From ef50b52a02b418eba814928a5fd32fce1c066ea2 Mon Sep 17 00:00:00 2001 From: Mitsuru Mutaguchi Date: Wed, 19 Feb 2020 20:34:53 +0900 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E3=83=AB=E3=83=BC=E3=83=A0=E3=81=AE?= =?UTF-8?q?=E3=83=90=E3=83=83=E3=82=AF=E3=82=A2=E3=83=83=E3=83=97=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0=E6=99=82?= =?UTF-8?q?=E3=81=AB=E3=80=8CXML=E3=81=AE=E3=82=A2=E3=83=B3=E3=82=B7?= =?UTF-8?q?=E3=83=AA=E3=82=A2=E3=83=A9=E3=82=A4=E3=82=BA=E3=81=AB=E5=A4=B1?= =?UTF-8?q?=E6=95=97=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=83=AA?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=A2=E3=81=99=E3=82=8BXML=E3=82=92?= =?UTF-8?q?=E3=81=94=E7=A2=BA=E8=AA=8D=E3=81=8F=E3=81=A0=E3=81=95=E3=81=84?= =?UTF-8?q?=E3=80=8D=E3=82=A8=E3=83=A9=E3=83=BC=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit バックアップファイルに含まれる掲示板の記事データ内に [Unicode文字番号] U+0008(BackSpace), U+001D(制御文字) 等が含まれるとXMLパースでエラーになるバグを修正 --- html/maple/includes/pear/XML/Parser.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/html/maple/includes/pear/XML/Parser.php b/html/maple/includes/pear/XML/Parser.php index ef8436a..6407c8b 100644 --- a/html/maple/includes/pear/XML/Parser.php +++ b/html/maple/includes/pear/XML/Parser.php @@ -476,6 +476,20 @@ function parse() if (is_resource($this->fp)) { while ($data = fread($this->fp, 4096)) { + + // bugfix by mutaguchi@opensource-workshop.jp + // [Unicode文字番号] ''←U+0008(BackSpace), ''←U+001D(制御文字) がどういう訳かウィジウィグに含まれる事がある。 + // 見た目は空白文字だが、XMLに含まれると、parseでエラーになる。 + // また、NetCommons2のバックアップはデータをXML保存していて、リストア時に"XMLのアンシリアライズに失敗しました
リストアするXMLをご確認ください"エラーになる。 + // そのため、制御文字は取り除く。 + // + // 参考URL + // https://qiita.com/khsk/items/3c98174bc6cb9b596e61 + // + // 実装は以下と等価です。文字コード0x0~0x1fまでの制御文字を取り除きます。 + // $data = urlencode(preg_replace('/[\x0-\x1f]/', '', $data)); + $data = filter_var($data, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW); + if (!$this->_parseString($data, feof($this->fp))) { $error = &$this->raiseError(); $this->free(); @@ -687,4 +701,4 @@ function XML_Parser_Error($msgorparser = 'unknown error', $code = 0, $mode = PEA } // }}} } -?> \ No newline at end of file +?>