News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

2.0.18 -> 2.0.19: QueryString.php Test Failed

Started by Gus A, January 20, 2022, 08:56:23 AM

Previous topic - Next topic

Gus A

Hey folks. Hope everyone is doing well. Just tried to apply this update and I get a "Test failed" error for ./Sources/QueryString.php

When I click on the edit icon on the left I get this message (see attached screenshot).

I'm assuming that I need to find this line of code

if (strpos($m[0], $context['session_var']) === false)

And replace it with this.

if (!empty($context['session_var']) && strpos($m[0], $context['session_var']) === false)
The only problem is that I can't find that first line in the QueryString.php file.

Am I missing something?

You cannot view this attachment.



Gus A

Quote from: Doug Heffernan on January 20, 2022, 09:54:40 AMCan you attach the file in question here?

Here you go!

You cannot view this attachment.

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Doug Heffernan

Quote from: Kindred on January 20, 2022, 10:57:05 AMhttps://wiki.simplemachines.org/smf/Error_in_mod_installation

As mentioned above, the OP can not find the code mentioned in the error message.

Quote from: Gus A on January 20, 2022, 10:24:38 AM
Quote from: Doug Heffernan on January 20, 2022, 09:54:40 AMCan you attach the file in question here?

Here you go!

You cannot view this attachment.


You are right. The code mentioned in the error message does not exist. Anyways, find this code:

// This should work even in 4.2.x, just not CGI without cgi.fix_pathinfo.
if (!empty($modSettings['queryless_urls']) && (!$context['server']['is_cgi'] || @ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && ($context['server']['is_apache'] || $context['server']['is_lighttpd']))
{
// Let's do something special for session ids!
if (defined('SID') && SID != '')
$buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic|page)=[^#"]+?)(#[^"]*?)?"~', 'sid_insert__preg_callback', $buffer);
else
$buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?((?:board|topic|page)=[^#"]+?)(#[^"]*?)?"~', 'pathinfo_insert__preg_callback', $buffer);
}

And add below:

// Be nice and try to inject session tokens into login forms since many older themes don't.
if ($user_info['is_guest'])
$buffer = preg_replace_callback(
'~(<form[^<]+action=login2(.+))</form>~iUs' . (!empty($context['utf8']) ? 'u' : ''),
function ($m) use ($context)
{
$repl = '';
if (!empty($context['session_var']) && strpos($m[0], $context['session_var']) === false)
$repl .= '<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"/>';

return $m[1] . $repl . '</form>';
},
$buffer
);

Save the changes and you should be all set. Or better yet, reupload said file in question with that of the 2.0.19 upgrade package. If you have made manual edits to the file, you will have to re-add them again. Hope it helps.

Kindred

Quote from: Doug Heffernan on January 20, 2022, 12:30:28 PMAs mentioned above, the OP can not find the code mentioned in the error message.


Well, yes, but that's why the automatic part failed -- the manual part is finding the code (which was probably modified by a mod) and use human logic to apply...

If that entire section of code is missing, that begs the question WHY it is missing in a core file
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Doug Heffernan

Quote from: Kindred on January 20, 2022, 01:33:14 PMWell, yes, but that's why the automatic part failed -- the manual part is finding the code (which was probably modified by a mod) and use human logic to apply...

If that entire section of code is missing, that begs the question WHY it is missing in a core file

Nope, that part of the code was not modified by a mod, but it was completely missing. That part of the code mentioned in the error message should have been there.

That is based upon checking the file that the OP attached btw. I have not checked the original file from the 2.0.18 package. If the OP has installed a mod that removes that part, it is entirely a different matter then.

Gus A

Gentlemen, this worked like a charm. Can't thank you enough for the help!


Doug Heffernan

Quote from: Gus A on January 20, 2022, 02:41:41 PMGentlemen, this worked like a charm. Can't thank you enough for the help!



Glad to have been of help.

Advertisement: