-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WebProfilerBundle] Fix regexp #12124
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
Conversation
@@ -45,7 +45,7 @@ public function getConfigTreeBuilder() | |||
->end() | |||
->end() | |||
->booleanNode('intercept_redirects')->defaultFalse()->end() | |||
->scalarNode('excluded_ajax_paths')->defaultValue('^/bundles|^/_wdt')->end() | |||
->scalarNode('excluded_ajax_paths')->defaultValue('^/(app(_[\\\w]+)?\\\.php/)?(bundles|_wdt)')->end() |
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.
why 3 backslashes ?
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.
Because PHP will escape one , and javascript the second \ for have \w.
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.
it seems wrong to have JS escaping here. The JS escaping should be done by the template when rendering the JS. The PHP string should not need to be aware of the fact that it will be used as JS. Escaping is always a responsibility of the rendering layer.
Is it better like this ? |
rather than - !url.match(new RegExp("{{ excluded_ajax_paths }}"))
+ !url.match(new RegExp({{ excluded_ajax_paths|json_encode }})) This will take care of encoding the string properly for JS |
It didn't worked for me. console.log(new RegExp("{{ excluded_ajax_paths|json_encode }}"));
// RegExp /"^\/(app(_[\w]+)?\.php\/)?(bundles|_wdt)"/ If I write |
hmm, the syntax error is probably related to an extra HTML escaping being applied on quotes, while we are not in an HTML context here |
fixed tests fixed regexp for php and js
Do you think that the escaping you should be done in JavaScript instead ? |
Would this work? - !url.match(new RegExp("{{ excluded_ajax_paths }}"))
+ !url.match(new RegExp({{ (excluded_ajax_paths|json_encode)|raw }})) The value is encoded with json_encode so its save, then marking its output as raw. |
It works 👍 |
I will recreate this PR based on 2.6 |
This PR was squashed before being merged into the 2.6 branch (closes #14217). Discussion ---------- [WebProfilerBundle] Fix regexp | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #12122 | License | MIT | Doc PR | Old PR #12124 Commits ------- 091b37e [WebProfilerBundle] Fix regexp
This PR was squashed before being merged into the 2.6 branch (closes symfony#14217). Discussion ---------- [WebProfilerBundle] Fix regexp | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#12122 | License | MIT | Doc PR | Old PR symfony#12124 Commits ------- 091b37e [WebProfilerBundle] Fix regexp
I fixed the regexp for don't see
/app_dev.php/_wdt
.