Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

preg_match problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
DoT
Smarty n00b


Joined: 28 Mar 2004
Posts: 4

PostPosted: Fri Apr 02, 2004 8:57 pm    Post subject: preg_match problem Reply with quote

Hi,

i am parsing a $_REQUEST Var through the function preg_match

[php:1:cc3ca2f277]
$url = $_REQUEST['url'];
if(!preg_match("/[a-z]:\/\//si", $url)) $url = "http://$url";[/php:1:cc3ca2f277]

if i am giving a index.php?url=site.com it makes http://site.com ... ok
but if i try index.pgp?url=http://site.com it makes http://http:/site.com <- error

the pref_match w/o smarty works fine *g*
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Apr 02, 2004 10:38 pm    Post subject: Reply with quote

I don't think it working or not has anything to do with Smarty. This regex may be slightly more appropriate for you:
Code:
^[a-z]{3,4}:\/\/

It anchors its search to the start of the subject ($url) and insists that the protocol is 3 or 4 (lowercase english letters) long.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP