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

`yourls_plugin_url()` breaks on symlinks #2541

Open
dgw opened this issue Aug 2, 2019 · 0 comments

Comments

@dgw
Copy link
Member

commented Aug 2, 2019

Describe the bug
If a plugin directory is symlinked into YOURLS' plugins directory, calls to yourls_plugin_url() for that plugin's directory return nonexistent, incorrect URLs.

To Reproduce
Steps to reproduce the behavior:

  1. Symlink a plugin directory into YOURLS_ROOT/user/plugins/
  2. Load a page that the plugin affects, e.g. by injecting a script or stylesheet

A plugin that uses yourls_plugin_url() is needed, of course. I discovered this issue while installing the Sleeky backend.

So, let's say I have a plugin living in /home/dgw/repos/Sleeky/sleeky-backend, with symlink /home/dgw/yourls/user/plugins/sleeky-backend pointing to it, for the purpose of explanation.

Expected behavior
The injected asset loads correctly. yourls_plugin_url('file.ext') generates the URL https://yourls_site/user/plugins/sleeky-backend/file.ext

Actual behavior
The injected asset fails to load, because the URL generated is incorrect. yourls_plugin_url('file.ext') generates https://yourls_site/home/dgw/repos/Sleeky/sleeky-backend/file.ext.

Versions
YOURLS 1.7.x (the code for this function has not changed since 1.6) on Ubuntu Linux under nginx with php-fpm.

Additional context
I made the examples above with a specific file for clarity. However, Sleeky itself uses yourls_plugin_url( __DIR__ ) and then stores that value for later. Either way, the method used in yourls_plugin_basename() to remove the leading absolute path is likely the root cause here.

There's an easy workaround to this, of course: Don't symlink plugin directories. But this approach to adding plugins works in many, many different software packages—I use it a ton. Low priority this bug may be, I do think it really is a bug.

@dgw dgw added the bug label Aug 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.