Congratulations! On 5/31/16, 1:27 PM, "Harbs" <[email protected]> wrote:
>Yay! > >I think I just managed to complete my first fix for FalconJX. :-) > >I committed a fix and added a test case for it. > >Harbs > >On May 31, 2016, at 9:53 PM, Alex Harui <[email protected]> wrote: > >> AIUI, a String literal can be passed to JS as-is. An XML literal is >>trickier because we want to wrap the literal in quotes so it can be >>passed as an parameter to the XML constructor. >> >> The current code attempts to try to figure out what quoting was used in >>the XML literal and use the other quotes. Naturally, this isn't >>sufficient when both quotes are used. Probably even for: >>> <root firstName="Alex" lastName='Harui' />; >> >> It would suck to have to parse the XML first and canonicalize it, but >>maybe that's the only "true" answer, I don't know. Maybe you can just >>escape every double and single quote. It might be worth trying: >>http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/ >>lang3/StringUtils.html#wrap(java.lang.String,%20char) >> >> -Alex >> >> >> From: Harbs <[email protected]> >> Date: Tuesday, May 31, 2016 at 11:26 AM >> To: Alex Harui <[email protected]> >> Subject: Re: [FalconJX]Compilation error in XML >> >> No. That’s not going to work because the first character is not the >>quote. It’s “n” from new XML… >> >> I’ll give it a go and see if I can fix this… >> >> On May 31, 2016, at 9:16 PM, Harbs <[email protected]> wrote: >> >>> I just simplified the case to: >>> private var quotedXML : XML =<root title="That's Entertainment"/>; >>> >>> This is enough to cause the error: >>> this.quotedXML = new XML( "<root title="That's Entertainment"/>"); >>> >>> I added it to the manualtest for XML. >>> >>> I looked at the code again, and it looks like it should be escaping >>>the quotes on line 111 and on: >>> >>> if (c == '"') >>> { >>> s = s.substring(1, s.length() - 1); >>> s = s.replace("\"", "\\\""); >>> s = "\"" + s + "\""; >>> } >>> else if (c == '\'') >>> { >>> s = s.substring(1, s.length() - 1); >>> s = s.replace("'", "\\'"); >>> s = "'" + s + "'"; >>> } >>> >>> I think the problem is that this is wrapped in a check for: >>> if (node.getLiteralType() == LiteralType.STRING) >>> >>> While the XML type is LiteralType.XML (I think) >>> >>> I’m not sure why that check is there. Does it make sense to check for: >>> >>> if (node.getLiteralType() == LiteralType.STRING || >>>node.getLiteralType() == LiteralType.XML) >>> >>> instead? >>> >>> On May 31, 2016, at 8:50 PM, Alex Harui <[email protected]> wrote: >>> >>>> I haven't looked at the test case in detail. Is there a tricky use >>>>of both single and double quotes as string delimiters? Otherwise, I >>>>think the simple-ish answer is to replace the s.contains test for a >>>>better test that tests whether a single-quote is being used in the >>>>string without being escaped. >>>> >>>> Or am I missing what the issue is? >>>> -Alex >>>> >>>> From: Harbs <[email protected]> >>>> Date: Tuesday, May 31, 2016 at 10:07 AM >>>> To: Alex Harui <[email protected]> >>>> Subject: Re: [FalconJX]Compilation error in XML >>>> >>>> That’s the current code. I’m not really sure how to fix it… >>>> >>>> On May 31, 2016, at 7:47 PM, Alex Harui <[email protected]> wrote: >>>> >>>>> Feel free to try it. That code scares me. >>>>> >>>>> From: Harbs <[email protected]> >>>>> Date: Tuesday, May 31, 2016 at 8:00 AM >>>>> To: Alex Harui <[email protected]> >>>>> Subject: Re: [FalconJX]Compilation error in XML >>>>> >>>>> I think this is the problem: >>>>> s = ((LiteralNode)child).getValue(true); >>>>> if (s.contains("'")) >>>>> sb.append("\"" + s + "\""); >>>>> else >>>>> sb.append("'" + s + "'"); >>>>> >>>>> The problem is the line which contains both a single quote and a >>>>>double quote... >>>>> >>>>> On May 31, 2016, at 5:58 PM, Harbs <[email protected]> wrote: >>>>> >>>>>> Theoretically it should be doing that already: >>>>>> s = s.replaceAll("\\\\\"", "__QUOTE_PLACEHOLDER__"); >>>>>> >>>>>> I’m not sure where __QUOTE_PLACEHOLDER__ is set… >>>>>> >>>>>> On May 31, 2016, at 4:42 PM, Alex Harui <[email protected]> wrote: >>>>>> >>>>>>> That's probably the code in LiteralEmitter. You're welcome to try >>>>>>>to fix it. >>>>>>> >>>>>>> Sent from my LG G3, an AT&T 4G LTE smartphone >>>>>>> >>>>>>> ------ Original message------ >>>>>>> From: Harbs >>>>>>> Date: Tue, May 31, 2016 4:15 AM >>>>>>> To: dev; >>>>>>> Subject:[FalconJX]Compilation error in XML >>>>>>> >>>>>>> The following XML does not compile correctly: >>>>>>> private var xml : XML =<root title="That's Entertainment"> >>>>>>> <node title="My Music"> >>>>>>> <node title="Language and Perspective" artist="Bad >>>>>>>Suns"> >>>>>>> <node title="Matthew James" length="3:24"/> >>>>>>> <node title="We Move Like the Ocean" >>>>>>>length="3:56"/> >>>>>>> <node title="Cardiac Arrest" >>>>>>>length="3:15"/> >>>>>>> </node> >>>>>>> <node title="Strange Desire" artist="Bleachers"> >>>>>>> <node title="Wild Heart" length="4:15"/> >>>>>>> <node title="Rollercoaster" length="3:39"/> >>>>>>> <node title="Shadow" length="3:46"/> >>>>>>> <node title="I Wanna Get Better" >>>>>>>length="4:23"/> >>>>>>> </node> >>>>>>> </node> >>>>>>> <node title="My Books"> >>>>>>> <node title="Wizard of Oz"> >>>>>>> <node title="So this is Kansas?" >>>>>>>length="82"/> >>>>>>> <node title="A Might Dusty Here" >>>>>>>length="63"/> >>>>>>> <node title="Is that a Tornado?" >>>>>>>length="103"/> >>>>>>> </node> >>>>>>> <node title="Favorite Book #2"> >>>>>>> <node title="Chapter 1" length="15"/> >>>>>>> <node title="Chapter 2" length="86"/> >>>>>>> <node title="Chapter 3" length="104"/> >>>>>>> <node title="Chapter 4" length="99"/> >>>>>>> </node> >>>>>>> </node> >>>>>>> </root>; >>>>>>> >>>>>>> It gets compiled to: >>>>>>> >>>>>>> this.xml = new XML( "<root title="That's Entertainment">\ >>>>>>> \t<node title="My Music">\ >>>>>>> \t\t<node title="Language and Perspective" artist="Bad Suns">\ >>>>>>> \t\t\t<node title="Matthew James" length="3:24"/>\ >>>>>>> \t\t\t<node title="We Move Like the Ocean" length="3:56"/>\ >>>>>>> \t\t\t<node title="Cardiac Arrest" length="3:15"/>\ >>>>>>> \t\t</node>\ >>>>>>> \t\t<node title="Strange Desire" artist="Bleachers">\ >>>>>>> \t\t\t<node title="Wild Heart" length="4:15"/>\ >>>>>>> \t\t\t<node title="Rollercoaster" length="3:39"/>\ >>>>>>> \t\t\t<node title="Shadow" length="3:46"/>\ >>>>>>> \t\t\t<node title="I Wanna Get Better" length="4:23"/>\ >>>>>>> \t\t</node>\ >>>>>>> \t</node>\ >>>>>>> \t<node title="My Books">\ >>>>>>> \t\t<node title="Wizard of Oz">\ >>>>>>> \t\t\t<node title="So this is Kansas?" length="82"/>\ >>>>>>> \t\t\t<node title="A Might Dusty Here" length="63"/>\ >>>>>>> \t\t\t<node title="Is that a Tornado?" length="103"/>\ >>>>>>> \t\t</node>\ >>>>>>> \t\t<node title="Favorite Book #2">\ >>>>>>> \t\t\t<node title="Chapter 1" length="15"/>\ >>>>>>> \t\t\t<node title="Chapter 2" length="86"/>\ >>>>>>> \t\t\t<node title="Chapter 3" length="104"/>\ >>>>>>> \t\t\t<node title="Chapter 4" length="99"/>\ >>>>>>> \t\t</node>\ >>>>>>> \t</node>\ >>>>>>> </root>"); >>>>>>> >>>>>>> Note that the quotes are not properly escaped which causes the >>>>>>>string to be terminated prematurely. >>>>>> >>>>> >>>> >>> >> >
