Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .htaccess-example
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ DirectoryIndex index.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [B,L]
</IfModule>
10 changes: 5 additions & 5 deletions qa-include/qa-index.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ function qa_index_set_request()

foreach ($params as $param) {
if (preg_match('/^([^\=]*)(\=(.*))?$/', $param, $matches) && isset($matches[3])) {
$argument = strtr(rawurldecode($matches[1]), '.', '_'); // simulate PHP's $_GET behavior
$_GET[$argument] = qa_string_to_gpc(rawurldecode($matches[3]));
$argument = strtr(urldecode($matches[1]), '.', '_'); // simulate PHP's $_GET behavior
$_GET[$argument] = qa_string_to_gpc(urldecode($matches[3]));
}
}

Expand All @@ -86,10 +86,10 @@ function qa_index_set_request()
// Generally we assume that $_GET['qa-rewrite'] has the right path depth, but this won't be the case if there's
// a & or # somewhere in the middle of the path, due to Apache unescaping. So we make a special case for that.
// If 'REQUEST_URI' and 'qa-rewrite' already match (as on Nginx), we can skip this.
$normalizedpath = rawurldecode($origpath);
$normalizedpath = urldecode($origpath);
if (substr($normalizedpath, -strlen($qa_rewrite)) !== $qa_rewrite) {
$keepparts = count($requestparts);
$requestparts = explode('/', rawurldecode($origpath)); // new request calculated from $_SERVER['REQUEST_URI']
$requestparts = explode('/', urldecode($origpath)); // new request calculated from $_SERVER['REQUEST_URI']

// loop forwards so we capture all parts
for ($part = 0, $max = count($requestparts); $part < $max; $part++) {
Expand Down Expand Up @@ -134,7 +134,7 @@ function qa_index_set_request()
$origpath = substr($origpath, 0, $questionpos);
}

$normalizedpath = rawurldecode($origpath);
$normalizedpath = urldecode($origpath);
$indexpos = strpos($normalizedpath, $indexpath);
}

Expand Down