php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44297 XSLTProcessor::transformToXML doesn't change content-type's charset
Submitted: 2008-02-29 22:28 UTC Modified: 2008-03-01 08:53 UTC
From: jaap dot taal at gmail dot com Assigned:
Status: Not a bug Package: XSLT related
PHP Version: 5.2.5 OS: Windows
Private report: No CVE-ID: None
 [2008-02-29 22:28 UTC] jaap dot taal at gmail dot com
Description:
------------
When I execute the code on linux the dash (&#8211) is shown as a dash. This is because PHP adds a "Content-Type: text/html; charset=UTF-8" header (used firebug to view the info).
On my windows installation, however, the header isn't modified so my browser is displaying "–" instead of a dash.

Manually adding the header works, but it's only a workaround.

I've found a similar bugreport from two years:
http://bugs.php.net/bug.php?id=36415

Reproduce code:
---------------
<?php
$xml = "<mytag>&amp;#8211 is a dash: &quot;&#8211;&quot;</mytag>";
$xmldoc = new DOMDocument();
$xmldoc->loadXML($xml);
$xsl = '<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"/>';
$xsldoc = new DOMDocument();
$xsldoc->loadXML($xsl);
$proc = new XSLTProcessor();
$proc->importStylesheet($xsldoc);
echo $proc->transformToXML($xmldoc);
?>

Expected result:
----------------
&#8211 is a dash: "?"

Actual result:
--------------
&#8211 is a dash: "–"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-01 08:53 UTC] chregu@php.net
It's not the XSLT extension, which sends the COntent-Type header. It's - 
at the end - apache, so if you don't tell apache (via php), which 
content type it should use, it takes the default one.. And that is 
obviously different from what you expect :)
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 13:01:24 2019 UTC