ID:               49646
 Comment by:       taylorms at mtaonline dot net
 Reported By:      taylorms at mtaonline dot net
 Status:           Open
 Bug Type:         DOM XML related
 Operating System: Linux
 PHP Version:      5.3SVN-2009-09-23 (snap)
 New Comment:

sjo...@php.net

You are correct. I first removed the & and there was no problem. I then
replaced "&" with "&" and still no problem. I guess I did not
realize that you needed to escape & in javascript, since earlier in the
HTML is a javascript with plenty of "&&"s in it. Perhaps the onclick is
not parsed by the loadHTMLfile as javascript since it is enclosed in
"".

Thanks for your quick reply.

Shane


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

[2009-09-23 20:02:33] sjo...@php.net

Thank you for your bug report.

If I recall correctly, ampersands need to be escaped in HTML, including
in links and the like. This means that this is a bug in your HTML and
not in the DOM parser. Please try to put your file through W3Cs HTML
validator at http://validator.w3.org/ .

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

[2009-09-23 19:53:24] taylorms at mtaonline dot net

Description:
------------
The line of HTML below causes DOM LoadHTMLfile to throw the following
exception:

DOMDocument::loadHTMLFile() [<a
href='function.DOMDocument-loadHTMLFile'>function.DOMDocument-loadHTMLFile</a>]:
htmlParseEntityRef: expecting ';' in contactus.html, line: 111

Line 111 of contactus.html is a link with an onclick with multiline
(";" separated) embedded javascript. The source line is shown in the
code section. Note that if I create a javascript function, and reference
only the function name in the 'onclick=""', the error is NOT produced
(also shown). It appears the parser is getting confused with the
embedded javascript in this statement.



Reproduce code:
---------------
---
>From manual page: domdocument.loadhtmlfile
---

HTML Source that causes error:

<a class="social_buttons"
href="http://www.facebook.com/share.php?u=aboutfaceak.com";
onclick="u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return
false;" target="_blank"><img class="social_img"
src="../images/facebook_share.png" /></a>

The following code with a change to "onclick" does NOT cause an error:

<a class="social_buttons"
href="http://www.facebook.com/share.php?u=aboutfaceak.com";
ONCLICK="RETURN FBSHARE();" target="_blank"><img class="social_img"
src="../images/facebook_share.png" /></a>



Expected result:
----------------
The onclick javascript code opens a new window with a facebook php app
that uses the URL of the page where the link was clicked as the link to
share on facebook. If javascript is disabled, the generic link listed in
"href" is used instead of the actual current page URL.

Actual result:
--------------
The error shown in the description is thrown (and caught/logged) when
the loadHTMLfile function is called with the source file containing the
above source line.


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


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

Reply via email to