Closed Bug 10609 Opened 20 years ago Closed 20 years ago

Can't declare html markups with attribute values in entity value

Categories

(Core :: XML, defect, P1, critical)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: tao, Assigned: harishd)

Details

(Whiteboard: 1/3: Clarification requested from assigned engineer prior to verification)

The problem Bill is seeing
--------------------------

I tried to escape the quote with """ in the entry value as such
<html:div id=&quot.foo&quot;>Hello</html:div>
I can get this to work:

<!ENTITY foo "&quot;Hello&quot;">

I can get this to work:

<!ENTITY foo "<html:div>Hello</html:div>">

This crashes:

<!ENTITY foo "<html:div id=&quot.foo&quot;>Hello</html:div>">

Note the &quot;'s inside the html tag.

Bill



Bill Law's original message:
----------------------------

  I'm working on moving entities from .xul to .dtd files and a questions
  came up.

  I have one dialog

(http://lxr.mozilla.org/seamonkey/source/xpfe/components/ucth/resources/unknownContent.xul)

  that has text of the form:

     You have started to download a file of type <mime-type>.

  The <mime-type> is filled in at runtime, based on the URL being
  downloaded.  I do this via a <html:div> element and JavaScript that uses
  DOM apis to set the content.

  So my question is how to make sure this is easily translatable.  If I
  put the text only into an entity:

  <!ENTITY startDownload "You have started to download a file of type">

  then it seems to restrict translators because they can't reword this so
  that the mime-type appears elsewhere rather than at the end of the
  sentence.

  So I think I have to resort to putting markup in the entity:

   <!ENTITY startDownload "You have started to download a file of type
    <html:div id="dialog.contentType"
    style="display:inline;"></html:div>.">
Bill's comments
----------------

Note that markup can go in entities,
just as long as the markup doesn't contain &quot;.

Here's a small testcase: http://law.mcom.com/entity.xul.

My web server won't serve this up as text/xul (or whatever) so you have
to save it to your local machine (using 4.x) and enter a file url.
Here's the content:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/xul.css" type="text/css"?>

<!DOCTYPE window
[
<!ENTITY e1 "foobar">
<!ENTITY e2 "&quot;foobar&quot;">
<!ENTITY e3 "<div>foobar</div>">
<!ENTITY e4 "&lt;div>foobar&lt;/div>">
<!ENTITY e5 "<div id=&quot;foobar&quot;>foobar</div>">
]>

<xul:window xmlns="http://www.w3.org/TR/REC-html40"

xmlns.xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    e1: &e1;
    <br/>
    e2: &e2;
    <br/>
    e3: &e3;
    <br/>
    e4: &e4;
<!-- Uncomment this to cause crash
    <br/>
    e5: &e5;
-->

</xul:window>
Status: NEW → ASSIGNED
Target Milestone: M9
Accepting bug and setting milestone to M9...
Assignee: nisheeth → harishd
Status: ASSIGNED → NEW
Bill,

<!ENTITY foo "<html:div id=&quot;foo&quot;>Hello</html:div>">

is a malformed XML entity because its replacement text equals:

<html:div id=&quot;foo&quot;>Hello</html:div>

which is malformed because the id attribute's value is unquoted.  See
http://www.w3.org/TR/REC-xml#intern-replacement for more information.  You need
to use the following entity declaration:

<!ENTITY foo "<html:div id=&#32;foo&#32;>Hello</html:div>">

for which the replacement text will be the intended

<html:div id="foo">Hello</html:div>

Your test case has uncovered a bug with the way we report errors.  On viewer,
the above test case ends up displaying a black background and nothing else.  On
apprunner, according to the bug report, it crashes.

Harish, I looked into the problem more and here's what's happening. Expat
reports the error to nsExpatTokenizer, which pushes an error token and returns
the NS_ERROR_HTMLPARSER_STOPPARSING error code to the parser.  The parser
assigns the error code to its mInternalState flag and calls BuildModel()
expecting that method to process all the tokens in the token queue.  However,
the first token processed (the stylesheet PI) returns NS_ERROR_HTMLPARSER_BLOCK
so, all subsequent tokens remain unprocessed.  We need to add logic to the
parser to catch this case and process all the tokens once the parser becomes
unblocked even when mInternalState is set to NS_ERROR_HTMLPARSER_STOPPARSING.
You implemented the stop parser logic so I'm assigning this bug to you.
Target Milestone: M9 → M10
Status: NEW → ASSIGNED
setting to M10.
Accepting bug.
Priority: P3 → P1
Setting priority to P1.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Checked in a fix to handle malformed XML/XUL documents.

Marking bug FIXED.
Whiteboard: 1/3: Clarification requested from assigned engineer prior to verification
Harish: I need to verify this bug as fixed. You stated that you had a fix to
handle malformed XML/XUL documents. When I load the malformed doc referred to in
7/27 comments, what should the expected behavior be? Using 1/3 build, the
document doesn't hang the application but it doesn't load it. Please advise.
Thanks
Verified
Windows (NT):2000-07-13-09-M17
Linux       :2000-07-13-08-M17

The test file that is used is "entity.xml", the testcase provided by Bill on 
07/27/99.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.