pike.git / lib / modules / Web.pmod / Auth.pmod / module.pmod

version» Context lines:

pike.git/lib/modules/Web.pmod/Auth.pmod/module.pmod:23:    {    params = args||({});    }       //! Sign the parameters    //!    //! @param secret    //! The API secret    string sign(string secret)    { -  return md5(sort(params)->name_value()*"" + secret); +  // We could stream all the values through MD5, but that is +  // probably not faster due to call overhead. +  return String.string2hex(Crypto.MD5.hash(sort(params)->name_value()*"" + secret));    }       //! Parameter keys    protected array(string) _indices()    {    return params->get_name();    }       //! Parameter values    protected array(string) _values()
pike.git/lib/modules/Web.pmod/Auth.pmod/module.pmod:54:    string to_unencoded_query()    {    return params->name_value()*"&";    }       //! Turns the parameters into a query string    string to_query()    {    array o = ({});    foreach (params, Param p) -  o += ({ urlencode(p->get_name()) + "=" + urlencode(p->get_value()) }); +  o += ({ Protocols.HTTP.uri_encode(p->get_name()) + "=" + +  Protocols.HTTP.uri_encode(p->get_value()) });       return o*"&";    }       //! Turns the parameters into a mapping    mapping(string:mixed) to_mapping()    {    return mkmapping(params->get_name(), params->get_value());    }   
pike.git/lib/modules/Web.pmod/Auth.pmod/module.pmod:223:       //! Returns the name and value as querystring key/value pair    string name_value()    {    return name + "=" + value;    }       //! Same as @[name_value()] except this URL encodes the value.    string name_value_encoded()    { -  return urlencode(name) + "=" + urlencode(value); +  return Protocols.HTTP.uri_encode(name) + "=" + +  Protocols.HTTP.uri_encode(value);    }       //! Comparer method. Checks if @[other] equals this object    //!    //! @param other    protected int(0..1) `==(mixed other)    {    if (!INSTANCE_OF(this, other)) return 0;    if (name == other->get_name())    return value == other->get_value();
pike.git/lib/modules/Web.pmod/Auth.pmod/module.pmod:296:       if (String.width(value) < 8) {    if (mixed e = catch(value = string_to_utf8(value))) {    werror("Warning: Auth.low_set_value(%O): string_to_utf8() failed. "    "Already encoded?\n%s\n", value, describe_error(e));    }    }    }   }    - //! Same as @[Protocols.HTTP.uri_encode()] except this turns spaces into - //! @tt{+@} instead of @tt{%20@}. - //! - //! @param s - string urlencode(string s) - { - #if constant(Protocols.HTTP.uri_encode) -  return Protocols.HTTP.uri_encode(s); - #elif constant(Protocols.HTTP.http_encode_string) -  return Protocols.HTTP.http_encode_string(s); - #endif - } -  - //! Same as @[Protocols.HTTP.uri_decode()] except this turns spaces into - //! @tt{+@} instead of @tt{%20@}. - //! - //! @param s - string urldecode(string s) - { - #if constant(Protocols.HTTP.uri_decode) -  return Protocols.HTTP.uri_decode(s); - #elif constant(Protocols.HTTP.http_decode_string) -  return Protocols.HTTP.http_decode_string(s); - #else -  return s; - #endif - } -  +    //! Turns a query string into a mapping   //!   //! @param query   mapping query_to_mapping(string query)   {    mapping m = ([]);    if (!query || !sizeof(query))    return m;       if (query[0] == '?')    query = query[1..];       foreach (query/"&", string p) {    sscanf (p, "%s=%s", string k, string v); -  m[k] = urldecode(v); +  m[k] = Protocols.HTTP.uri_decode(v); // FIXME: Shouldn't k be decoded?    }       return m;   } -  - //! MD5 routine - //! - //! @param s - string md5(string s) - { - #if constant(Crypto.MD5) -  return String.string2hex(Crypto.MD5.hash(s)); - #else -  return Crypto.string_to_hex(Crypto.md5()->update(s)->digest()); - #endif - } +