[PHP-users 12776] Re: URLエンコードされた文字列に対する処理

HOTTA Michihide php-users@php.gr.jp
Fri, 24 Jan 2003 09:54:49 +0900


堀田@諫早市です。

On Thu, 23 Jan 2003 19:11:37 +0900
Naoto Arai <arai@init.co.jp> wrote:

> フォーム:入力文字列「%24」
>  ↓
> ブラウザがURLエンコードして送信:送信文字列「%2524」
>  ↓
> PHP受け取り:RAW_DATA「%2524」
>  ↓
> グローバル変数に登録
> 恐らくここで謎な処理が発生。
> 本来なら_POSTにデコードされた「%24」が入るはずだが、
> なぜか「$」になる。(2重でデコード処理がされている?)
> 
> これが、PHP 4.2.3のバグなのか、
> ただの設定ミスで、特定の設定項目を修正すれば直るのか、
> それともConfigureしなおす必要があるのか、

手元の環境 (VineSeed) でテストしてみましたが、再現できませんでした。

$ rpm -q php
php-4.2.3-0vl3 
(この rpm パッケージは、まだ?リリースされていません)

<?php
printf("HTTP_RAW_POST_DATA=\"%s\"<br>\n", $HTTP_RAW_POST_DATA);
printf("\$a=%s<br>\n", $_POST['a']);
print <<< EOD
<form action="{$_SERVER['PHP_SELF']}" method="POST">
<input type=text name=a>
</form>
EOD;
?>

/etc/php.ini の変更部分
always_populate_raw_post_data = On

入力:$
表示:HTTP_RAW_POST_DATA="a=$"
      $a=$
入力:%24
表示:HTTP_RAW_POST_DATA="a=%2524"
      $a=%24

コンパイルオプションは、以下のようになっています。

'./configure' '--prefix=/usr' '--with-config-file-path=/etc'
'--enable-force-cgi-redirect' '--disable-debug' '--enable-pic'
'--enable-inline-optimization' '--with-apxs=/usr/sbin/apxs'
'--with-exec-dir=/usr/bin' '--with-bz2' '--with-regex=system'
'--with-gettext' '--with-gmp' '--with-gd' '--with-jpeg-dir=/usr'
'--with-png-dir=/usr' '--with-ttf' '--with-zlib' '--with-gdbm'
'--with-openssl' '--with-layout=GNU' '--enable-debugger'
'--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets'
'--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars'
'--enable-yp' '--enable-ftp' '--enable-wddx' '--without-mysql'
'--without-oracle' '--without-oci8' '--with-xml' '--with-expat-dir
usr' '--with-dom=/usr' '--enable-xslt' '--with-xslt-sablot=/usr'
'--with-dom-xslt=/usr' '--enable-iconv' '--enable-mbregex'
'--with-namazu=/usr' '--with-kakasi=/usr' '--enable-mbstring'
'--enable-mbstr-enc-trans' '--enable-versioning'
'--enable-zend-multibyte'

output_buffering = off
と
output_buffering = 4096
output_handler = mb_output_handler
mbstring.internal_encoding = EUC-JP
mbstring.http_input = auto
mbstring.http_output = SJIS
mbstring.detect_order = auto
mbstring.substitute_character = none;

のいずれにおいても、実行結果は同じでした。

OS や PHP の導入方法も明示してみられたら、何かわかるかもしれません。
-- 
HOTTA Michihide <hotta@net-newbie.com> <http://www.net-newbie.com>