[HttpKernel] fix broken multiline <esi:remove>
This commit is contained in:
parent
b1003d57f3
commit
06f97bfbd1
@ -162,8 +162,8 @@ class Esi
|
||||
|
||||
// we don't use a proper XML parser here as we can have ESI tags in a plain text response
|
||||
$content = $response->getContent();
|
||||
$content = preg_replace('#<esi\:remove>.*?</esi\:remove>#', '', $content);
|
||||
$content = preg_replace('#<esi\:comment[^>]*(?:/|</esi\:comment)>#', '', $content);
|
||||
$content = preg_replace('#<esi\:remove>.*?</esi\:remove>#s', '', $content);
|
||||
$content = preg_replace('#<esi\:comment[^>]+>#s', '', $content);
|
||||
|
||||
$chunks = preg_split('#<esi\:include\s+(.*?)\s*(?:/|</esi\:include)>#', $content, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]);
|
||||
|
@ -92,6 +92,28 @@ class EsiTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($response->headers->has('x-body-eval'));
|
||||
}
|
||||
|
||||
public function testMultilineEsiRemoveTagsAreRemoved()
|
||||
{
|
||||
$esi = new Esi();
|
||||
|
||||
$request = Request::create('/');
|
||||
$response = new Response('<esi:remove> <a href="http://www.example.com">www.example.com</a> </esi:remove> Keep this'."<esi:remove>\n <a>www.example.com</a> </esi:remove> And this");
|
||||
$esi->process($request, $response);
|
||||
|
||||
$this->assertEquals(' Keep this And this', $response->getContent());
|
||||
}
|
||||
|
||||
public function testCommentTagsAreRemoved()
|
||||
{
|
||||
$esi = new Esi();
|
||||
|
||||
$request = Request::create('/');
|
||||
$response = new Response('<esi:comment text="some comment >" /> Keep this');
|
||||
$esi->process($request, $response);
|
||||
|
||||
$this->assertEquals(' Keep this', $response->getContent());
|
||||
}
|
||||
|
||||
public function testProcess()
|
||||
{
|
||||
$esi = new Esi();
|
||||
|
Reference in New Issue
Block a user