Bug #50278 [Sus->Csd]: DOM saveHTML removes space from HTML
| From: | cmb@php.net | Date: | Wed, 10 Jun 2015 13:29:12 +0000 |
| Subject: | Bug #50278 [Sus->Csd]: DOM saveHTML removes space from HTML | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193306@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=50278&edit=1
ID: 50278
Updated by: cmb@php.net
Reported by: taylorms at mtaonline dot net
Summary: DOM saveHTML removes space from HTML
-Status: Suspended
+Status: Closed
Type: Bug
Package: DOM XML related
Operating System: linux 2.6
PHP Version: 5.2SVN-2009-11-24 (snap)
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This issue is solved by passing LIBXML_HTML_NODEFDTD as option
when loading the document. This constant is available as of PHP
5.4.0 when libxml2 >= 2.7.8 is used. See <http://3v4l.org/qs4TC>.
Previous Comments:
------------------------------------------------------------------------
[2009-11-24 13:35:31] rasmus@php.net
This looks more like a libxml2 issue than a PHP one. Information for filing bugs against libxml2 is
here:
http://xmlsoft.org/bugs.html
------------------------------------------------------------------------
[2009-11-24 08:59:49] taylorms at mtaonline dot net
Note: I added a <span> tag with a single space in it between the two <input> tags and it
worked OK. The source became
<form action="../search/search.php" method="get"
class="searchform">
<input type="text" size="15" name="zoom_query"
id="searchbox"/><span> </span><input type="submit"
value="search" id="searchgo"/>
</form>
The <input><span><input> are all still on one single line (3 lines total), but the
space between the searchbox and searchgo elements is consistent now with all other pages. I'm
baffled.
------------------------------------------------------------------------
[2009-11-24 04:36:56] taylorms at mtaonline dot net
Description:
------------
Using loadHTML to load a formated HTML template file. I then use the DOM functions to create new
elements before using saveHTML to dump the entire HTML to the browser.
When loading the .html file directly into the browser, the elements have correct spacing. When using
loadHTML/saveHTML, spacing for a particular element is different.
I've tracked it down to the following difference. The .html looks as shown in BLK#1 below,
whereas the html generated with loadHTML/saveHTML is as shown in BLK#2 below.
The newline in the .html file shown in BLK#1 produces a "space" between the elements in
both FF3.5 and IE8 that is missing when the BLK#2 code is sent.
Reproduce code:
---------------
BLK#1
<form class="searchform" method="get"
action="../search/search.php">
<input id="searchbox" type="text" name="zoom_query"
size="15"/>
<input id="searchgo" type="submit" value="search"/>
</form>
BLK#2
<form action="../search/search.php" method="get"
class="searchform">
<input type="text" size="15" name="zoom_query"
id="searchbox"/><input type="submit" value="search"
id="searchgo"/>
</form>
NOTE: In BLK#2, the two <input> tags are together on the same line, i.e., no newline between
them.
Expected result:
----------------
The searchbox (textbox) and searchgo (button) are separated by a small space (about 5 px) when
displaying the .html file directly (BLK#1 code).
Actual result:
--------------
When displaying in browser using saveHTML, the space is missing, and only on this page. This is part
of a template file and is identical on every page of my site. BLK#2 code produces a searchbox and
searchgo button that are touching.
NOTE: I can edit the source directly in FF Firebug, add a single space or a newline to the code
between the two <input> tags and the space appears as it should be.
The DOM functionality is removing newlines in other places too, but manifests itself here as a
negative visual effect.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=50278&edit=1