-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Now MetaDataFilter takess also regexp. For example whern you want to #507
Changes from all commits
9b8db62
a813dd5
688a4ec
33a12ad
b9f75f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,16 @@ public function accept() | |
$metadata = $it->current(); | ||
|
||
foreach ($this->filter as $filter) { | ||
if (strpos($metadata->name, $filter) !== false) { | ||
$pregResult = preg_match("/" . preg_quote($filter) . "/", $metadata->name); | ||
if ($pregResult === false) { | ||
return false; | ||
} | ||
|
||
if ($pregResult === 0) { | ||
return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you return false for both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know. There was one sugestiin that it should be treated diferently. My open question was: should I twrow an exception when error occurs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, please, Exception makes sense |
||
} | ||
|
||
if ($pregResult) { | ||
return true; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot use preg_qoute here, if you do so,
$filter
will not be treated as a regular expression (which was the intention of this pull request). And even if you do so, you still do not escape the delimiter, you would have to do this:preg_quote($filter, '/')
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true. I realized that after I pushed the code. Some unit test might be helpfull here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove the preg_quote()