Skip to content

Commit

Permalink
Support dot followed by space in directories (#16578)
Browse files Browse the repository at this point in the history
### What does it do?
Refined regex in Browser class to allow dot-space (e.g., `1. Folder
Name`) within directory, but not when directory/file begins with a dot
(e.g., .htaccess, .hidden-dir, etc).

### Why is it needed?
Responding to community member request.

### How to test
Create various directories and files with dot(s) and space(s) within to
verify desired behavior.

### Related issue(s)/PR(s)
Resolves #16351
  • Loading branch information
smg6511 authored Aug 29, 2024
1 parent 2faf7a8 commit 46d232e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/src/Revolution/Processors/Browser/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ public function sanitize($file)
{
$file = rawurldecode($file);
$file = strip_tags($file);
$file = preg_replace('#\.(?![\w\-\~])#u', '', $file);
$file = preg_replace('#\/{2,}#', '/', $file);
if (strpos($file, '.') === 0) {
$file = preg_replace('/^(\.)([\s\/]*)(.*)/', '$1$3', $file);
}
$file = preg_replace('/\.(?![\w\-\~\s])/u', '', $file);
$file = preg_replace('/\/{2,}/', '/', $file);
$file = strip_tags($file);

return $file;
Expand Down

0 comments on commit 46d232e

Please sign in to comment.