Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API not functioning correctly when backend plugin enabled with PrivateBin #113

Open
LuckVintage opened this issue Jul 17, 2022 · 0 comments

Comments

@LuckVintage
Copy link

Hi,

Since enabling the backend plugin for Sleeky I've noticed that the YOURLS API seems to have a slight issue when used with PrivateBin.

When attempting to use the API via PrivateBin to shorten a paste, I always receive the 'Too Many requests' page - however, the URL seems to get added successfully anyway. When disabling the plugin, the API seems to function normally when used with PrivateBin again.

chrome_R00GMomf9M (1)

If I use the API directly in my browser (instead of using PrivateBin), everything functions as intended.

After looking at the source code for Sleeky's backend, I think I'm experiencing this issue because the API always has <style>ul#admin_menu li:not(.frontend_link) {display: none}</style> infront of the API response, which isn't valid JSON. PrivateBin is expecting a JSON response from the API. Whenever there is an error/unexpected response, PrivateBin opens the API URL directly in a new browser tab which seems to trigger YOURLS's flood prevention as it tries to add the URL again straight after it was already added.

When I removed the code:

// Hide admin links for non-authenticated users if (yourls_is_valid_user() != 1) { echo <<<HEAD <style>ul#admin_menu li:not(.frontend_link) {display: none}</style> HEAD; }

from the very end of the backend plugin.php file, the API seems to function as expected when used with PrivateBin.

Obviously, just removing the code isn't a valid fix, more a temporarily workaround. To fix this issue, I think the <style>ul#admin_menu li:not(.frontend_link) {display: none}</style> code needs to stop appearing in front of the API file.

Many Thanks 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant