OSDN Git Service

FIX: 円マークをバックスラッシュに置換
authorsakamocchi <o-takashi@sakamocchi.jp>
Sat, 24 Mar 2012 01:58:21 +0000 (10:58 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Sat, 24 Mar 2012 01:58:21 +0000 (10:58 +0900)
UTF-8/Shift_JIS間の変換を繰り返したため以下が発生しました。これはその修正コミットです。

UTF-8からShift_JIS: バックスラッシュは円マーク(0x5C)として認識された
Shift_JISからUTF-8: 円マークが2バイト(0xC2A5)に変換された

背景:
UTF-8の文字集合であるUCS-2はバックスラッシュ(backslash)と円マーク(yen
sign)のそれぞれにコードポイントを割り当て、別々のキャラクターとして扱う。そのためこれらは、UTF-8において異なるバイナリーとなり、前者は0x5Cに、後者は0xC2A5に符号化される。

対してShift_JISの文字集合のひとつであるJIS X
0201(英数字と約物、片仮名を含む)はこれら2つのうち円マークしか規定していない。そのためShift_JISはバックスラッシュを扱うことができず、円マークを0x5Cに符号化する。

なおISO
8859シリーズはいずれも、バックスラッシュは符号化対象文字列に持つものの、円マークは以下の4つしか持たない。この場合、バックスラッシュは0x5Cに、円マークは0xA5に符号化される。
 ISO-8859-1
 ISO-8859-8
 ISO-8859-9
 ISO-8859-15

install/index.php

index b5c4291..37a364b 100644 (file)
@@ -243,7 +243,7 @@ function show_header()
                                                {\r
                                                        echo ' class="gry"';\r
                                                }\r
-                                               echo '>&nbsp; &gt; &nbsp;', _STEP3, "</li>¥n";\r
+                                               echo '>&nbsp; &gt; &nbsp;', _STEP3, "</li>\n";\r
                                        }\r
                                        if ( in_array($param->state, array('mysql', 'weblog', 'detail')) )\r
                                        {\r
@@ -290,7 +290,7 @@ function show_select_locale_form()
        $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);\r
        foreach ($languages as $language)\r
        {\r
-               $language = preg_replace('#([¥w]+).*#', '$1', $language);\r
+               $language = preg_replace('#([\w]+).*#', '$1', $language);\r
                break;\r
        }\r
 \r
@@ -310,12 +310,12 @@ function show_select_locale_form()
 <?php\r
        foreach ( $locales as $locale )\r
        {\r
-               echo "<option value=¥"$locale[0]¥"";\r
+               echo "<option value=\"$locale[0]\"";\r
                if ( i18n::strpos($locale[0], $language) === 0 )\r
                {\r
                        echo ' selected';\r
                }\r
-               echo ">$locale[1]</option>¥n";\r
+               echo ">$locale[1]</option>\n";\r
        }\r
 ?>\r
                                        </select>\r
@@ -369,7 +369,7 @@ function show_database_setting_form($isPostback)
                {\r
                        foreach ( $errors as $error )\r
                        {\r
-                               echo '<span class="err">', $error, "</span>¥n";\r
+                               echo '<span class="err">', $error, "</span>\n";\r
                        }\r
                }\r
        }\r
@@ -431,7 +431,7 @@ function show_blog_setting_form($isPostback)
                {\r
                        foreach ( $errors as $error )\r
                        {\r
-                               echo '<span class="err">', $error, "</span>¥n";\r
+                               echo '<span class="err">', $error, "</span>\n";\r
                        }\r
                }\r
        }\r
@@ -460,7 +460,7 @@ function show_blog_setting_form($isPostback)
                {\r
                        foreach ( $errors as $error )\r
                        {\r
-                               echo '<span class="err">', $error, "</span>¥n";\r
+                               echo '<span class="err">', $error, "</span>\n";\r
                        }\r
                }\r
        }\r
@@ -513,7 +513,7 @@ function show_detail_setting_form($isPostback)
 <?php\r
        if ( $isPostback && !$param->check_all_parameters() )\r
        {\r
-               echo '<span class="err">', _ERROR26, "</span>¥n";\r
+               echo '<span class="err">', _ERROR26, "</span>\n";\r
        }\r
 ?>\r
                        </p>\r
@@ -541,7 +541,7 @@ function show_detail_setting_form($isPostback)
                {\r
                        foreach ( $errors as $error )\r
                        {\r
-                               echo '<span class="err">', $error, "</span>¥n";\r
+                               echo '<span class="err">', $error, "</span>\n";\r
                        }\r
                }\r
        }\r
@@ -580,7 +580,7 @@ function show_detail_setting_form($isPostback)
                {\r
                        foreach ( $errors as $error )\r
                        {\r
-                               echo '<span class="err">', $error, "</span>¥n";\r
+                               echo '<span class="err">', $error, "</span>\n";\r
                        }\r
                }\r
                $errors = $param->check_path_parameters();\r
