From 9abcf40df7bfc9bdba9626b9cfd9d132fe935e97 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 3 Dec 2019 09:47:45 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B02558=20Test=20for=20the=20HTMLDOMSanitiz?= =?UTF-8?q?er=20white=20list=20:=20remove=20new=20lines=20the=20parser=20g?= =?UTF-8?q?ives=20different=20results=20depending=20on=20the=20PHP=20versi?= =?UTF-8?q?on=20Didn't=20manage=20to=20get=20it=20right=20:=20-=20no=20php?= =?UTF-8?q?.ini=20difference=20-=20playing=20with=20the=20parser=20preserv?= =?UTF-8?q?eWhitespace/formatOutput=20parser=20options=20didn't=20help?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So we're removing new lines on both sides :/ --- test/core/HTMLDOMSanitizerTest.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/core/HTMLDOMSanitizerTest.php b/test/core/HTMLDOMSanitizerTest.php index 3ce540b64..3b8f6eecc 100644 --- a/test/core/HTMLDOMSanitizerTest.php +++ b/test/core/HTMLDOMSanitizerTest.php @@ -24,11 +24,18 @@ class HTMLDOMSanitizerTest extends ItopTestCase { $sInputHtml = $this->ReadTestFile($sFileToTest, self::INPUT_DIRECTORY); $sOutputHtml = $this->ReadTestFile($sFileToTest, self::OUTPUT_DIRECTORY); - $sOutputHtml = $this->RemoveNewLines($sOutputHtml); $oSanitizer = new HTMLDOMSanitizer(); $sRes = $oSanitizer->DoSanitize($sInputHtml); + // Removing newlines as the parser gives different results depending on the PHP version + // Didn't manage to get it right : + // - no php.ini difference + // - playing with the parser preserveWhitespace/formatOutput parser options didn't help + // So we're removing new lines on both sides :/ + $sOutputHtml = $this->RemoveNewLines($sOutputHtml); + $sRes = $this->RemoveNewLines($sRes); + $this->debug($sRes); $this->assertEquals($sOutputHtml, $sRes); } @@ -71,7 +78,14 @@ class HTMLDOMSanitizerTest extends ItopTestCase $oSanitizer = new HTMLDOMSanitizer(); $sRes = $oSanitizer->DoSanitize($sHtmlToTest); - $this->debug($sRes); + // Removing newlines as the parser gives different results depending on the PHP version + // Didn't manage to get it right : + // - no php.ini difference + // - playing with the parser preserveWhitespace/formatOutput parser options didn't help + // So we're removing new lines on both sides :/ + $sHtmlToTest = $this->RemoveNewLines($sHtmlToTest); + $sRes = $this->RemoveNewLines($sRes); + $this->assertEquals($sHtmlToTest, $sRes); }