Incorrect parsing of `<`angle brackets `>` as text characters
メンテナーはふだん 4 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- tooling
調査の方向性
まず preserveOrder を指定した XMLParser.parse で両方の例を再現し、次に、これらの入力から到達する parser のエントリポイントと token/name の処理を調べます。XMLBuilder.build を使って結果を検証します。無効な山括弧シーケンスがテキストのまま残り、両方のケースで有効な XML 構造が保持されれば完了です。
索引モデルが 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
I encountered a case where a text content like <...> inside a tag is incorrectly handled by the parser. The parser tries to interpret this as a tag name and breaks the tree structure. This is also applicable to the symbol \U+2026 Horizontal Ellipsis
What does <...> mean?
In text, <...> usually means something has been intentionally left out. It’s a placeholder that implies omitted words, omitted text that isn’t being shown, quoted, or repeated
However, the . symbol can indeed be used in the XML tag name, but only if it is not the starting character (NameStartChar in spec). And the ellipsis symbol seems to be invalid for NameChar. Please look at the Names and Tokens section here https://www.w3.org/TR/xml/#sec-common-syn
Also, while writing this issue, I tried using only the angle bracket characters individually and saw strange behavior. I've described this below as a second case.
I assume that the correct parser behavior if the angle brackets don't form a valid tag name according to XML specification would be to leave the angle bracket characters in the #text element or escape them in entities.
Input
Code
const xmlParser = new XMLParser({
preserveOrder: true,
allowBooleanAttributes: true,
ignoreAttributes: false,
ignoreDeclaration: true,
});
const firstCase = `<?xml version="1.0"?>
<root>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pretium odio non ex hendrerit, eu convallis sapien ultricies <...> Sed sagittis at est auctor varius. Donec sit amet nibh sodales, varius nunc eu, tempus turpis. <...> Nulla gravida erat a tortor sollicitudin laoreet.</p>
<foo></foo>
</root>`;
const secondCase = `<?xml version="1.0"?>
<root>
<p>if (1 < 3) return text;</p>
</root>
`;
const jObj = xmlParser.parse(firstCase); // check first and second case
const xmlBuilder = new XMLBuilder({
ignoreAttributes: false,
preserveOrder: true,
});
const xmlContent = xmlBuilder.build(jObj);
console.log(xmlContent);
Output
In the first case:
jObj
[
{
"root": [
{
"p": [
{
"#text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pretium odio non ex hendrerit, eu convallis sapien ultricies"
},
{
"...": [
{
"#text": "Sed sagittis at est auctor varius. Donec sit amet nibh sodales, varius nunc eu, tempus turpis."
},
{
"...": [
{
"#text": "Nulla gravida erat a tortor sollicitudin laoreet."
}
]
},
{
"foo": []
}
]
}
]
}
]
}
]
<root><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pretium odio non ex hendrerit, eu convallis sapien ultricies<...>Sed sagittis at est auctor varius. Donec sit amet nibh sodales, varius nunc eu, tempus turpis.<...>Nulla gravida erat a tortor sollicitudin laoreet.</...><foo></foo></...></p></root>
In the second case:
jObj
[
{
"root": [
{
"p": [
{
"#text": "if (1"
},
{
"": [],
":@": {
"@_3)": true,
"@_return": true,
"@_text;": true,
"@_</p": true
}
}
]
}
]
}
]
<root><p>if (1< 3) return text; </p></></p></root>
expected data
In the first case:
<root><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pretium odio non ex hendrerit, eu convallis sapien ultricies <...> Sed sagittis at est auctor varius. Donec sit amet nibh sodales, varius nunc eu, tempus turpis. <...> Nulla gravida erat a tortor sollicitudin laoreet.</p><foo></foo></root>
In the second case:
<root><p>if (1 < 3) return text;</p></root>
Would you like to work on this issue?
- Yes
- No
Bookmark this repository for further updates. Visit SoloThought to know about recent features.
- 主要言語
- JavaScript
- スター
- 3.1k
- フォーク
- 398
- 平均マージ
- 3日 9時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NaturalIntelligence/fast-xml-parser のほかの issue
-
難易度 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 日以内に返信
-
ignoreDeclaration does not ignore lower case doctype declaration再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NaturalIntelligence/fast-xml-parser#870 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
-
CLI crashes with an uncaught exception when the input file is missing対応中かも @troclaux が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
NaturalIntelligence/fast-xml-parser#894 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
Numeric character references (A, A) are not decoded unless htmlEntities is enabled対応中かも @guocn が 3 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
NaturalIntelligence/fast-xml-parser#892 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
NaturalIntelligence/fast-xml-parser の issue をすべて見る
似ている issue
-
area: apple-music area: build-release bug effort: small priority: high
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ChristianTabor/Argon#32 ·
メンテナーはふだん 1 日以内に返信
-
0️⃣ phase/new
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
Link Checker Reportオープンautomated issue report
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
good first issue tests
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信