Re: TypeError in ExternalReferrer under php8

"Marc-Etienne Vargenau (Nokia)" <[email protected]> Thu, 16 Nov 2023 15:57:56 +0000
Newsgroups gmane.comp.web.wiki.phpwiki.talk
Message-ID <PR3PR07MB818397804E689F53D99FFCD6ACB0A@PR3PR07MB8183.eurprd07.prod.outlook.com>
--===============3549401180454477502==
Content-Language: fr-FR
Content-Type: multipart/alternative;
	boundary="_000_PR3PR07MB818397804E689F53D99FFCD6ACB0APR3PR07MB8183eurp_"

--_000_PR3PR07MB818397804E689F53D99FFCD6ACB0APR3PR07MB8183eurp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Thom,

I have just published PhpWiki 1.6.3 with a fix for your issue.

You can download it at: https://sourceforge.net/projects/phpwiki/

Thank you again for your bug report.

Best regards,

Marc-Etienne

--
Marc-Etienne Vargenau [email protected]<mailto:marc-etienne.v=
[email protected]>
Nokia, 12, rue Jean-Bart, 91300 Massy, FRANCE
Mobile: +33 6 24 49 78 68<tel:+33624497868>
Senior Specialist Open Source
Planned absence: none


De : Marc-Etienne Vargenau (Nokia) <[email protected]>
Date : mercredi, 8 novembre 2023 =E0 19:55
=C0 : Discussion on PhpWiki features, bugs, development. <phpwiki-talk@list=
s.sourceforge.net>
Cc : Thom Jeera <[email protected]>
Objet : Re: [Phpwiki-talk] TypeError in ExternalReferrer under php8
Hi Thom,

Thank you for the report.
I will test and provide a fix.

Is your Phpwiki internal or available on the Internet?

Best regards,

Marc-Etienne

--
Marc-Etienne Vargenau [email protected]<mailto:marc-etienne.v=
[email protected]>
Nokia, 12, rue Jean-Bart, 91300 Massy, FRANCE
Mobile: +33 6 24 49 78 68<tel:+33624497868>
Senior Specialist Open Source
Planned absence: none


De : Thom Jeera via Phpwiki-talk <[email protected]>
Date : mardi, 24 octobre 2023 =E0 21:35
=C0 : [email protected] <[email protected]=
t>
Cc : Thom Jeera <[email protected]>
Objet : [Phpwiki-talk] TypeError in ExternalReferrer under php8

CAUTION: This is an external email. Please be very careful when clicking li=
nks or opening attachments. See the URL nok.it/ext for additional informati=
on.



Hi - I'm running phpwiki-1.6.2 on php 8.2.11.

I saw an error when someone clicked a phpwiki link from within a gmail app =
- see bottom of email. The 'google.' in the referer triggers the external r=
eferrer code, which breaks under php8 (seems ok in php5 - I couldn't recrea=
te it against phpwiki.demo.free.fr for instance).

Something like this would trigger it under php8:

curl -H 'referer: android-app://com.google.android.gm/' http://phpwiki.demo=
.free.fr/index.php/SandBox

