Skip to content

Commit

Permalink
Include all whitespace when removing matched option
Browse files Browse the repository at this point in the history
Previously, only space was considered. This caused error when the
nspages tag spanned multiple lines and there was no trailing space
before the newline.

Fixes gturri#153
  • Loading branch information
dregad committed Sep 15, 2023
1 parent 2e0d0f3 commit a7bc940
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion optionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ static private function preg_match_all_wrapper($pattern, $subject, &$matches){

static private function _removeFromMatch($matched, $match){
$matched = trim($matched); // to handle the case of the option "-r" which already matches an extra whitespace
return substr(str_replace($matched.' ', ' ', $match.' '), 0, -1);
// Matched option including any leading and trailing whitespace
$regex = '/\s*' . preg_quote($matched, '/') . '\s*/';
return preg_replace($regex, ' ', $match);
}
}

0 comments on commit a7bc940

Please sign in to comment.