Attribute values are not normalized as XML 1.0 section 3.3.3 requires
Maintainer thường phản hồi trong vòng 4 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript
- Lĩnh vực
- backend
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
- 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
- Ngôn ngữ chính
- JavaScript
- Star
- 3.1k
- Fork
- 410
- Merge trung bình
- 4 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NaturalIntelligence/fast-xml-parser
-
A processing instruction with no target passes validation, then the builder prints invalid XMLCó thể đã có người làm @bardrop đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NaturalIntelligence/fast-xml-parser#927 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
XMLValidator accepts double hyphens inside commentsCó thể đã có người làm @Sskift đã nhận 16 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
NaturalIntelligence/fast-xml-parser#903 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
XMLValidator accepts raw < and & in attribute valuesCó thể đã có người làm @jeromeyyy đã nhận 14 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
NaturalIntelligence/fast-xml-parser#900 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
getMetaDataSymbol() declares a boxed SymbolCó thể đã có người làm @chiragbitoni đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
NaturalIntelligence/fast-xml-parser#890 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
NaturalIntelligence/fast-xml-parser#888 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của NaturalIntelligence/fast-xml-parser
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
-
Extended search drops any query term that contains a line breakCó thể đã có người làm @goranai đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
0.3.14: pdfmake.virtualfs renamed to sharedVirtualfs without changelog entry (breaking change)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày