From 3f008d8870caaa822ccd20831e8e7ca23584b04e Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 4 Aug 2013 22:12:21 -0400 Subject: [PATCH] fix Varnish compatibility when characters such as * are in use for a boardname --- inc/functions.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 1dece172..fa9905e8 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -389,9 +389,12 @@ function purge($uri) { global $config, $debug; // Fix for Unicode - $uri = urlencode($uri); - $uri = str_replace("%2F", "/", $uri); - $uri = str_replace("%3A", ":", $uri); + $uri = rawurlencode($uri); + + $noescape = "/!~*()+:"; + $noescape = preg_split('//', $noescape); + $noescape_url = array_map("rawurlencode", $noescape); + $uri = str_replace($noescape_url, $noescape, $uri); if (preg_match($config['referer_match'], $config['root']) && isset($_SERVER['REQUEST_URI'])) { $uri = (str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) == '/' ? '/' : str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) . '/') . $uri;