-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Block Theme Previews: Add a nonce for activation #4795
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
Changes from 1 commit
d01393e
b06bdb3
2041820
0cdfdc9
af5e72c
c8deaf4
e7e4ce2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Co-authored-by: Peter Wilson <[email protected]>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -68,9 +68,9 @@ function wp_attach_theme_preview_middleware() { | |||||
| function wp_block_theme_activate_nonce() { | ||||||
| $nonce_handle = 'switch-theme_' . wp_get_theme_preview_path(); | ||||||
| ?> | ||||||
| <script type="text/javascript"> | ||||||
| window.BLOCK_THEME_ACTIVATE_NONCE = '<?php echo wp_create_nonce( $nonce_handle ); ?>'; | ||||||
| </script> | ||||||
| <script type="text/javascript"> | ||||||
| window.WP_BLOCK_THEME_ACTIVATE_NONCE = '<?php echo wp_create_nonce( $nonce_handle ); ?>'; | ||||||
|
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. This could potentially be a security issue. Is there a specific reason for not escaping the nonce value?
Suggested change
Contributor
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. Good catch @anton-vlasenko -- it's more a bug than a security issue as it's not user input, however it may break with custom nonce implementations using special characters. It will need to change to I'll reopen the ticket and add a PR to the GB repo. 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. Thank you for getting back to my code review, @peterwilsoncc! Yes, using |
||||||
| </script> | ||||||
| <?php | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
Nitpick: I don't see many PHP frameworks using inline tags to output text these days. Instead, I would use
echoorprintto output the nonce code to the buffer. But I admit, this is just a personal preference.