Bug 50498 - [PATCH] Reject top-level typed nodes in XMP
Summary: [PATCH] Reject top-level typed nodes in XMP
Status: NEEDINFO
Alias: None
Product: XMLGraphicsCommons - Now in Jira
Classification: Unclassified
Component: xmp (show other bugs)
Version: 1.4
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: --
Assignee: XML Graphics Project Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-19 16:58 UTC by brian m. carlson
Modified: 2012-04-10 19:31 UTC (History)
0 users



Attachments
Patch to reject top-level typed nodes (1.07 KB, patch)
2010-12-19 16:59 UTC, brian m. carlson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description brian m. carlson 2010-12-19 16:58:38 UTC
(This is Debian bug #605940.)

XMP permits only rdf:Description elements directly under rdf:RDF. libxmlgraphics-commons-java does not enforce this and produces some odd results in the XMP (it looks like it treats top-level non-Description elements as properties).  These top-level non-rdf:Description elements should either be rejected or turned into rdf:Description elements with rdf:type properties.
Comment 1 brian m. carlson 2010-12-19 16:59:42 UTC
Created attachment 26423 [details]
Patch to reject top-level typed nodes

This patch rejects top-level typed nodes with an exception.
Comment 2 Glenn Adams 2012-04-10 19:31:14 UTC
(In reply to comment #1)
> Created attachment 26423 [details]
> Patch to reject top-level typed nodes
> 
> This patch rejects top-level typed nodes with an exception.

+            String about = attributes.getValue(XMPConstants.RDF_NAMESPACE, "about");                                                                                                                     
+            if (this.contextStack.peek().equals(this.meta) && (about != null)) {                                                                                                                         
+                //rdf:RDF is the parent, so this is a top-level item that isn't                                                                                                                          
+                //an rdf:Description, which isn't allowed.                                                                                                                                               
+                throw new SAXException("Top-level element " + qName + " not an rdf:Description");                                                                                                        
+            }                                                                                             

(1) the check this.contextStack.peek().equals(this.meta) would also return true if xmp:xmpmeta is the parent;

(2) that <!{xmp|rdf}:* rdf:about=""> is the same as 'not an rdf:Description' is not clear to me; aren't there other possibilities for 'not an rdf:Description' that do not have rdf:about?

could you update patch accordingly, and also provide junit tests that test this new functionality both for absence and presence (see test/java/org/apache/xmlgraphics/xmp/XMPParserTest.java)