The code here in ExternalReferrer.php looks inconsistent - if there is no q=
uery string (ie the tested value IS empty), then $url is still an array whe=
n it gets passed into stristr, hence the error.

        if (!empty($url["query"])) {
            $url =3D $url["query"];
        }

        if ($query1 and @stristr($url, $query1)) {

The behaviour is present but the error gets suppressed under earlier versio=
ns of php.

Suggested fix: add "else return false;" after the !empty test ?


Reported error:

Got error 'PHP message: PHP Fatal error:  Uncaught TypeError: stristr():
Argument #1 ($haystack) must be of type string, array given in /syshome/web=
chris/html/phpwiki-1.6.1/lib/ExternalReferrer.php:129
Stack trace:
#0 /syshome/webchris/html/phpwiki-1.6.1/lib/ExternalReferrer.php(129): stri=
str()
#1 /syshome/webchris/html/phpwiki-1.6.1/lib/stdlib.php(1890): SearchEngines=
->parseSearchQuery()
#2 /syshome/webchris/html/phpwiki-1.6.1/lib/display.php(324): isExternalRef=
errer()
#3 /syshome/webchris/html/phpwiki-1.6.1/lib/main.php(1069): displayPage()
#4 /syshome/webchris/html/phpwiki-1.6.1/lib/main.php(816): WikiRequest->act=
ion_browse()
#5 /syshome/webchris/html/phpwiki-1.6.1/lib/main.php(1451): WikiRequest->ha=
ndleAction()
#6 /syshome/webchris/html/phpwiki-1.6.1/lib/main.php(1475): main()
#7 /syshome/webchris/html/phpwiki-1.6.1/index.php(60): include('...')
#8 {main}
  thrown in /syshome/webchris/html/phpwiki-1.6.1/lib/ExternalReferrer.php o=
n line 129', referer: android-app://com.google.android.gm/


Regards,
Thom.


_______________________________________________
Phpwiki-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/phpwiki-talk

--_000_PR3PR07MB818397804E689F53D99FFCD6ACB0APR3PR07MB8183eurp_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" xmlns:w=3D"urn:sc=
hemas-microsoft-com:office:word" xmlns:m=3D"http://schemas.microsoft.com/of=
fice/2004/12/omml" xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	font-size:10.0pt;
	font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
span.EmailStyle19
	{mso-style-type:personal-reply;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;
	mso-ligatures:none;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
	{page:WordSection1;}
--></style>
</head>
<body lang=3D"FR" link=3D"blue" vlink=3D"purple" style=3D"word-wrap:break-w=
ord">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">Hi Thom,<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">I have just published PhpWiki 1.6.3 with a fix for y=
our issue.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">You can download it at:
<a href=3D"https://sourceforge.net/projects/phpwiki/">https://sourceforge.n=
et/projects/phpwiki/</a><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">Thank you again for your bug report.<o:p></o:p></spa=
n></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;mso-fareast-language=
:EN-US">Best regards,<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;mso-fareast-language=
:EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;mso-fareast-language=
:EN-US">Marc-Etienne<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;mso-fareast-language=
:EN-US"><o:p>&nbsp;</o:p></span></p>
<div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-family:&quot;Courier New&quot;;c=
olor:#212121">--&nbsp;<br>
Marc-Etienne&nbsp;Vargenau&nbsp;<a href=3D"mailto:marc-etienne.vargenau@nok=
ia.com" title=3D"mailto:[email protected]"><span style=3D"col=
or:#0078D7;text-decoration:none">marc-etienne</span><span style=3D"color:#0=
078D7">[email protected]</span></a><br>
Nokia, 12, rue Jean-Bart, 91300 Massy, FRANCE<br>
Mobile:&nbsp;<a href=3D"tel:+33624497868"><span style=3D"color:#0078D7">+33=
 6 24 49 78 68</span></a></span><span style=3D"font-size:11.0pt;color:#2121=
21"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-family:&quot;Cour=
ier New&quot;;color:#212121">Senior Specialist Open Source<br>
Planned absence:&nbsp;</span><b><span lang=3D"EN-US" style=3D"font-size:11.=
0pt;font-family:&quot;Courier New&quot;;color:#212121">none</span></b><span=
 lang=3D"EN-US" style=3D"font-size:11.0pt;color:#212121"><o:p></o:p></span>=
</p>
</div>
</div>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
<div id=3D"mail-editor-reference-message-container">
<div>
<div style=3D"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm =
0cm 0cm">
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><b><span style=3D"fon=
t-size:12.0pt;color:black">De&nbsp;:
</span></b><span style=3D"font-size:12.0pt;color:black">Marc-Etienne Vargen=
au (Nokia) &lt;[email protected]&gt;<br>
<b>Date&nbsp;: </b>mercredi, 8 novembre 2023 =E0 19:55<br>
<b>=C0&nbsp;: </b>Discussion on PhpWiki features, bugs, development. &lt;ph=
[email protected]&gt;<br>
<b>Cc&nbsp;: </b>Thom Jeera &lt;[email protected]&gt;<br>
<b>Objet&nbsp;: </b>Re: [Phpwiki-talk] TypeError in ExternalReferrer under =
php8<o:p></o:p></span></p>
</div>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;mso-fareast-language=
:EN-US">Hi Thom,</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;mso-fareast-language=
:EN-US">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">Thank you for the report.</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">I will test and provide a fix.</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">Is your Phpwiki internal or available on the Interne=
t?</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">Best regards,</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">Marc-Etienne</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">&nbsp;</span><o:p></o:p></p>
<div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-family:&quot;Courier New&quot;;c=
olor:#212121">--&nbsp;<br>
Marc-Etienne&nbsp;Vargenau&nbsp;<a href=3D"mailto:marc-etienne.vargenau@nok=
ia.com" title=3D"mailto:[email protected]"><span style=3D"col=
or:#0078D7;text-decoration:none">marc-etienne</span><span style=3D"color:#0=
078D7">[email protected]</span></a><br>
Nokia, 12, rue Jean-Bart, 91300 Massy, FRANCE<br>
Mobile:&nbsp;<a href=3D"tel:+33624497868"><span style=3D"color:#0078D7">+33=
 6 24 49 78 68</span></a></span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-family:&quot;Cour=
ier New&quot;;color:#212121">Senior Specialist Open Source<br>
Planned absence:&nbsp;</span><b><span lang=3D"EN-US" style=3D"font-size:11.=
0pt;font-family:&quot;Courier New&quot;;color:#212121">none</span></b><o:p>=
</o:p></p>
</div>
</div>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt;mso-f=
areast-language:EN-US">&nbsp;</span><o:p></o:p></p>
<div id=3D"mail-editor-reference-message-container">
<div>
<div style=3D"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm =
0cm 0cm">
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><b><span style=3D"fon=
t-size:12.0pt;color:black">De&nbsp;:
</span></b><span style=3D"font-size:12.0pt;color:black">Thom Jeera via Phpw=
iki-talk &lt;[email protected]&gt;<br>
<b>Date&nbsp;: </b>mardi, 24 octobre 2023 =E0 21:35<br>
<b>=C0&nbsp;: </b>[email protected] &lt;phpwiki-talk@lists=
.sourceforge.net&gt;<br>
<b>Cc&nbsp;: </b>Thom Jeera &lt;[email protected]&gt;<br>
<b>Objet&nbsp;: </b>[Phpwiki-talk] TypeError in ExternalReferrer under php8=
</span><o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt"><br>
CAUTION: This is an external email. Please be very careful when clicking li=
nks or opening attachments. See the URL nok.it/ext for additional informati=
on.<br>
<br>
<br>
<br>
Hi - I'm running phpwiki-1.6.2 on php 8.2.11.<br>
<br>
I saw an error when someone clicked a phpwiki link from within a gmail app =
- see bottom of email. The 'google.' in the referer triggers the external r=
eferrer code, which breaks under php8 (seems ok in php5 - I couldn't recrea=
te it against phpwiki.demo.free.fr
 for instance).<br>
<br>
Something like this would trigger it under php8:<br>
<br>
curl -H 'referer: android-app://com.google.android.gm/' <a href=3D"http://p=
hpwiki.demo.free.fr/index.php/SandBox">
http://phpwiki.demo.free.fr/index.php/SandBox</a><br>
<br>
The code here in ExternalReferrer.php looks inconsistent - if there is no q=
uery string (ie the tested value IS empty), then $url is still an array whe=
n it gets passed into stristr, hence the error.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!empty($url[&quot;query&quot=
;])) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $url =3D=
 $url[&quot;query&quot;];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($query1 and @stristr($url, $=
query1)) {<br>
<br>
The behaviour is present but the error gets suppressed under earlier versio=
ns of php.<br>
<br>
Suggested fix: add &quot;else return false;&quot; after the !empty test ?<b=
r>
<br>
<br>
Reported error:<br>
<br>
Got error 'PHP message: PHP Fatal error:&nbsp; Uncaught TypeError: stristr(=
):<br>
Argument #1 ($haystack) must be of type string, array given in /syshome/web=
chris/html/phpwiki-1.6.1/lib/ExternalReferrer.php:129<br>
Stack trace:<br>
#0 /syshome/webchris/html/phpwiki-1.6.1/lib/ExternalReferrer.php(129): stri=
str()<br>
#1 /syshome/webchris/html/phpwiki-1.6.1/lib/stdlib.php(1890): SearchEngines=
-&gt;parseSearchQuery()<br>
#2 /syshome/webchris/html/phpwiki-1.6.1/lib/display.php(324): isExternalRef=
errer()<br>
#3 /syshome/webchris/html/phpwiki-1.6.1/lib/main.php(1069): displayPage()<b=
r>
#4 /syshome/webchris/html/phpwiki-1.6.1/lib/main.php(816): WikiRequest-&gt;=
action_browse()<br>
#5 /syshome/webchris/html/phpwiki-1.6.1/lib/main.php(1451): WikiRequest-&gt=
;handleAction()<br>
#6 /syshome/webchris/html/phpwiki-1.6.1/lib/main.php(1475): main()<br>
#7 /syshome/webchris/html/phpwiki-1.6.1/index.php(60): include('...')<br>
#8 {main}<br>
&nbsp; thrown in /syshome/webchris/html/phpwiki-1.6.1/lib/ExternalReferrer.=
php on line 129', referer: android-app://com.google.android.gm/<br>
<br>
<br>
Regards,<br>
Thom.<br>
<br>
<br>
_______________________________________________<br>
Phpwiki-talk mailing list<br>
[email protected]<br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/phpwiki-talk">https=
://lists.sourceforge.net/lists/listinfo/phpwiki-talk</a></span><o:p></o:p><=
/p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

--_000_PR3PR07MB818397804E689F53D99FFCD6ACB0APR3PR07MB8183eurp_--


--===============3549401180454477502==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============3549401180454477502==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Phpwiki-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/phpwiki-talk

--===============3549401180454477502==--