Changeset 22186


Ignore:
Timestamp:
2012/12/28 22:39:21 (11 years ago)
Author:
Seasoft
Message:

#1988 (国際化テンプレート:エスケープ処理) 現状コミット。

  • ja.po は、data/Smarty/templates/admin/ownersstore/plugin.tpl に対応する部分のみ、局所的に変更しています。
    • data/Smarty/templates/admin/ownersstore/plugin.tpl にコメントを記載している「案1」及び「案2」の方向性については協議中。
  • 上記以外では、po ファイルの改修が終わるまで、HTML エスケープが過剰に行なわれます。(主に、入力必須マークの出力が正しく行なわれないといった状況が生じます。)
Location:
branches/version-2_12-multilang/data
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-multilang/data/Smarty/templates/admin/ownersstore/plugin.tpl

    r22130 r22186  
    3434 
    3535            if(mode === 'disable') { 
    36                 result = window.confirm('<!--{t string="tpl_458"}-->'); 
     36                result = window.confirm('<!--{t string="tpl_458" escape="j"}-->'); 
    3737                if(result === false) { 
    3838                    $(event.target).attr("checked", "checked"); 
    3939                } 
    4040            } else if(mode === 'enable') { 
    41                 result = window.confirm('<!--{t string="tpl_459"}-->'); 
     41                result = window.confirm('<!--{t string="tpl_459" escape="j"}-->'); 
    4242                if(result === false) { 
    4343                    $(event.target).attr("checked", ""); 
     
    5555     */ 
    5656    function remoteException(XMLHttpRequest, textStatus, errorThrown) { 
    57         alert('<!--{t string="tpl_460"}-->'); 
     57        alert('<!--{t string="tpl_460" escape="j"}-->'); 
    5858    } 
    5959 
     
    8080     */ 
    8181    function install() { 
    82         if (window.confirm('<!--{t string="tpl_461" kaigyo_escape=true}-->')){ 
     82        if (window.confirm('<!--{t string="tpl_461" escape="j"}-->')){ 
    8383            fnModeSubmit('install','',''); 
    8484        } 
     
    8989     */ 
    9090    function uninstall(plugin_id, plugin_code) { 
    91         if (window.confirm('<!--{t string="tpl_462"}-->')){ 
     91        if (window.confirm('<!--{t string="tpl_462" escape="j"}-->')){ 
    9292            fnSetFormValue('plugin_id', plugin_id); 
    9393            fnModeSubmit('uninstall', 'plugin_code', plugin_code); 
     
    9999     */ 
    100100    function update(plugin_id, plugin_code) { 
    101         if (window.confirm('<!--{t string="tpl_463"}-->')){ 
     101        if (window.confirm('<!--{t string="tpl_463" escape="j"}-->')){ 
    102102            removeUpdateFile('update_file_' + plugin_id); 
    103103            fnSetFormValue('plugin_id', plugin_id); 
     
    128128    <h2><!--{t string="tpl_464"}--></h2> 
    129129    <table class="form"> 
     130        <!--{* 案1 *}--> 
    130131        <tr> 
    131             <th><!--{t string="tpl_465"}--></th> 
     132            <th><!--{t string="tpl_465"}--> <!--{t string="<require>"}--></th> 
     133            <td> 
     134                <!--{assign var=key value="plugin_file"}--> 
     135                <span class="attention"><!--{$arrErr[$key]}--></span> 
     136                <input type="file" name="<!--{ $key }-->" class="box45" size="43"  style="<!--{$arrErr[$key]|sfGetErrorColor}--> <!--{if $arrErr[$key]}--> background-color:<!--{$smarty.const.ERR_COLOR|h}--><!--{/if}-->"> 
     137                <a class="btn-action" href="javascript:;" onclick="install(); return false;"><span class="btn-next"><!--{t string="tpl_466"}--></span></a> 
     138            </td> 
     139        </tr> 
     140        <!--{* 案2 *}--> 
     141        <tr> 
     142            <th><!--{t string="tpl_465"}--> <span class='attention'><!--{t string="require_mark"}--></span></th> 
    132143            <td> 
    133144                <!--{assign var=key value="plugin_file"}--> 
  • branches/version-2_12-multilang/data/class/helper/SC_Helper_Locale.php

    r22099 r22186  
    7070        } 
    7171 
     72        $return = $string; 
    7273        // Get string list of specified language. 
    73         if ($lang_code == 'en') { 
    74             return $string; 
    75         } else { 
     74        if ($lang_code != 'en') { 
    7675            $translations = SC_Helper_Locale_Ex::$_instance->get_translations($lang_code, $device_type_id); 
    7776            // Whether a string which corresponding with alias is exist. 
    78             if (isset($translations[$string])) { 
    79                 return $translations[$string]; 
    80             } 
    81             else { 
    82                 return $string; 
    83             } 
    84         } 
     77            if (isset($translations[$return])) { 
     78                $return = $translations[$return]; 
     79            } 
     80        } 
     81 
     82        $esc_types = $options['escape']; 
     83        if (is_null($esc_types) && $string[0] !== '<') { 
     84            $esc_types = 'h'; 
     85        } 
     86        foreach (explode(',', $esc_types) as $esc_type) { 
     87            switch ($esc_type) { 
     88                case 'h': 
     89                case 'html': 
     90                    $return = htmlspecialchars($return, ENT_QUOTES); 
     91                    break; 
     92 
     93                case 'j': 
     94                case 'javascript': 
     95                    // escape quotes and backslashes, newlines, etc. 
     96                    $return = strtr($return, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/')); 
     97                    break; 
     98 
     99                case 'nl2br': 
     100                    $return = nl2br($return, true); 
     101                    break; 
     102 
     103                case '': 
     104                case 'none': 
     105                    break; 
     106 
     107                case 'htmlall': 
     108                    $return = htmlentities($return, ENT_QUOTES); 
     109                    break; 
     110 
     111                case 'u': 
     112                case 'url': 
     113                    $return = rawurlencode($return); 
     114                    break; 
     115 
     116                case 'urlpathinfo': 
     117                    $return = str_replace('%2F','/',rawurlencode($return)); 
     118                    break; 
     119 
     120                case 'quotes': 
     121                    // escape unescaped single quotes 
     122                    $return = preg_replace("%(?<!\\\\)'%", "\\'", $return); 
     123                    break; 
     124 
     125                case 'hex': 
     126                    // escape every character into hex 
     127                    $text = ''; 
     128                    for ($x=0; $x < strlen($return); $x++) { 
     129                        $text .= '%' . bin2hex($return[$x]); 
     130                    } 
     131                    $return = $text; 
     132                    break; 
     133 
     134                case 'hexentity': 
     135                    $text = ''; 
     136                    for ($x=0; $x < strlen($return); $x++) { 
     137                        $text .= '&#x' . bin2hex($return[$x]) . ';'; 
     138                    } 
     139                    $return = $text; 
     140                    break; 
     141 
     142                case 'decentity': 
     143                    $text = ''; 
     144                    for ($x=0; $x < strlen($return); $x++) { 
     145                        $text .= '&#' . ord($return[$x]) . ';'; 
     146                    } 
     147                    $return = $text; 
     148                    break; 
     149 
     150                case 'mail': 
     151                    // safe way to display e-mail address on a web page 
     152                    $return = str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '), $return); 
     153                    break; 
     154 
     155                case 'nonstd': 
     156                   // escape non-standard chars, such as ms document quotes 
     157                   $_res = ''; 
     158                   for($_i = 0, $_len = strlen($return); $_i < $_len; $_i++) { 
     159                       $_ord = ord(substr($return, $_i, 1)); 
     160                       // non-standard char, escape it 
     161                       if($_ord >= 126){ 
     162                           $_res .= '&#' . $_ord . ';'; 
     163                       } 
     164                       else { 
     165                           $_res .= substr($return, $_i, 1); 
     166                       } 
     167                   } 
     168                   $return = $_res; 
     169                    break; 
     170 
     171                default: 
     172                    trigger_error('unknown escape type. ' . var_export(func_get_args(), true), E_USER_WARNING); 
     173                    break; 
     174            } 
     175        } 
     176 
     177        return $return; 
    85178    } 
    86179 
  • branches/version-2_12-multilang/data/locales/ja.po

    r22173 r22186  
    33"Project-Id-Version: EC-CUBE Core\n" 
    44"POT-Creation-Date: 2012-05-07 13T_39+0900\n" 
    5 "PO-Revision-Date: 2012-12-27 14:19+0900\n" 
     5"PO-Revision-Date: 2012-12-28 22:26+0900\n" 
    66"Last-Translator: MATSUDA Terutaka <matsudaterutaka@gmail.com>\n" 
    77"Language-Team: \n" 
     
    35323532msgid "SC_Utils_001" 
    35333533msgstr "" 
    3534 "&gt;&gt; /install/T_FIELD は、インストール完了後にファイルを削除してくださ" 
    3535 "い。" 
     3534">> /install/T_FIELD は、インストール完了後にファイルを削除してください。" 
    35363535 
    35373536msgid "SC_Utils_002" 
     
    50245023msgid "tpl_462" 
    50255024msgstr "" 
    5026 "一度削除したデータは元に戻せません。\\nプラグインを削除しても宜しいですか?" 
     5025"一度削除したデータは元に戻せません。\n" 
     5026"プラグインを削除しても宜しいですか?" 
    50275027 
    50285028msgid "tpl_463" 
     
    50335033 
    50345034msgid "tpl_465" 
    5035 msgstr "プラグイン<span class='attention'> *</span>" 
     5035msgstr "プラグイン" 
    50365036 
    50375037msgid "tpl_466" 
     
    58785878msgid "pt_suffix" 
    58795879msgstr "pt" 
     5880 
     5881msgid "<require>" 
     5882msgstr "<span class='attention'>*</span>" 
     5883 
     5884msgid "require_mark" 
     5885msgstr "*" 
  • branches/version-2_12-multilang/data/smarty_extends/function.t.php

    r22099 r22186  
    4545        unset($params['device_type_id']); 
    4646    } 
     47    // エスケープの指定がある場合、オプションに移す 
     48    if (isset($params['escape'])) { 
     49        $options['escape'] = $params['escape']; 
     50        unset($params['escape']); 
     51    } 
    4752 
    4853    return t($string, $params, $options); 
Note: See TracChangeset for help on using the changeset viewer.