Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

IMG BBCode v7 & v9 question (possible redundant code)

I was wondering why all allowed extensions are in lower- and in uppercase in the preg_replace_callback!
The regex has an operator at the end of the regex which makes it case insensitive. See #si.

Then wouldn't it be better to strip the duplicates for performance sake?

The file and code I'm talking about is in; img_bbcode_include.php
$text = preg_replace_callback("#\[img\]((http|ftp|https|ftps)://)(.*?)(\.(jpg|jpeg|gif|png|JPG|JPEG|GIF|PNG))\[/img\]#si", "img_bbcode_callback", $text); 

Come on people, has no one any thoughts on this?

To all who read this. Happy Christmas and a prosperous 2016!
To the devs. Thanks for all your spare time invested in php-fusion.
I have not been digging to much in to it, it is a pattern often seen.
The extra is probably just a fail-safe addition. You can for example see it in preg_match for alpha chars pretty often as well (a-zA-Z).
WO doing any more extensive research on it and if I had to do an guess, Id say it could be because of older PHP versions to maintain compatibility.

Merry Christmas !
Thanks for your thoughts on this, seems a logical explanation. I'll try to find out if the fail safe is really necessary for the minimum php version that is advised/required for php-fusion.
I played a little with the regex and ended up with a simpler regex which uses less steps (old: 103 steps, new: 96 steps). I assume less steps is better performance:
$text = preg_replace_callback("#\[img\]((https?|ftps?):\/\/)(.*?)(\.(jpg|jpeg|gif|png))\[\/img\]#si", "img_bbcode_callback", $text);

You can test it here; https://regex101.com/r/cB4kY4/1
Let´s see what the Lead Dev says :)
Thread Information
Posted In
6 posts
1076 times
Last Post
Last updated on 5 years ago
You can view all discussion threads in this forum.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
Users who participated in discussion: Falk, Wanabo