test
https://www.google.it
https://www.google.it
Https://www.google.it
Https://www.google.it
HTTP://www.google.itt
HTTP://www.google.it
it happens to elkarte 1.0.x but also here on elkarte 1.1
Looks like it's not seeing the caps as the http for some odd reason.
Wonder if you know what also had this.
Okay, after testing on an old, old, site, yes, this is a SMF problem, as well. :D
I think this could be solved using the "Censored word" function included into elkarte/smf, I did not test it but should work.
Anyway will be better if solved into the core ;)
Good to know this is also an SMF bug, did you alredy reported to SMF
@Burke Knight ?
edit: reported also to SMF http://www.simplemachines.org/community/index.php?topic=550527
Thats kind of funny!
Well the quick fix is in Subs.php, and the bug should effect urls, iurls and img tags as well. Anyway in that file search for
strpos($data, 'http://') !== 0 && strpos($data, 'https://') !== 0)
I think you will find it 6 times. Change that to
stripos($data, 'http://') !== 0 && stripos($data, 'https://') !== 0)
and then it should stop doing what its doing.
May look at whats best there at that point, this, a substr or a simple regex, but anyway.
Tested on localhost, I confirm it works. Thanks Spuds
Glad it worked .... looking at it just a moment more, I'll probably PR something more like
if (preg_match("~^https?://~i", $data) !== 1)
since its cleaner to me.
Also in a quick test this was a bit more efficient if the selector was https (ie one preg_match was faster than two stripos or two strpos for that matter). If the link was http then it was slightly slower (single strpos or stripos). Of course this is one of those silly micro optimizations that should not be taken very seriously, its just for my entertainment.
Really? Hahaha!!!!!
Why should I even entertain the thought of helping that vile project and it's evil Project Manager, who does not even know a quarter of their product than a 2 year old does?
His first reply to you in your report, proves it.
He's not interested in SMF, and improving it.
He's just interested in shifting the blame for things, and making it seem like every issue is user error.
Sheesh. I'll never help any SMF site, until they get smart, and kick him out.
Please, free bashing is not really helpful to anyone.
That said, arguments that support the objection are instead always welcome:
So we add a $match to the preg and
strtolower($match[0])
Are we so picky? lol
At the moment I did this:
https://github.com/elkarte/Elkarte/compare/development...emanuele45:protocol
to replace the protocol we'd need to first remove it?
Then maybe:
$pattern = '/^(' . implode('|', array_map(function ($val) {return preg_quote($val, "/");}, $protocols)) . ')/i';
$found = false;
$url = preg_replace_callback($pattern, function($match) use (&$found) {
$found = true;
return strtolower($match[0]);
}, $url);
if ($found === true)
{
return $url;
}
return $protocols[0] . $url;
Good point, its already ~8X slower then whats there now, no need to add more functions to that cauldron lol.
ETA:
If it were me, I'd set $protocals = array() in the function, then
if (empty($protocols))
$pattern = '~^https?://~i';
else
$pattern = '/^(' . implode('|', array_map(function ($val) {return preg_quote($val, "/");}, $protocols)) . ')/i';
to avoid having to build $pattern when you know what it will be by default, that cuts down on the inefficiency.
Good point.
ETA: BTW, what code are you using to test efficiency? O:-)
I don't understand much of what you two wrote above, but I'm glad to see that elkarte is having such an attention on performance. We all love fast websites ;)
OT: regarding SMF, I'm not using it, but I still read and sometimes write on sm.org forums... I did the report, it's up to their team to decide what to do.
Good old Ubench ... a version I made some minor updates to (some time back), but its still unknown w brackets program