Attribute values are not normalized as XML 1.0 section 3.3.3 requires
メンテナーはふだん 4 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- backend
調査の方向性
Start by reading the XMLParser attribute handling and entity decoding paths, then check issue #330 for the existing behavior around preserving newlines. The report says normalization must happen before entity and character references are decoded and may need to be opt-in. Done means literal attribute whitespace normalizes to spaces while a decoded character reference preserves its newline; add coverage for both forms.
索引モデルが issue の本文から書いたものです。
説明
- Are you running the latest version?
- Have you included sample input, output, error, and expected output?
- Have you checked if you are using correct configuration?
- Did you try online tool?
- Have you checked the docs for helpful APIs and examples?
Description
XMLParser does not apply the attribute-value normalization of XML 1.0, section 3.3.3. A literal line feed or tab in an attribute value is kept as is, but the spec says that a conforming processor replaces each literal whitespace character (#x20, #xD, #xA, #x9) with a space, and only a character reference such as adds the character itself.
Because the parser keeps the literal characters, the two forms cannot be told apart once character references are decoded (htmlEntities: true or an entityDecoder): a="x y" and an attribute with a real line break both become "x\ny". An application that writes the value back has no way to know whether the source meant a space or a line feed.
I found no option for this. #330 asked for the opposite (keeping newlines) in 2021, and that is the current behavior, so a change would probably have to be opt-in, for example an option such as normalizeAttributeValues: true. The normalization would have to happen before entity and character references are decoded.
Input
<r a="x
y"/>
Code
import { XMLParser } from "fast-xml-parser"; // 5.12.0
const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: "" });
parser.parse('<r a="x\ny"/>').r.a; // "x\ny"
parser.parse('<r a="x\ty"/>').r.a; // "x\ty"
parser.parse('<r a="x\r\ny"/>').r.a; // "x\ny"
parser.parse('<r a="x y"/>').r.a; // "x y" (numeric references are not decoded by default, see #892)
Output
"x\ny"
"x\ty"
"x\ny"
expected data
"x y"
"x y"
"x y"
"x\ny" // for a="x y", once numeric references are decoded
For comparison, @xmldom/xmldom returns "x y" for the first two inputs and "x\ny" for a="x y".
Would you like to work on this issue?
- Yes
- No
- 主要言語
- JavaScript
- スター
- 3.1k
- フォーク
- 410
- 平均マージ
- 4日 15時間
- マージ済み PR(30日)
- 8
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NaturalIntelligence/fast-xml-parser のほかの issue
-
A processing instruction with no target passes validation, then the builder prints invalid XML対応中かも @bardrop が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NaturalIntelligence/fast-xml-parser#927 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
-
XMLValidator accepts double hyphens inside comments対応中かも @Sskift が 16 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
NaturalIntelligence/fast-xml-parser#903 · コメント 3 件 ·
メンテナーはふだん 4 日以内に返信
-
XMLValidator accepts raw < and & in attribute values対応中かも @jeromeyyy が 14 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NaturalIntelligence/fast-xml-parser#900 · コメント 3 件 ·
メンテナーはふだん 4 日以内に返信
-
getMetaDataSymbol() declares a boxed Symbol対応中かも @chiragbitoni が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
NaturalIntelligence/fast-xml-parser#890 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
NaturalIntelligence/fast-xml-parser#888 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
NaturalIntelligence/fast-xml-parser の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
-
Extended search drops any query term that contains a line break対応中かも @goranai が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信