Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1209] Compile error when a view's attribute contains an escaped quote

GitHub Issuen/a
TypeBug
PriorityMedium
StatusResolved
ResolutionWon't Fix
Resolution Date2015-01-09T14:26:14.000+0000
Affected Version/sn/a
Fix Version/sAlloy 1.7.0
ComponentsXML
LabelsTCSupportTriage, alloy, compile, view
ReporterFokke Zandbergen
AssigneeTim Poulsen
Created2014-11-12T14:01:58.000+0000
Updated2015-01-09T14:26:14.000+0000

Description

The following view:
<Alloy>
	<Window>
		<Label html="Hello <b>Bold</b> <font color=\"red\">World!</font>" />
	</Window>
</Alloy>
Will result in the following compile error:
[INFO]    view:       "index.xml"
[WARN]  attribute space is required"html"!!
[WARN]  @#[line:3,col:3]
[ERROR] Error parsing XML file.
[ERROR] element parse error: Error: attribute value must after "="
[ERROR] @#[line:3,col:3]
[ERROR] Alloy compiler failed
I'd expect this to work fine since the " is escaped?

Comments

  1. Fokke Zandbergen 2015-01-09

    Workaround by [~skypanther]:
        <Label html='Hello <b>Bold</b> <font color="red">World!</font>' />
        <Label html="Hello <b>Bold</b> <font color='red'>World!</font>" />
       
  2. Fokke Zandbergen 2015-01-09

    The correct way to escape (double) quotes in XML according to the [specification](http://www.w3.org/TR/REC-xml/#syntax) is to use " or use <![CDATA[ .. ]]> in a text node. I think with this argument this ticket can be closed as *Won't Fix*
  3. Tim Poulsen 2015-01-09

    Resolving per Fokke's comments. Escaped characters aren't supported in XML, we don't support CDATA blocks, and there's no reliable way to replace quotes (escaped or otherwise) in attribute values given the many possible permutations of strings developers might use. Additional workarounds would be to put the strings into the TSS or JS, or for quotes within HTML (not surrounding attributes as in the original problem description) would be to use entities like &ldquo;

JSON Source