Professional Web Applications Themes

#45824 [NEW]: loadXML moves entity references from attribute value to before element - PHP Bugs

From: marc at mongenet dot ch Operating system: Linux PHP version: 5.2.6 PHP Bug Type: DOM XML related Bug description: loadXML moves entity references from attribute value to before element Description: ------------ When an attribute value contains an entity reference (like a="&eacute;"), loadXML() moves this entity out of the attribute, just before the owner element. Reproduce code: --------------- $doc = new DOMDoent(); $xml = '<!DOCTYPE e PUBLIC "1" "2">'."\n". # DOCTYPE just to appear well-formed '<e><e a="&eacute;"/></e>'."\n"; $doc->loadXML($xml); echo '<pre>', htmlspecialchars($doc->saveXML()), '</pre>'; Expected result: ---------------- <?xml version="1.0"?> <!DOCTYPE e PUBLIC "1" "2"> <e><e a="&eacute;"/></e> Actual result: -------------- <?xml version="1.0"?> <!DOCTYPE ...

  1. #1

    Default #45824 [NEW]: loadXML moves entity references from attribute value to before element

    From: marc at mongenet dot ch
    Operating system: Linux
    PHP version: 5.2.6
    PHP Bug Type: DOM XML related
    Bug description: loadXML moves entity references from attribute value to before element

    Description:
    ------------
    When an attribute value contains an entity reference (like a="&eacute;"),
    loadXML() moves this entity out of the attribute, just before the owner
    element.

    Reproduce code:
    ---------------
    $doc = new DOMDoent();
    $xml = '<!DOCTYPE e PUBLIC "1" "2">'."\n". # DOCTYPE just to appear
    well-formed
    '<e><e a="&eacute;"/></e>'."\n";
    $doc->loadXML($xml);
    echo '<pre>', htmlspecialchars($doc->saveXML()), '</pre>';


    Expected result:
    ----------------
    <?xml version="1.0"?>
    <!DOCTYPE e PUBLIC "1" "2">
    <e><e a="&eacute;"/></e>


    Actual result:
    --------------
    <?xml version="1.0"?>
    <!DOCTYPE e PUBLIC "1" "2">
    <e>&eacute;<e a=""/></e>


    --
    Edit bug report at http://bugs.php.net/?id=45824&edit=1
    --
    Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45824&r=trysnapshot52
    Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45824&r=trysnapshot53
    Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45824&r=trysnapshot60
    Fixed in CVS: http://bugs.php.net/fix.php?id=45824&r=fixedcvs
    Fixed in release: http://bugs.php.net/fix.php?id=45824&r=alreadyfixed
    Need backtrace: http://bugs.php.net/fix.php?id=45824&r=needtrace
    Need Reproduce Script: http://bugs.php.net/fix.php?id=45824&r=needscript
    Try newer version: http://bugs.php.net/fix.php?id=45824&r=oldversion
    Not developer issue: http://bugs.php.net/fix.php?id=45824&r=support
    Expected behavior: http://bugs.php.net/fix.php?id=45824&r=notwrong
    Not enough info: http://bugs.php.net/fix.php?id=45824&r=notenoughinfo
    Submitted twice: http://bugs.php.net/fix.php?id=45824&r=submittedtwice
    register_globals: http://bugs.php.net/fix.php?id=45824&r=globals
    PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45824&r=php4
    Daylight Savings: http://bugs.php.net/fix.php?id=45824&r=dst
    IIS Stability: http://bugs.php.net/fix.php?id=45824&r=isapi
    Install GNU Sed: http://bugs.php.net/fix.php?id=45824&r=gnused
    Floating point limitations: http://bugs.php.net/fix.php?id=45824&r=float
    No Zend Extensions: http://bugs.php.net/fix.php?id=45824&r=nozend
    MySQL Configuration Error: http://bugs.php.net/fix.php?id=45824&r=mysqlcfg

    marc Guest

  2. #2

    Default #45824 [Opn->Bgs]: loadXML moves entity references from attribute value to before element

    ID: 45824
    Updated by: net
    Reported By: marc at mongenet dot ch
    -Status: Open
    +Status: Bogus
    Bug Type: DOM XML related
    Operating System: Linux
    PHP Version: 5.2.6
    New Comment:

    You should read the warning, it produces:

    Warning: DOMDoent::loadXML(): Entity 'eacute' not defined in Entity,

    line: 2 in /Users/chregu/tmp/foo.php on line 6

    eacute is not a entity which is defined by default (there are only 5 of

    them)


    Previous Comments:
    ------------------------------------------------------------------------

    [2008-08-14 17:59:11] marc at mongenet dot ch

    Description:
    ------------
    When an attribute value contains an entity reference (like
    a="&eacute;"), loadXML() moves this entity out of the attribute, just
    before the owner element.

    Reproduce code:
    ---------------
    $doc = new DOMDoent();
    $xml = '<!DOCTYPE e PUBLIC "1" "2">'."\n". # DOCTYPE just to appear
    well-formed
    '<e><e a="&eacute;"/></e>'."\n";
    $doc->loadXML($xml);
    echo '<pre>', htmlspecialchars($doc->saveXML()), '</pre>';


    Expected result:
    ----------------
    <?xml version="1.0"?>
    <!DOCTYPE e PUBLIC "1" "2">
    <e><e a="&eacute;"/></e>


    Actual result:
    --------------
    <?xml version="1.0"?>
    <!DOCTYPE e PUBLIC "1" "2">
    <e>&eacute;<e a=""/></e>



    ------------------------------------------------------------------------


    --
    Edit this bug report at http://bugs.php.net/?id=45824&edit=1

    chregu@php.net Guest

  3. #3

    Default #45824 [Bgs]: loadXML moves entity references from attribute value to before element

    ID: 45824
    User updated by: marc at mongenet dot ch
    Reported By: marc at mongenet dot ch
    Status: Bogus
    Bug Type: DOM XML related
    Operating System: Linux
    PHP Version: 5.2.6
    New Comment:

    In the Extensible Markup Language (XML) 1.0 (Fourth Edition) W3C
    Recommendation, chapter 4.1 Character and Entity References, it is
    written:
    "Note that non-validating processors are not obligated to to read and
    process entity declarations occurring in parameter entities or in the
    external subset; for such doents, the rule that an entity must be
    declared is a well-formedness constraint only if standalone='yes'."

    What we have in this example is : "Entity 'eacute' is not defined in
    Entity" -> i.e. it is not defined in the pd data. That's because it
    is defined in the external subset. Okay, I admit I didn't write an
    external subset, but it makes no difference because the XML processor
    does not try to read it because I haven't set
    $doc->resolveExternals=TRUE.

    The XML processor should either stop on a fatal error or produce a
    correct DOM (that't a general rule for XML processors). But producing a
    wrong DOM is a no-no. BTW, if the &eacute; entity reference appears in
    the text instead of an attribute value, then the DOM is correctly built.


    Previous Comments:
    ------------------------------------------------------------------------

    [2008-08-15 06:34:07] net

    You should read the warning, it produces:

    Warning: DOMDoent::loadXML(): Entity 'eacute' not defined in Entity,

    line: 2 in /Users/chregu/tmp/foo.php on line 6

    eacute is not a entity which is defined by default (there are only 5 of

    them)

    ------------------------------------------------------------------------

    [2008-08-14 17:59:11] marc at mongenet dot ch

    Description:
    ------------
    When an attribute value contains an entity reference (like
    a="&eacute;"), loadXML() moves this entity out of the attribute, just
    before the owner element.

    Reproduce code:
    ---------------
    $doc = new DOMDoent();
    $xml = '<!DOCTYPE e PUBLIC "1" "2">'."\n". # DOCTYPE just to appear
    well-formed
    '<e><e a="&eacute;"/></e>'."\n";
    $doc->loadXML($xml);
    echo '<pre>', htmlspecialchars($doc->saveXML()), '</pre>';


    Expected result:
    ----------------
    <?xml version="1.0"?>
    <!DOCTYPE e PUBLIC "1" "2">
    <e><e a="&eacute;"/></e>


    Actual result:
    --------------
    <?xml version="1.0"?>
    <!DOCTYPE e PUBLIC "1" "2">
    <e>&eacute;<e a=""/></e>



    ------------------------------------------------------------------------


    --
    Edit this bug report at http://bugs.php.net/?id=45824&edit=1

    marc Guest

Similar Threads

  1. How can I fetch the element's attribute value by AS in amxml file?
    By liaoyateam in forum Macromedia Flex General Discussion
    Replies: 3
    Last Post: May 7th, 12:50 AM
  2. #39505 [NEW]: xpath query failed if root element has xmlns attribute
    By sghnqk at gmail dot com in forum PHP Bugs
    Replies: 1
    Last Post: November 13th, 08:50 PM
  3. CFFORM XML character entity references
    By HairyDude in forum Coldfusion - Advanced Techniques
    Replies: 5
    Last Post: November 10th, 01:00 AM
  4. DEBUG help please? LoadXml error - ugh.
    By Kathy Burke in forum ASP.NET General
    Replies: 1
    Last Post: August 2nd, 08:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139