BUG Fix incorrect backslash escaping in htaccess template

This commit is contained in:
Damian Mooyman 2016-09-22 16:29:58 +12:00
parent aa7a9565ce
commit 65ff0a4d38
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
2 changed files with 4 additions and 4 deletions

View File

@ -14,10 +14,10 @@
# Allow error pages
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule error[^\\/]*\.html$ - [L]
RewriteRule error[^\\\\/]*\\.html$ - [L]
# Block invalid file extensions
RewriteCond %{REQUEST_URI} !\.(?i:<% loop $AllowedExtensions %>$Extension<% if not $Last %>|<% end_if %><% end_loop %>)$
RewriteCond %{REQUEST_URI} !\\.(?i:<% loop $AllowedExtensions %>$Extension<% if not $Last %>|<% end_if %><% end_loop %>)$
RewriteRule .* - [F]
# Non existant files passed to requesthandler

View File

@ -44,14 +44,14 @@ class AssetAdapterTest extends SapphireTest {
$htaccess = $adapter->read('.htaccess');
$content = $htaccess['contents'];
// Allowed extensions set
$this->assertContains('RewriteCond %{REQUEST_URI} !.(?i:', $content);
$this->assertContains('RewriteCond %{REQUEST_URI} !\\.(?i:', $content);
foreach(File::config()->allowed_extensions as $extension) {
$this->assertRegExp('/\b'.preg_quote($extension).'\b/', $content);
}
// Rewrite rules
$this->assertContains('RewriteRule .* ../framework/main.php?url=%1 [QSA]', $content);
$this->assertContains('RewriteRule error[^\\/]*.html$ - [L]', $content);
$this->assertContains('RewriteRule error[^\\\\/]*\\.html$ - [L]', $content);
// Test flush restores invalid content
\file_put_contents($this->rootDir . '/.htaccess', '# broken content');