-
Notifications
You must be signed in to change notification settings - Fork 846
Blogging prompts: Refinements #27557
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
|
Are you an Automattician? You can now test your Pull Request on WordPress.com. On your sandbox, run |
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
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.
Comment on line 75 is the only one preventing me giving an approval. The others are optional as far as I'm concerned or are just for discussion.
|
|
||
| $blog_id = \Jetpack_Options::get_option( 'id' ); | ||
| $path = '/sites/' . $blog_id . '/blogging-prompts?from=' . $day_before . '&number=10&_locale=' . $locale; | ||
| $path = rawurldecode( '/sites/' . $blog_id . '/blogging-prompts?from=' . $day_before . '&number=10&_locale=' . $locale ); |
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.
Wrong function, and the right function won't do the right thing as you're doing it here.
| $path = rawurldecode( '/sites/' . $blog_id . '/blogging-prompts?from=' . $day_before . '&number=10&_locale=' . $locale ); | |
| $path = '/sites/' . rawurlencode( $blog_id ) . '/blogging-prompts?from=' . rawurlencode( $day_before ) . '&number=10&_locale=' . rawurlencode( $locale ); |
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.
🤦🏼 Working too quickly on that one--thanks for the correction.
| wp_add_inline_script( 'jetpack-blocks-editor', 'var Jetpack_BloggingPrompts = JSON.parse( decodeURIComponent( "' . rawurlencode( $daily_prompts ) . '" ) );', 'before' ); | ||
| wp_add_inline_script( | ||
| 'jetpack-blocks-editor', | ||
| 'var Jetpack_BloggingPrompts = ' . wp_json_encode( $daily_prompts, JSON_HEX_TAG ) . ';', |
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.
If you want to be extra safe
| 'var Jetpack_BloggingPrompts = ' . wp_json_encode( $daily_prompts, JSON_HEX_TAG ) . ';', | |
| 'var Jetpack_BloggingPrompts = ' . wp_json_encode( $daily_prompts, JSON_HEX_TAG | JSON_HEX_AMP ) . ';', |
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.
Nice!
| */ | ||
| function jetpack_setup_blogging_prompt_response( $post_id ) { | ||
| // phpcs:ignore WordPress.Security.NonceVerification.Recommended | ||
| // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Clicking a prompt response link can happen from notifications, Calypso, wp-admin, etc and only setups up a response post (tag, meta, prompt text); the user must take action to actually publish the post. |
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.
Should we worry about the list of "draft" posts getting filled up by an attacker?
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's a fair question! In practice, I'm personally not worried--it seems like a lot of effort (or patience) to get a user to open the answer_prompt link enough times to be concerning. I think there are probably easier and lower effort attacks.
For me the desire to make answering a writing prompt as seamless as possible from multiple contexts outweighs the (arguably) minimal security benefit of a nonce in this particular case.
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.
Fair enough. I don't know enough about this to second-guess the decision, I just wanted to confirm that the decision was made with relevant factors having been considered.
|
FYI, I'm attempting to move the mag16 locale logic to wpcom here: D93225-code |
Addresses feedback from #26680 (review)
Changes proposed in this Pull Request:
Other information:
Jetpack product discussion
See #26680 for context
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
No user facing changes from #26680. Testing instructions from that PR
Jetpack Site
define( 'JETPACK_EXPERIMENTAL_BLOCKS', true )(or Settings > Jetpack Constants if you're using jurassic.ninja)site_intentoption towriteanswer_promptquery param with the prompt id for today as the value (e.g./wp-admin/post-new.php?answer_prompt=2130), and you should see a writing prompt as a pullquote block, the tagdailypromptadded to the post, and the_jetpack_blogging_prompt_keypost meta set to the prompt id.Simple Site
bin/jetpack-downloader test jetpack try/paragraph-block-writing-prompts