News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Bug in new 1.1.11 download

Started by dcmouser, December 01, 2009, 09:31:17 PM

Previous topic - Next topic

dcmouser

Just downloaded the new 1.1.11 package and found this bug in Subs.php

In many places you have the line:
if (strpos($data, \'http://\') !== 0 || strpos($data, \'https://\') !== 0)

I believe that should be (in all cases):
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)

Basically if you leave it as is that condition is ALWAYS matched (since one of thos will not be ===0 meaning in first position), and so you get extra http:// added to each url and image link.
proud member of donationcoder.com (forum)

RMIGHTY1

TY dcmouser, that got the extra "HTTP://" out of the url's.

~~Ray     :D

vizzini

yep, that would do it.

for the lazy...
sed -i -e 's/0 ||/0 \&\&/g' Sources/Subs.php

assumes you haven't modified the stock install or upgrade Sources/Subs.php before running it

Arantor

This has actually been fixed, btw. Was fixed in the revised packages issued about 2 hours later.

If you updated within the first couple of hours, uninstall the patch, delete it and reinstall.

vizzini

Just dl'd all three bz2 files and they have the same issue...

Arantor

Weird. They were supposed to have been regenerated.

I know the upgrade from 1.1.10 -> 1.1.11 was fixed; I was using that myself.

Geek

Hi,

I just tried upgrading the Subs.php files from the downloads area (the Full and Small install .zips, 0145AM PST, Dec 2nd) and the bug is still there.

I just edited manually as per the first poster's instructions and voila! Fixed ;D

Cheers!
-= Gregg =-

Arantor

* Arantor goes and bugs the devs then to fix that.

vizzini

The above fix has issues as well; it always evaluates to zero.

I've been running the following changes for the past two hours without issue...

Original:if (strpos($data, \'http://\') !== 0 || strpos($data, \'https://\') !== 0)
Proposed:if (!(strncmp($data, \'http://\', 7) == 0 || strncmp($data, \'https://\', 8) == 0))

Original:elseif (strpos($data, \'http://\') !== 0 || strpos($data, \'https://\') !== 0)
Proposed:elseif (!(strncmp($data, \'http://\', 7) == 0 || strncmp($data, \'https://\', 8) == 0))

Original:if (strpos($data, \'ftp://\') !== 0 || strpos($data, \'ftps://\') !== 0)
Proposed:if (!(strncmp($data, \'ftp://\', 6) == 0 || strncmp($data, \'ftps://\', 7) == 0))

the above would cover cases like  'anonym.to/?http://example.com [nofollow]'.  I also suspect the assignment should be $data = $boardurl instead of just stuffing h t t p : / / infront; how else would you get relative urls in the smf_messages.body?

Arantor

Umm, the only time you should ever be able to produce relative URLs is with # links only, from what I remember of it.

davyp74

I have the same problem.
i have installed 1.1.11 today.


vizzini

rut-ro, i have a few "/index.php?board=x" in smf_messages.board... yes, without h t t p : / /  that's why i beginning to believe $data = $boardurl was the real intention.

Is there a smf specification on encoding? Perhaps someone has script to vigorously verify current expectations with regard to markup? 'Find and repair any errors' didn't catch this ( wouldn't expect it to )

Arantor

No, $boardurl was never the intention here, never has been. The idea is that url is supposed to be for full links (and always has been) so it's vetting for http://

vizzini

The downloads are the same; any word on an official fix time frame?

Arantor

Not yet. No doubt there will be a post if/when things get fixed.

javierjp

#15
Hi Arantor,

What we should do? i get the extra http:// too, we must wait for a official fix or we should apply the dcmouser solution?
thanks in advance.

edit: dcmouser, i tried your fix and works fine for posted images, but not solve the problem with posted urls, still with double http://

alphacaveman


dcmouser

make sure you change all occurences of if (strpos($data, \'http://\') !== 0 || strpos($data, \'https://\') !== 0)
and same for if (strpos($data, \'ftp://\') !== 0 || strpos($data, \'ftps://\') !== 0)

there are several places in that subs.php file where this is checked -- some cover img tags, others cover url tags; if you change them all it will be fixed.

Quote from: javierjp on December 02, 2009, 09:08:12 AM
edit: dcmouser, i tried your fix and works fine for posted images, but not solve the problem with posted urls, still with double http://
proud member of donationcoder.com (forum)

javierjp

Thanks for reply, so i must search and replace the || for &&  in all the tags with problems, right?

dcmouser

yes you can do a global search and replace in subs.php and replace
!== 0 || strpos($data,
with
!== 0 && strpos($data,
proud member of donationcoder.com (forum)

Advertisement: