Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Attributes with newline are not handled consistently #7395

Closed
scabug opened this issue Apr 20, 2013 · 4 comments
Closed

XML Attributes with newline are not handled consistently #7395

scabug opened this issue Apr 20, 2013 · 4 comments

Comments

@scabug
Copy link

scabug commented Apr 20, 2013

See the two instances I have below (taken from REPL)

Native XML handling, preserves the newline character.

scala> <foo key="val
     | ue" />
res0: scala.xml.Elem = 
<foo key="val
ue"/>

XML.loadString, however, converts to a newline.

scala> XML.loadString("""<foo key="val
     | ue" />""")
res3: scala.xml.Elem = <foo key="val ue"/>

As such, the XML blocks are not equal.

scala> res0 equals res3
res6: Boolean = false

Newlines NOT inside of attributes are preserved in both instances are are equal as such.

scala> <foo>
     | bar
     | baz
     | </foo>
res4: scala.xml.Elem = 
<foo>
bar
baz
</foo>

scala> XML.loadString("""<foo>
     | bar
     | baz
     | </foo>""")
res5: scala.xml.Elem = 
<foo>
bar
baz
</foo>

scala> res4 equals res5
res7: Boolean = true
@scabug
Copy link
Author

scabug commented Apr 20, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7395?orig=1
Reporter: Joshua Backfield (jbackfield)
Affected Versions: 2.10.0

@scabug
Copy link
Author

scabug commented Apr 20, 2013

Joshua Backfield (jbackfield) said:
No idea why this is set to a blocker, I was unable to change the initial priority.

@scabug
Copy link
Author

scabug commented Jun 26, 2014

@rklaehn said:
I have to disagree with the categorization of this issue as "Minor". Not properly escaping attributes means that scala.xml does not comply to the xml spec. This should be very easy to fix, but to work around this issue is a major pain in the ass.

So why not just fix this? I know scala.xml is on the way to deprecation. But a lot of people are still using it. Especially given that there is no official replacement, and it is still shown in the examples in all the books such as "Programming in Scala".

@scabug
Copy link
Author

scabug commented Jul 17, 2015

@SethTisue said:
The scala-xml library is now community-maintained. Issues with it are now tracked at https://github.com/scala/scala-xml/issues instead of here in the Scala JIRA.

Interested community members: if you consider this issue significant, feel free to open a new issue for it on GitHub, with links in both directions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant