Euphoria Ticket #940: parse_url fails on redirection

sequence url = "http://extranet.oneaccess-net.com/drupal/?url=http://extranet.oneaccess-net.com/support/" 
sequence s = parse(url, 0) 

fails with error

C:\Data\Euphoria\v4\parse_url.ex:94 in function parse() 
slice length is less than 0 (-18) - in slice/subscript #1 of 'url' 

Checked with latest source code on SCM.

Jean-Marc

Details

Type: Bug Report Severity: Normal Category: Interpreter
Assigned To: unknown Status: New Reported Release: 4.1
Fixed in SVN #: View VCS: none Milestone:

1. Comment by jmduro Nov 09, 2015

A way to correct the bug is to modify include/std/net/url.e as follows

    integer first_slash = find('/', url, pos) 
    integer at = find('@', url) 
    if not at then 
        -- We do not have a user or password, skip ahead to parsing the domain 
        goto "parse_domain" 
    end if 
     
    integer password_colon = find(':', url[1..first_slash], pos) 
    if password_colon > 0 and password_colon < at then 
        -- We have a password too! 
        user_name = url[pos..password_colon-1] 
        password = url[password_colon+1..at-1] 
    else 
        -- Just a user name 
        user_name = url[pos..at-1] 
    end if 
     
    pos = at + 1 
 
label "parse_domain" 
     
    integer qs_start = find('?', url, pos) 
    integer port_colon = find(':', url[1..first_slash], pos) 

'first_slash' must be declared before 'at', 'password_colon' and 'port_colon' must be checked only on 'url[1..first_slash]'.

2. Comment by jmduro Nov 09, 2015

Not that easy: first_slah can also have value 0, so port_colon might be declared this way:

    if first_slash then 
      port_colon = find(':', url[1..first_slash], pos) 
    else 
      port_colon = find(':', url, pos) 
    end if 

Search



Quick Links

User menu

Not signed in.

Misc Menu