Menu

Patch available for relative redirections (SR_ERROR_INVALID_URL)

2013-05-14
2023-09-06
  • Eugene Adell

    Eugene Adell - 2013-05-14

    When a server sends a redirection (Location header) with a relative URL instead of absolute, streamripper dies with SR_ERROR_INVALID_URL error message.
    The faulty one in this story, is the server by not applying RFC 2616, but it is better to have a client-side solution to this problem to allow the download as expected by the end-user.

    I created this patch for lib/http.c file :

    cat http.c.patch-20130514

    --- http.c      2013-05-14 11:21:15.164984928 +0200
    +++ http.c.patched-20130514     2013-05-14 11:17:30.490985091 +0200
    @@ -103,8 +103,19 @@
            if (*info->http_location) {
                /* RECURSIVE CASE */
                debug_printf ("Redirecting: %s\n", info->http_location);
    -           url = info->http_location;
    -           return http_sc_connect (rmi, sock, info->http_location,
    +           /* PATCH for non-absolute redirects, when servers are not compliant to RFC */
    +           /* see http://tools.ietf.org/html/rfc2616#section-14.30 */
    +           /* written by Eugene Adell eugene_adell@hotmail.com */
    +           if ( (strchr(info->http_location, '/') - info->http_location) == 0 ) {
    +               char localbuffer [1024];
    +               sprintf(localbuffer, "http://%s:%d%s", url_info.host, url_info.port,info->http_location);
    +               debug_printf ("Location gave a relative URL, we must rebuild it to absolute : URL will be %s \n", localbuffer);
    +               url = localbuffer;
    +           }
    +           else {
    +               url = info->http_location;
    +           }
    +           return http_sc_connect (rmi, sock, url,
                                        proxyurl, info, useragent, if_name);
            } else {
                break;
    

    Apply it like any other patch :
    patch < http.c.patch-20130514

     

    Last edit: Eugene Adell 2013-05-14
  • Eugene Adell

    Eugene Adell - 2017-09-09

    I didn't mention, but the previous patch I posted was for version 1.63.5. Here is one for version 1.64.6 which is, according to wikipedia, the last stable release (the 1.65.0 CHANGES says 1.65.0 is really bugged, and the download doesn't contain the configure script even .. )

     
    • Julien Ferreiro

      Julien Ferreiro - 2023-09-06

      Hi
      I'm running on Win 10 and still have the same problem...
      I just reinstall all my PC, but still had the issue before it.
      I saw your post but I'm pretty bad to understand it, could you explain how to apply your patch to a newbie? ^^
      Thanks

       

      Last edit: Julien Ferreiro 2023-09-06
  • Julien Ferreiro

    Julien Ferreiro - 2023-09-01

    Hi
    I'm running on Win 10 and still have the same problem...
    I just reinstall all my PC, but still had the issue before it.
    I saw your post but I'm pretty bad to understand it, could you explain how to apply your patch to a newbie? ^^
    Thanks

     

Log in to post a comment.