Menu

#3 Problem with entity reference &

open
None
5
2005-04-11
2004-06-14
Anonymous
No

An & in an attribute reference causes an "Invalid
entity reference found" error. There was notes about
this problem in Google groups:

http://groups.google.com/groups?q=%
22invalid+entity+reference+found&hl=en&lr=&ie=UTF-
8&selm=3f66e42d%241%
40newsgroups.borland.com&rnum=1

Discussion

  • Karl Waclawek

    Karl Waclawek - 2005-04-11
    • assigned_to: nobody --> kbwood
     
  • Karl Waclawek

    Karl Waclawek - 2005-04-11

    Logged In: YES
    user_id=290026

    It seems we never got notified of this bug entry.

     
  • Trevor Magnusson

    This bug occurs because TSAXDelphiReader.DoElement() (or rather, the StartElement;() sub procedure within it) processes each "entity" twice.
    The comments suggest the first pass is to "Handle namespace declarations separately", while the second pass is to "Now process the names"

    The result is that in the first pass, the ampersand escape sequence is correctly translated into a literal ampersand.
    In the second pass, that naked ampersand causes an "Invalid entity reference found" exception, which is not recoverable.

    My workaround:
    line 313 of saxkw.pas, comment out the *second* call to ReplaceEntiries():
    //Attribs.Values[AttrName] := ReplaceEntities(Attribs.Values[AttrName]);

    (not sure if there are any consequences...)

    BTW, I contacted the original developer with this info and the response was:
    > Sorry I can't help you out. I haven't looked at this code for over 8 years.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.