_oauthEscape encoding "~" #16

Closed
samharnack opened this Issue Jul 1, 2012 · 2 comments

Comments

Projects
None yet
2 participants

Just spent some time trying to get LinkedIn to work, they like using ~ in their urls.

private static function _oauthEscape($string) 
    {
        if ($string === 0) { return 0; }
        if ($string == '0') { return '0'; }
        if (strlen($string) == 0) { return ''; }
        if (is_array($string)) {
            throw new OAuthSimpleException('Array passed to _oauthEscape');
        }
        $string = rawurlencode($string);

        //FIX: rawurlencode of ~
        $string = str_replace('%7E','~', $string);

        $string = str_replace('+','%20', $string);
        $string = str_replace('!','%21', $string);
        $string = str_replace('*','%2A', $string);
        $string = str_replace('\'','%27', $string);
        $string = str_replace('(','%28', $string);
        $string = str_replace(')','%29', $string);      

        return $string;
    }
Owner

jrconlin commented Jul 2, 2012

Argh. I thought that was originally covered by rawurlencode.

Thanks, I'll try to get the patch in, or you can submit a pull and I'll
approve it.

On 7/1/2012 4:15 PM, samharnack wrote:

Just spent some time trying to get LinkedIn to work, they like using ~ in their urls.

private static function _oauthEscape($string)
     {
         if ($string === 0) { return 0; }
      if ($string == '0') { return '0'; }
         if (strlen($string) == 0) { return ''; }
         if (is_array($string)) {
             throw new OAuthSimpleException('Array passed to _oauthEscape');
      }
         $string = rawurlencode($string);

         //FIX: rawurlencode of ~
          $string = str_replace('%7E','~', $string);

          $string = str_replace('+','%20', $string);
          $string = str_replace('!','%21', $string);
         $string = str_replace('*','%2A', $string);
         $string = str_replace('\'','%27', $string);
         $string = str_replace('(','%28', $string);
         $string = str_replace(')','%29', $string);       

         return $string;
     }

Reply to this email directly or view it on GitHub:
#16

Owner

jrconlin commented Sep 30, 2014

resolved:fixed.

jrconlin closed this Sep 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment