Sanitize numeric character reference #56
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
サロゲートペアなど数値文字参照としてはエラーになる値をチェックしてかわりに規定の値を返すよう修正します。
issueを立ててないので不具合の説明をここに記載します。
動作環境
JDim 0.1.0-20190309(git:e649cc2f0c)
不具合の説明
これら不具合は不正な数値文字参照が不正なutf-8文字列に変換されることで発生します。例えばサロゲートペアは数値文字参照としては不正です。(:x:
��
, 🆗🌵
-> 🌵)不正となる数値文字参照は以下のリンクを参考にしました。
Numeric character reference end state (HTML 5.3)
https://www.w3.org/TR/html53/syntax.html#numeric-character-reference-end-state
不具合の再現
未修正のJDimで以下のスレッドにアクセスします。
https://swallow.5ch.net/test/read.cgi/livejupiter/1529864683/605
https://swallow.5ch.net/test/read.cgi/livejupiter/1539076573/186
スレッド履歴が正常に読み込めなくなりますので注意してください!
https://swallow.5ch.net/test/read.cgi/livejupiter/1534241668/1
表示される実行時警告の例
テスト
ma8ma:minefieldに変換のテストケースがあります。テストの導入についてはメンテナーの方と #45 で話をしています。
今のところ未修正の点
周辺のインターフェースと合わせてコードポイントを表す型を
int
からchar32_t
に変更します。edit: スレ履歴の修復について
スレ履歴のXMLファイルに不正なutf-8文字列が混入すると自動では修復できません。手動で修復するには(a)XMLファイル(hist.xml)を編集し不正なutf-8文字列が含まれる項目を削除するか、(b)キャッシュディレクトリの初期化(削除)をしてください。