Skip to content

getPlainText html_entity_decode encoding error #31

Description

@GoogleCodeExporter
Running version lower than PHP 5.3 (and even higher versions, if you believe 
the comments at php.net) does not default to UTF-8, but to ISO-8859-1, when 
using html_entity_decode(...) function. This creates problems when using 
getPlainText(), because it does not take into account the encoding.

What will reproduce the problem?
Just parse something in an encoding other than *YOUR* html_entity_decode(...) 
function and it should be easy to see the problems.

What is the expected output? What do you see instead?
Expected output are correctly converted html enttities. 
I get an empty string, like " " => ""
but I would expect to see, " " => " "


Which version are you using?
Ganon single file PHP5 (rev. #78)

Please provide any additional information below.
It can be easily resolved by replacing the function getPlainText() from 
return preg_replace('`\s+`', ' ', html_entity_decode($this->toString(true, 
true, true), ENT_QUOTES));

to

return preg_replace('`\s+`', ' ', html_entity_decode($this->toString(true, 
true, true), ENT_QUOTES, $this->getEncoding()));

Original issue reported on code.google.com by thomas.a...@gmail.com on 19 Jan 2013 at 1:57

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions