Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.6.4, 1.7.4
-
Fix Version/s: 1.7.5, 1.8-beta-2
-
Component/s: XML Processing
-
Labels:None
-
Testcase included:yes
-
Patch Submitted:Yes
-
Number of attachments :
Description
Given an XML file which contains a newline character reference ( ) in the value of an attribute, the following groovy code incorrectly outputs the actual newline character instead of the original character reference. This is a significant problem because the XML standard dictates that newlines found in the value of an attribute must be treated as a space. Thus, if any XML parser reads the output of this groovy snippet, it is as if the newline is gone.
newline.xml:
<option name="LINE_SEPARATOR" value="
"/>
groovy:
def fileWriter = new FileWriter('./newline-roundtrip.xml')
def input = new XmlParser().parse('./newline.xml')
PrintWriter printWriter = new PrintWriter(fileWriter)
new XmlNodePrinter(printWriter).print(input)
printWriter.flush()
I've attached a junit test which demonstrates the problem.
Activity
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 1.6.4 [ 15291 ] | |
| Fix Version/s | 1.7.4 [ 16563 ] | |
| Affects Version/s | 1.7.4 [ 16563 ] |
| Attachment | GROOVY-4380-1_7_x.diff [ 50885 ] |
| Fix Version/s | 1.8-beta-2 [ 16629 ] | |
| Patch Submitted | [Yes] | |
| Fix Version/s | 1.7.5 [ 16639 ] |
| Assignee | Paul King [ paulk ] |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Sorry, I meant to mark 1.6.4 and 1.7.4 in Affected versions, not Fix versions. I don't see a way for me to change it now.