Preserved Topic: Pattern Matching a URL (Page 1 of 1) |
|
---|---|
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 01-28-2003 02:07
I am having a bit of trouble coming up with a perl style pattern matching for the generic URL. |
Paranoid (IV) Inmate From: Milwaukee |
posted 01-28-2003 03:24
The PHP.net section on Perl-compatible regular expressions has lots of code in the comments sections. Try this page and scan down to the entry that starts: quote:
|
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 01-28-2003 03:43
Thanks a lot. That is exactly what I am looking for. The Pattern is bellow, I am going to attempt to deconstruct it and I will post that when I do. I just wanted to let you know that I really appreciate it. code: "((.*?):\/\/)?(([^:]*) :([^@]*)@)?([^\/:]*)( :([^\/]*))?([^\?]*\/?)?(\?(.*))?"
|
Paranoid (IV) Inmate From: Milwaukee |
posted 01-28-2003 05:41
Well, I could deconstruct 80% of it off the top of my head, there's nothing really zany going on with it -- no backreferences or anything arcane like that. But it'll probably be a good experience for you to do it yourself. |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 01-28-2003 12:40 |
Maniac (V) Mad Scientist From: 127 Halcyon Road, Marenia, Atlantis |
posted 01-28-2003 17:16
we did this a while back... lemme find the thread... |
Maniac (V) Mad Scientist From: 127 Halcyon Road, Marenia, Atlantis |
posted 01-28-2003 17:46
while searching for the old thread, I decided to post a reference for that code that WarMage spit out: code: ( # begin a 'unity'
|
Maniac (V) Mad Scientist From: 127 Halcyon Road, Marenia, Atlantis |
posted 01-28-2003 17:55
the code goes like this |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 01-28-2003 18:10
the biggest issue I see for that one is the "www" part. That last one isn't really that efficient and would also allow for XSS attacks (which is one of the big reasons to parse submitted URLS). Basically the second only looks for some string with http:// or https?://www code: < a href="http://www.<script>alert('document.cookie')</script>">here</a>
|
Maniac (V) Mad Scientist From: 127 Halcyon Road, Marenia, Atlantis |
posted 01-28-2003 19:27
aren't you turning '<' to '<' anyway? |