-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow to use another RegExp Delimiter #2442
Labels
Comments
Note i see in PhpWord\Escaper\RegExp the following But:
|
I had similar issue with TemplateProcessor->setImageValue method. I had placeholders with $varsToReplace = array_filter($partVariables, function ($partVar) use ($searchString) {
return ($partVar == $searchString) || preg_match('/^' . preg_quote($searchString, '/') . ':/', $partVar);
}); and if (preg_match('/(<[^<]+>)([^<]*)(' . preg_quote($varNameWithArgsFixed, '/') . ')([^>]*)(<[^>]+>)/Uu', $partContent, $matches)) { I'm not sure about the consequences, so didn't dare to submit a PR with this, but probably might have someone. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
RegExp Delimiter appears to be hardcoded as /, whereas the Macro characters choice is free, and the blocks and variables name choice is free
Describe the solution you'd like
Add a class variable
private $regexp_delimiter = '/';
and report it in preg_xxx function
Then provide a function to manage it as a parameter.
This would allow to adapt the regexp parameter looking to the file content, ie not to have to manage to escape the slash, but to escape a generic parameter use for example preg_quote function
Note that also as setMacroChars function is Provided, a test could be set to be sure the slash is escaped if included in it (preg_quote is used quite everywhere, but not on cloneBlock and replaceBlock).
Describe alternatives you've considered
1 -Forbid the slash in the block and variables
OR
2 - Escape the slash in all the data that is provided to preg_xxx functions
Additional context
The text was updated successfully, but these errors were encountered: