pike.git / lib / modules / Standards.pmod / URI.pike

version» Context lines:

pike.git/lib/modules/Standards.pmod/URI.pike:1:   #pike __REAL_VERSION__      //! This class implements URI parsing and resolving of relative references to   //! absolute form, as defined in RFC 2396 and RFC 3986.      // Implemented by Johan Sundström and Johan Schön. - // $Id: URI.pike,v 1.32 2009/09/17 17:25:11 grubba Exp $ + // $Id: URI.pike,v 1.33 2010/05/23 19:25:52 grubba Exp $      #pragma strict_types      //! Scheme component of URI   string scheme;      //! Authority component of URI (formerly called net_loc, from RFC 2396   //! known as authority)   string authority;   
pike.git/lib/modules/Standards.pmod/URI.pike:45:   #define DEBUG(X, Y ...) werror("Standards.URI: "+X+"\n", Y)   #else   #define DEBUG(X, Y ...)   #endif      // FIXME: What about decoding of Percent-Encoding (RFC3986 2.1)?   // cf pct-encoded in the functions below.      // Parse authority component (according to RFC 1738, § 3.1)   // Updated to RFC 3986 $ 3.2. + // NOTE: Censors the userinfo from the @[authority] variable.   protected void parse_authority()   {    // authority = [ userinfo "@" ] host [ ":" port ]    if(sscanf(authority, "%[^@]@%s", string userinfo, authority) == 2)    {    // userinfo = *( unreserved / pct-encoded / sub-delims / ":" )    sscanf(userinfo, "%[^:]:%s", user, password); // user info present    DEBUG("parse_authority(): user=%O, password=%O", user, password);    }    if(scheme)
pike.git/lib/modules/Standards.pmod/URI.pike:242:    }    DEBUG("Found scheme %O", scheme);       // Parse authority/login    //    // hier-part = "//" authority path-abempty / path-absolute    // / path-rootless / path-empty    if(sscanf(uri, "//%[^/]%s", authority, uri))    {    DEBUG("Found authority %O", authority); +  int q = search(authority, "?", search(authority, "@")+1); +  if (q >= 0) { +  // There's a question mark in the host and port section +  // of the authority. This happens when the path is empty +  // and there's a query part afterwards. +  // Example: http://foo?bar +  uri = authority[q..] + uri; +  authority = authority[..q-1]; +  DEBUG("Adjusted authority %O", authority);    } -  +  }       // Parse query information    // query = *( pchar / "/" / "?" )    // pchar = unreserved / pct-encoded / sub-delims / ":" / "@"    sscanf(uri, "%s?%s", uri, query);    DEBUG("Found query %O", query);       // Parse path:    // pchar = unreserved / pct-encoded / sub-delims / ":" / "@"    if ((uri == "") && !scheme && !authority && (this_program::base_uri)) {