Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-06-13
02:32 • Closed ticket [920728ffff]: Regexp misparses some URL plus 7 other changes artifact: e667498236 user: hobbs
2005-01-12
18:41 • Ticket [920728ffff]: 4 changes artifact: 2539b91445 user: dkf
2004-03-22
01:57 • New ticket [920728ffff]. artifact: 6e20eecdef user: nobody

Regexp misparses some URL

Closed / Out of Date920728ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 19 years ago
Descriptionplain2004-03-22 01:57:14
A URL of the form
http://foo.com/@bar.com/url.ext
is misparsed with the host being bar.com instead of foo.com.

The problem is an attempt to parse [email protected] type URL

This code is where it happens:

       set exp {^(([^:]*)://)?([^@]+@)?([^/:]+)(:([0-9]+))?(/.*)?$}
       if {![regexp -nocase $exp $url x prefix proto user host y port srvurl]} {

This modification (adding a / to the unrecognzed characters as part of a 
"name@" field) solves the problem.
  
        set exp {^(([^:]*)://)?([^@/]+@)?([^/:]+)(:([0-9]+))?(/.*)?$}
        if {![regexp -nocase $exp $url x prefix proto user host y port srvurl]} {

Submitted by [email protected]
dkfplain2005-01-12 18:41:12
Logged In: YES 
user_id=79902

The correct URL (and its interpretation) is this horror:
set exp
{^(?:([^:]*)://)?(?:([^@/:]+)(?::([^@/:]+))?@)?([^/:]+)(?::([0-9]+))?(/.*)?$}
regexp $exp -> proto user pass host port path
hobbsplain2007-06-13 02:32:10
Logged In: YES 
user_id=72656
Originator: NO

Works correctly in head.
Log in (anonymous is fine) to add a comment.