Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 390280 - @XmlPath predicate values with slashes cause parse fail and illegal generated xml
Summary: @XmlPath predicate values with slashes cause parse fail and illegal generated...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-24 17:36 EDT by Markus Mårtensson CLA
Modified: 2022-06-09 10:31 EDT (History)
2 users (show)

See Also:
matt.macivor: iplog+


Attachments
Simple patch (1.08 KB, application/octet-stream)
2012-09-24 17:36 EDT, Markus Mårtensson CLA
no flags Details
Simple patch v2 (2.13 KB, application/octet-stream)
2012-09-25 07:36 EDT, Markus Mårtensson CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Mårtensson CLA 2012-09-24 17:36:59 EDT
Created attachment 221444 [details]
Simple patch

XMLField.buildFragments splits @XmlPath values at slashes, even when they are found within string values.

Consider the following annotation on a property:
@XmlPath("atom:category[@scheme='http://example/scheme']/@term")

This is a very common pattern for us given that the RESTful API
we are communicating with is mostly atom based and its documentation
is XPath centric.

Parsing will always give a null value whereas generation will give us this disappointing output:

<?xml version="1.0" encoding="UTF-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom">
   <atom:category[@scheme='http:>
      <example>
         <scheme'] term="test"/>
      </example>
   </atom:category[@scheme='http:>
</atom:entry>

I'm attaching a simplistic patch which fixes the problem for any but the 
trickiest exceptions and should have no adverse effects.

Parsing works and we get the following output generated:

<?xml version="1.0" encoding="UTF-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom">
   <atom:category scheme="http:/example/scheme" term="test"/>
</atom:entry>
Comment 1 Markus Mårtensson CLA 2012-09-25 07:18:30 EDT
Upon closer inspection, it appears that double slashes (as in http://) are
turned into single slashes (http:/) with my patch. I expect this to be
an easy fix using returnDelims of StringTokenizer.
Comment 2 Markus Mårtensson CLA 2012-09-25 07:36:28 EDT
Created attachment 221468 [details]
Simple patch v2

Updated patch to handle double slashes.
Comment 3 Matt MacIvor CLA 2012-09-26 14:26:51 EDT
Attached patch has been reviewed, verified and committed. A junit test case was also added for this use case. The fix was checked into master and 2.4 branches and will appear in future nightly builds of those streams.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:31:41 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink