diff --git a/lib/html2text.php b/lib/html2text.php index e2d0dffddbc..9cc213ddd60 100644 --- a/lib/html2text.php +++ b/lib/html2text.php @@ -335,7 +335,7 @@ class html2text */ function html2text( $source = '', $from_file = false, $do_links = true, $width = 75 ) { - if ( !empty($source) ) { + if ($source !== '') { $this->set_html($source, $from_file); } diff --git a/lib/html2text_readme.txt b/lib/html2text_readme.txt index 7fcaef1b3e7..7058045e5fc 100644 --- a/lib/html2text_readme.txt +++ b/lib/html2text_readme.txt @@ -53,3 +53,18 @@ Index: lib/html2text.php } -- Tim Hunt 2010-11-02 + +4 - Make sure html2text does not destroy '0'. + +index e2d0dff..9cc213d 100644 +--- a/lib/html2text.php ++++ b/lib/html2text.php +@@ -335,7 +335,7 @@ class html2text + */ + function html2text( $source = '', $from_file = false, $do_links = true, $wi { +- if ( !empty($source) ) { ++ if ($source !== '') { + $this->set_html($source, $from_file); + } + +-- Tim Hunt 2011-09-21 diff --git a/lib/simpletest/testweblib.php b/lib/simpletest/testweblib.php index 20f6ebf73e1..0e7a39d3609 100644 --- a/lib/simpletest/testweblib.php +++ b/lib/simpletest/testweblib.php @@ -140,6 +140,10 @@ class web_test extends UnitTestCase { $this->assertEqual('With trailing whitespace and some more text', html_to_text("With trailing whitespace \nand some more text", 0)); } + public function test_html_to_text_0() { + $this->assertIdentical('0', html_to_text('0')); + } + public function test_clean_text() { $text = "lala xx"; $this->assertEqual($text, clean_text($text, FORMAT_PLAIN));