viatoro / oauth

Automatically exported from code.google.com/p/oauth
0 stars 0 forks source link

In C# Code the URL Parameters and their values must be encoded before generating the hash-code #243

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Just copy/paste the code :)

Please change the function:

    /// <summary>
    /// Normalizes the request parameters according to the spec
    /// </summary>
    /// <param name="parameters">The list of parameters already sorted</param>
    /// <returns>a string representing the normalized parameters</returns>
    protected string NormalizeRequestParameters(IList<QueryParameter> parameters)
    {
      StringBuilder sb = new StringBuilder();
      QueryParameter p = null;
      for (int i = 0; i < parameters.Count; i++)
      {
        p = parameters[i];
        sb.AppendFormat("{0}={1}", p.Name, p.Value);

        if (i < parameters.Count - 1)
        {
          sb.Append("&");
        }
      }

      return sb.ToString();
    }

To this one:

    /// <summary>
    /// Normalizes the request parameters according to the spec
    /// </summary>
    /// <param name="parameters">The list of parameters already sorted</param>
    /// <returns>a string representing the normalized parameters</returns>
    protected string NormalizeRequestParameters(IList<QueryParameter> parameters)
    {
      StringBuilder sb = new StringBuilder();
      QueryParameter p = null;
      for (int i = 0; i < parameters.Count; i++)
      {
        p = parameters[i];
        sb.AppendFormat("{0}={1}", UrlEncode(p.Name), UrlEncode(p.Value));

        if (i < parameters.Count - 1)
        {
          sb.Append("&");
        }
      }

      return sb.ToString();
    }

Original issue reported on code.google.com by musta...@gmail.com on 17 Dec 2013 at 3:29