Changeset 90


Ignore:
Timestamp:
03/23/2009 08:46:31 PM (3 years ago)
Author:
amir
Message:

Fix for the base 64 encoding to be uri friendly , i.e. avoid +=/ .

Location:
trunk/WordPress/plugin/transposh
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WordPress/plugin/transposh/parser.php

    r84 r90  
    787787                //Use base64 encoding to make that when the page is translated (i.e. update_translation) we 
    788788        //get back exactlly the same string without having the client decode/encode it in anyway. 
    789         $token = "token=\"" . base64_encode($original_text) . "\""; 
     789        $token = "token=\"" . base64_url_encode($original_text) . "\""; 
    790790 
    791791        if($translated_text == NULL) 
     
    876876 
    877877} 
     878 
     879/** 
     880 * Encode a string as base 64 while avoiding characters which should be avoided  
     881 * in uri, e.g. + is interpeted as a space. 
     882 */ 
     883function base64_url_encode($input) { 
     884    return strtr(base64_encode($input), '+/=', '-_,'); 
     885} 
     886 
     887/** 
     888 * Decode a string previously decoded with base64_url_encode 
     889 */ 
     890function base64_url_decode($input) { 
     891    return base64_decode(strtr($input, '-_,', '+/=')); 
     892} 
     893 
    878894?> 
  • trunk/WordPress/plugin/transposh/transposh.php

    r89 r90  
    415415 
    416416    $ref=getenv('HTTP_REFERER'); 
    417     $original =  base64_decode($_POST['token'], TRUE); 
     417    $original =  base64_url_decode($_POST['token']); 
    418418    $translation = $_POST['translation']; 
    419419    $lang = $_POST['lang']; 
Note: See TracChangeset for help on using the changeset viewer.