From e0b587be49246206cf6690a321e94666ef7a323a Mon Sep 17 00:00:00 2001 From: Justin Filip Date: Wed, 14 Dec 2011 11:37:45 -0500 Subject: [PATCH] MDL-30741 Adding a new test to check for incorrect parsing of complicate HTML with a PRE tag. --- lib/simpletest/testweblib.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/simpletest/testweblib.php b/lib/simpletest/testweblib.php index cf2c84bc8b5..27359ce88a5 100644 --- a/lib/simpletest/testweblib.php +++ b/lib/simpletest/testweblib.php @@ -139,6 +139,27 @@ class web_test extends UnitTestCase { $this->assertIdentical('0', html_to_text('0')); } + public function test_html_to_text_pre_parsing_problem() { + $strorig = 'Consider the following function:
void FillMeUp(char* in_string) {'.
+                   '
int i = 0;
while (in_string[i] != \'\0\') {
in_string[i] = \'X\';
i++;
}
'. + '}
What would happen if a non-terminated string were input to this function?

'; + + $strconv = 'Consider the following function: + +void FillMeUp(char* in_string) { + int i = 0; + while (in_string[i] != \'\0\') { + in_string[i] = \'X\'; + i++; + } +} +What would happen if a non-terminated string were input to this function? + +'; + + $this->assertIdentical($strconv, html_to_text($strorig)); + } + public function test_clean_text() { $text = "lala xx"; $this->assertEqual($text, clean_text($text, FORMAT_PLAIN));