@@ -588,7 +588,7 @@ function show_detail_setting_form($isPostback)
                {\r
                        foreach ( $errors as $error )\r
                        {\r
-                               echo '<span class="err">', $error, "</span>¥n";\r
+                               echo '<span class="err">', $error, "</span>\n";\r
                        }\r
                }\r
        }\r
@@ -647,7 +647,7 @@ function show_detail_setting_form($isPostback)
                {\r
                        foreach ( $errors as $error )\r
                        {\r
-                               echo '<span class="err">', $error, "</span>¥n";\r
+                               echo '<span class="err">', $error, "</span>\n";\r
                        }\r
                }\r
        }\r
@@ -687,7 +687,7 @@ function show_detail_setting_form($isPostback)
                {\r
                        foreach ( $errors as $error )\r
                        {\r
-                               echo '<span class="err">', $error, "</span>¥n";\r
+                               echo '<span class="err">', $error, "</span>\n";\r
                        }\r
                }\r
        }\r
@@ -733,7 +733,7 @@ function show_install_complete_form()
                echo _ERROR27;\r
                foreach ( $errors as $error )\r
                {\r
-                       echo '<span class="err">', $error, "</span>¥n";\r
+                       echo '<span class="err">', $error, "</span>\n";\r
                }\r
        }\r
        else\r
@@ -900,11 +900,11 @@ function do_install()
        $queries = fread($fd, filesize($filename) );\r
        fclose($fd);\r
 \r
