Skip to content

Commit fc4aca6

Browse files
committed
cache tag invalidation needs to escape for regex
1 parent 78e2847 commit fc4aca6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/CacheInvalidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function invalidateTags(array $tags)
282282
throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN');
283283
}
284284

285-
$headers = array($this->getTagsHeader() => '('.implode('|', $tags).')(,.+)?$');
285+
$headers = array($this->getTagsHeader() => '('.implode('|', array_map('preg_quote', $tags)).')(,.+)?$');
286286
$this->cache->ban($headers);
287287

288288
return $this;

tests/Unit/CacheInvalidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function testInvalidateTags()
119119
{
120120
$ban = \Mockery::mock('\FOS\HttpCache\ProxyClient\Invalidation\BanInterface')
121121
->shouldReceive('ban')
122-
->with(array('X-Cache-Tags' => '(post-1|posts)(,.+)?$'))
122+
->with(array('X-Cache-Tags' => '(post\-1|posts)(,.+)?$'))
123123
->once()
124124
->getMock();
125125

@@ -131,7 +131,7 @@ public function testInvalidateTagsCustomHeader()
131131
{
132132
$ban = \Mockery::mock('\FOS\HttpCache\ProxyClient\Invalidation\BanInterface')
133133
->shouldReceive('ban')
134-
->with(array('Custom-Tags' => '(post-1)(,.+)?$'))
134+
->with(array('Custom-Tags' => '(post\-1)(,.+)?$'))
135135
->once()
136136
->getMock();
137137

0 commit comments

Comments
 (0)