Aladdin - Scala Bugtracking
[#844] project: compiler priority: low category: bug
submitter assigned to status date submitted
Nikolay Burak not repro 2006-11-28 11:21:38.0
subject [contrib #268] XML.loadString fails to load & inside attributes
code
scala.xml.XML.loadString("<x y=\"&amp;\"/>") // fails
scala.xml.XML.loadString("<x y=\"&amp;amp;\"/>") // loads <x y="&amp;"/>
scala.xml.XML.loadString(<x y="&amp;"/>.toString) // fails
what happened
java.lang.StringIndexOutOfBoundsException: String index out of range: 1
        at java.lang.String.charAt(String.java:558)
        at scala.Iterator$$anon$1.next(Iterator.scala:66)
        at scala.Iterator$$anon$1.next(Iterator.scala:62)
        at scala.xml.Utility$.parseAttributeValue(Utility.scala:279)
        at scala.xml.UnprefixedAttribute.(UnprefixedAttribute.scala:25)
        at scala.xml.parsing.FactoryAdapter$$anonfun$0.apply(FactoryAdapter.scala:156)
        at scala.xml.parsing.FactoryAdapter$$anonfun$0.apply(FactoryAdapter.scala:135)
        at scala.List.foreach(List.scala:687)
        at scala.xml.parsing.FactoryAdapter.startElement(FactoryAdapter.scala:135)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)\

        at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:798)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFr\
agmentScannerImpl.java:878)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(\
XMLDocumentScannerImpl.java:1157)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.disp\
atch(XMLDocumentFragmentScannerImpl.java:1794)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragme\
ntScannerImpl.java:368)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
        at scala.xml.parsing.FactoryAdapter.loadXML(FactoryAdapter.scala:287)
        at scala.xml.parsing.NoBindingFactoryAdapter.loadXML(NoBindingFactoryAdapter.scala:55)
        at scala.xml.XML$.load(XML.scala:66)
        at scala.xml.XML$.loadString(XML.scala:82)
        at line13$object$.(:4)
        at line13$object$.()
        at RequestResult$line13$object$.(:3)
        at RequestResult$line13$object$.()
        at RequestResult$line13$object.result()
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at scala.tools.nsc.Interpreter$Request.loadAndRun(Interpreter.scala:568)
        at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:284)
        at scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:173)
        at scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:86)
        at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:192)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:82)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
what expected returns
[back to overview]
Changes of this bug report
Nikolay  edited on  2006-11-28 11:23:03.0
Contribution #268. BTW, in the scala 2.3.0 interpreter non of these examples crashes. But the entity is not replaced with what it stands for.
Burak  edited on  2006-11-28 23:10:12.0
I could not reproduce this bug -- maybe I got the contrib wrong, because I am really writing &amp; (5 letters here). If you had only the ampersand by itself, it would not be wellformed XML.