diff options
author | Paul Phillips <paulp@improving.org> | 2011-10-04 00:53:15 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-10-04 00:53:15 +0000 |
commit | 77d90e3aead2a48c1b5c633e57dea1b452b40db1 (patch) | |
tree | c7f8ea8b961e5ab13e8e56f3b115d8e380d1ab43 | |
parent | 0d730957dd61c8d9132dcec9b9fe07805d2bb960 (diff) | |
download | scala-77d90e3aead2a48c1b5c633e57dea1b452b40db1.tar.gz scala-77d90e3aead2a48c1b5c633e57dea1b452b40db1.tar.bz2 scala-77d90e3aead2a48c1b5c633e57dea1b452b40db1.zip |
Fix for XML entity bug.
Hard to believe a bug like this can exist this long. Cay Horstman showed
me.
// Hey, where's my eacute?
scala> <city name="San José"/>.attributes foreach println
name="San Jos&;"
No review.
-rw-r--r-- | src/library/scala/xml/Utility.scala | 8 | ||||
-rw-r--r-- | test/files/jvm/xml05.check | 11 | ||||
-rw-r--r-- | test/files/jvm/xml05.scala | 7 |
3 files changed, 22 insertions, 4 deletions
diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index 4d6712419c..9f230a7866 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -364,14 +364,14 @@ object Utility extends AnyRef with parsing.TokenTests { c = it.next } val ref = rfb.toString() - rfb.setLength(0) + rfb.clear() unescape(ref,sb) match { case null => - if (sb.length > 0) { // flush buffer + if (sb.length > 0) { // flush buffer nb += Text(sb.toString()) - sb.setLength(0) + sb.clear() } - nb += EntityRef(sb.toString()) // add entityref + nb += EntityRef(ref) // add entityref case _ => } } diff --git a/test/files/jvm/xml05.check b/test/files/jvm/xml05.check new file mode 100644 index 0000000000..21db1e7ef5 --- /dev/null +++ b/test/files/jvm/xml05.check @@ -0,0 +1,11 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> <city name="San José"/> +res0: scala.xml.Elem = <city name="San José"></city> + +scala> + +scala> diff --git a/test/files/jvm/xml05.scala b/test/files/jvm/xml05.scala new file mode 100644 index 0000000000..52ae255393 --- /dev/null +++ b/test/files/jvm/xml05.scala @@ -0,0 +1,7 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ +<city name="San José"/> + """ +}
\ No newline at end of file |