Skip to content

Commit 2bba813

Browse files
jdreesendbu
authored andcommitted
Escape special characters in Varnish::banPath() host patterns
1 parent 8884fa4 commit 2bba813

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC
66
3.x
77
===
88

9+
3.1.1
10+
-----
11+
12+
### Varnish Cache
13+
14+
* Fixed `banPath` to escape array of host names to be a correct regular expression.
15+
916
3.1.0
1017
-----
1118

src/ProxyClient/Varnish.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function banPath(string $path, ?string $contentType = null, array|string|
110110
if (!count($hosts)) {
111111
throw new InvalidArgumentException('Either supply a list of hosts or null, but not an empty array.');
112112
}
113-
$hosts = '^('.implode('|', $hosts).')$';
113+
$hosts = '^('.implode('|', array_map('preg_quote', $hosts)).')$';
114114
}
115115

116116
$headers = [

0 commit comments

Comments
 (0)