Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4a834c9

Browse files
committedJun 25, 2025·
Add test for illegal its:dir value
1 parent 8e48c3a commit 4a834c9

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
 

‎lib/RdfXmlParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ while ${attribute.value} and ${activeSubjectValue} where found.`);
676676
throw this.newParseError(`Expected exactly one triple term in rdf:parseType="Triple" but got ${poppedTag.childrenTripleTerms.length}`);
677677
}
678678
for (const tripleTerm of poppedTag.childrenTripleTerms) {
679-
this.emitTriple(poppedTag.subject, poppedTag.predicate, tripleTerm, null, parentTag?.childrenTripleTerms);
679+
this.emitTriple(poppedTag.subject, poppedTag.predicate, tripleTerm, null, parentTag.childrenTripleTerms);
680680
}
681681
poppedTag.predicateEmitted = true;
682682
}
@@ -715,7 +715,7 @@ while ${attribute.value} and ${activeSubjectValue} where found.`);
715715
private setDirection(activeTag: IActiveTag, value?: string) {
716716
if (value) {
717717
if (value !== 'ltr' && value !== 'rtl') {
718-
throw this.newParseError(`Base directions must either be 'ltr' or 'rtl', while ${value} was found.`);
718+
throw this.newParseError(`Base directions must either be 'ltr' or 'rtl', while '${value}' was found.`);
719719
}
720720
activeTag.direction = value;
721721
} else {

‎test/RdfXmlParser-test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,19 @@ abc`)).rejects.toBeTruthy();
846846
new Error('5:13: unbound namespace prefix: "ex".'));
847847
});
848848

849+
it('on illegal its:dir values', async () => {
850+
return expect(parse(parser, `<?xml version="1.0"?>
851+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
852+
xmlns:dc="http://purl.org/dc/elements/1.1/"
853+
xmlns:ex="http://example.org/stuff/1.0/"
854+
xmlns:its="http://www.w3.org/2005/11/its">
855+
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar" xml:lang="en-us" its:dir="abc">
856+
<dc:title>RDF 1.1 XML Syntax</dc:title>
857+
</rdf:Description>
858+
</rdf:RDF>`)).rejects.toEqual(
859+
new Error('Base directions must either be \'ltr\' or \'rtl\', while \'abc\' was found.'));
860+
});
861+
849862
it('on rdf:parseType="Triple" with missing predicate in triple term', async () => {
850863
return expect(parse(parser, `<?xml version="1.0"?>
851864
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

0 commit comments

Comments
 (0)
Please sign in to comment.