-       $queries = preg_split('#(;¥n|;¥r)#', $queries);\r
+       $queries = preg_split('#(;\n|;\r)#', $queries);\r
 \r
        foreach ( $queries as $query )\r
        {\r
-               if ( preg_match('/¥w+/', $query) )\r
+               if ( preg_match('/\w+/', $query) )\r
                {\r
                        if ( $MYSQL_PREFIX )\r
                        {\r
@@ -1020,36 +1020,36 @@ function do_install()
        /*\r
         * 8. Write config file ourselves (if possible)\r
         */\r
-       $config_data = '<' . '?php' . "¥n";\r
-       $config_data .= "// mySQL connection information¥n";\r
-       $config_data .= "¥$MYSQL_HOST = '" . $MYSQL_HOST . "';¥n";\r
-       $config_data .= "¥$MYSQL_USER = '" . $MYSQL_USER . "';¥n";\r
-       $config_data .= "¥$MYSQL_PASSWORD = '" . $MYSQL_PASSWORD . "';¥n";\r
-       $config_data .= "¥$MYSQL_DATABASE = '" . $MYSQL_DATABASE . "';¥n";\r
-       $config_data .= "¥$MYSQL_PREFIX = '" . $MYSQL_PREFIX . "';¥n";\r
-       $config_data .= "// new in 3.50. first element is db handler, the second is the db driver used by the handler¥n";\r
-       $config_data .= "// default is ¥$MYSQL_HANDLER = array('mysql','mysql');¥n";\r
-       $config_data .= "//¥$MYSQL_HANDLER = array('mysql','mysql');¥n";\r
-       $config_data .= "//¥$MYSQL_HANDLER = array('pdo','mysql');¥n";\r
-       $config_data .= "¥$MYSQL_HANDLER = array('".$MYSQL_HANDLER[0]."','".$MYSQL_HANDLER[1]."');¥n";\r
-       $config_data .= "¥n";\r
-       $config_data .= "// main nucleus directory¥n";\r
-       $config_data .= "¥$DIR_NUCLEUS = '" . $DIR_NUCLEUS . "';¥n";\r
-       $config_data .= "¥n";\r
-       $config_data .= "// path to media dir¥n";\r
-       $config_data .= "¥$DIR_MEDIA = '" . $DIR_MEDIA . "';¥n";\r
-       $config_data .= "¥n";\r
-       $config_data .= "// extra skin files for imported skins¥n";\r
-       $config_data .= "¥$DIR_SKINS = '" . $DIR_SKINS . "';¥n";\r
-       $config_data .= "¥n";\r
-       $config_data .= "// these dirs are normally sub dirs of the nucleus dir, but ¥n";\r
-       $config_data .= "// you can redefine them if you wish¥n";\r
-       $config_data .= "¥$DIR_PLUGINS = ¥$DIR_NUCLEUS . 'plugins/';¥n";\r
-       $config_data .= "¥$DIR_LOCALES = ¥$DIR_NUCLEUS . 'locales/';¥n";\r
-       $config_data .= "¥$DIR_LIBS = ¥$DIR_NUCLEUS . 'libs/';¥n";\r
-       $config_data .= "¥n";\r
-       $config_data .= "// include libs¥n";\r
-       $config_data .= "include(¥$DIR_LIBS.'globalfunctions.php');¥n";\r
+       $config_data = '<' . '?php' . "\n";\r
+       $config_data .= "// mySQL connection information\n";\r
+       $config_data .= "\$MYSQL_HOST = '" . $MYSQL_HOST . "';\n";\r
+       $config_data .= "\$MYSQL_USER = '" . $MYSQL_USER . "';\n";\r
+       $config_data .= "\$MYSQL_PASSWORD = '" . $MYSQL_PASSWORD . "';\n";\r
+       $config_data .= "\$MYSQL_DATABASE = '" . $MYSQL_DATABASE . "';\n";\r
+       $config_data .= "\$MYSQL_PREFIX = '" . $MYSQL_PREFIX . "';\n";\r
+       $config_data .= "// new in 3.50. first element is db handler, the second is the db driver used by the handler\n";\r
+       $config_data .= "// default is \$MYSQL_HANDLER = array('mysql','mysql');\n";\r
+       $config_data .= "//\$MYSQL_HANDLER = array('mysql','mysql');\n";\r
+       $config_data .= "//\$MYSQL_HANDLER = array('pdo','mysql');\n";\r
+       $config_data .= "\$MYSQL_HANDLER = array('".$MYSQL_HANDLER[0]."','".$MYSQL_HANDLER[1]."');\n";\r
+       $config_data .= "\n";\r
+       $config_data .= "// main nucleus directory\n";\r
+       $config_data .= "\$DIR_NUCLEUS = '" . $DIR_NUCLEUS . "';\n";\r
+       $config_data .= "\n";\r
+       $config_data .= "// path to media dir\n";\r
+       $config_data .= "\$DIR_MEDIA = '" . $DIR_MEDIA . "';\n";\r
+       $config_data .= "\n";\r
+       $config_data .= "// extra skin files for imported skins\n";\r
+       $config_data .= "\$DIR_SKINS = '" . $DIR_SKINS . "';\n";\r
+       $config_data .= "\n";\r
+       $config_data .= "// these dirs are normally sub dirs of the nucleus dir, but \n";\r
+       $config_data .= "// you can redefine them if you wish\n";\r
+       $config_data .= "\$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";\r
+       $config_data .= "\$DIR_LOCALES = \$DIR_NUCLEUS . 'locales/';\n";\r
+       $config_data .= "\$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";\r
+       $config_data .= "\n";\r
+       $config_data .= "// include libs\n";\r
+       $config_data .= "include(\$DIR_LIBS.'globalfunctions.php');\n";\r
        $config_data .= "?" . ">";\r
 \r
        $result = false;\r
@@ -1123,7 +1123,7 @@ function getMySqlVersion()
        }\r
        else\r
        {\r
-               $result = @sql_query('SHOW VARIABLES LIKE ¥'version¥'', $conn);\r
+               $result = @sql_query('SHOW VARIABLES LIKE \'version\'', $conn);\r
 \r
                if ( $result != FALSE && @sql_num_rows($result) > 0 )\r
                {\r
@@ -1134,7 +1134,7 @@ function getMySqlVersion()
                {\r
                        //$output = shell_exec('mysql -V');\r
                        $output = ( function_exists('shell_exec') ) ? @shell_exec('mysql -V') : '0.0.0';\r
-                       preg_match('@[0-9]+¥.[0-9]+¥.[0-9]+@', $output, $version);\r
+                       preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);\r
                        $match = i18n::explode('.', $version[0]);\r
 \r
                        if ( $match[0] == '' )\r
@@ -1336,7 +1336,7 @@ function do_check_files()
 \r
        if ( count($missingfiles) > 0 )\r
        {\r
-               exit(implode( "¥n", $missingfiles));\r
+               exit(implode( "\n", $missingfiles));\r
        }\r
 }\r
 \r
@@ -1497,7 +1497,7 @@ class PARAM_MANAGER
                }\r
                \r
                if ( $this->mysql_user != ''\r
-                       && !preg_match('/^[a-z0-9_¥-]+$/i', $this->mysql_user) )\r
+                       && !preg_match('/^[a-z0-9_\-]+$/i', $this->mysql_user) )\r
                {\r
                        $errors[] = sprintf(_ERROR2, _DB_FIELD2);\r
                }\r
@@ -1513,7 +1513,7 @@ class PARAM_MANAGER
                }\r
 \r
                if ( $this->mysql_database != ''\r
-                       && !preg_match('/^[a-z0-9_¥-]+$/i', $this->mysql_database) )\r
+                       && !preg_match('/^[a-z0-9_\-]+$/i', $this->mysql_database) )\r
                {\r
                        $errors[] = sprintf(_ERROR2, _DB_FIELD4);\r
                }\r
@@ -1571,7 +1571,7 @@ class PARAM_MANAGER
                        $this->user_password = '';\r
                }\r
 \r
-               if ( !preg_match("/^[a-z0-9¥._+¥-]+@[a-z0-9¥._¥-]+¥.[a-z]{2,6}$/i", $this->user_email) )\r
+               if ( !preg_match("/^[a-z0-9\._+\-]+@[a-z0-9\._\-]+\.[a-z]{2,6}$/i", $this->user_email) )\r
                {\r
                        $errors[] = _ERROR7;\r
                }\r