Skip to content

Commit a33f030

Browse files
Fix xmlns without prefix being interpreted as property attribute
1 parent 8060f33 commit a33f030

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/RdfXmlParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ while ${attribute.value} and ${activeSubjectValue} where found.`);
517517
// Interpret attributes at this point as properties via implicit blank nodes on the property,
518518
// but we ignore attributes that have no prefix or known expanded URI
519519
if (propertyAttribute.prefix !== 'xml' && propertyAttribute.prefix !== 'xmlns'
520+
&& (propertyAttribute.prefix !== '' || propertyAttribute.local !== 'xmlns')
520521
&& propertyAttribute.uri) {
521522
if (parseType || activeTag.datatype) {
522523
throw this.newParseError(`Found illegal rdf:* properties on property element with attribute: ${

test/RdfXmlParser-test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,22 @@ abc`)).rejects.toBeTruthy();
930930
]);
931931
});
932932

933+
934+
it('declaration of the namespace on the element', async () => {
935+
return expect(await parse(parser, `<?xml version="1.0"?>
936+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
937+
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar">
938+
<title xmlns="http://purl.org/dc/terms/" xml:lang="en">RDF1.1 XML Syntax</title>
939+
</rdf:Description>
940+
</rdf:RDF>`))
941+
.toBeRdfIsomorphic([
942+
quad('http://www.w3.org/TR/rdf-syntax-grammar',
943+
'http://purl.org/dc/terms/title', '"RDF1.1 XML Syntax"@en'),
944+
]);
945+
});
946+
947+
948+
933949
it('DOCTYPE and ENTITY\'s', async () => {
934950
return expect(await parse(parser, `<!DOCTYPE rdf:RDF
935951
[<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">

0 commit comments

Comments
 (0)