stacey
stacey copied to clipboard
Problem with %2F encoded URLs - Encoded Slashes
When Stacey is not configured with clean URLs, there is a problem with Encoded Slashes.
When trying to post a link to a stacey site on Facebook, forward slashes after the ?
are encoded with %2F
– which are not properly handled. i.e. http://maribastashevski.com/?%2Fworks%2Fprivileged-confidential%2F
(instead of http://maribastashevski.com/?/works/privileged-confidential/
)
(Yes, this is Facebook's fault, but Zuck's not answering my emails, so…)
The proper solution would be to configure .htaccess
with AllowEncodedSlashes on
, but some hosting services (mine in any case) may not allow this.
Assuming enabling clean URLs isn't an option in this case, is there a way to modify how Stacey handles requests so as to deal with Encoded Slashes properly?
It seems that on line 127 of stacey.inc.php
$key = preg_replace(array('/\/$/', '/^\//'), '', key($get));
is already doing some work on cleaning up the URL data, seems like this is where magic could happen.
(this is on v. v2.3.0)
OK, I tried adding a line:
$key = str_replace('%2F', '/', key($get));
and then changing the original line 127 to receive the 'cleaned' version of the passed URL
$key = preg_replace(array('/\/$/', '/^\//'), '', $key);
but this seems not to work.
anyone have any ideas?
How about
$key = urldecode(key($get));
?
Kolber, I tried your suggestion, but it still gives the same error…
$key = urldecode(key($get));
# strip any leading or trailing slashes from the passed url
$key = preg_replace(array('/\/$/', '/^\//'), '', $key);
i'm guessing it has to be taken care of in .htaccess?
I had that problem, I cheked and I saw that I had folders in the project folder with accents and other non valid url characters (spanish website). So i fixed them all and seems to work now. It even affected if other project folders had those characters, to it seems that the parser gets corrupted and can affect strings in all the website.