-
Notifications
You must be signed in to change notification settings - Fork 4.8k
RTC: Sanitize remote CRDT changes from untrusted contributors #77207
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
7c695c3
5b2604b
4d87b10
525e3ed
b311342
3c0517d
517aa69
e4f36cc
7f9d79c
ccc491d
4ba07d9
37a2a21
dfce851
2855189
1a38799
e459ac9
28f8815
f095565
ec9334f
d54d55f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,7 +221,8 @@ function gutenberg_inject_real_time_collaboration_setting() { | |
|
|
||
| wp_add_inline_script( | ||
| 'wp-core-data', | ||
| 'window._wpCollaborationEnabled = ' . wp_json_encode( $enabled ) . ';', | ||
| 'window._wpCollaborationEnabled = ' . wp_json_encode( $enabled ) . ';' . | ||
| 'window._wpCollaborationKsesHtml = ' . wp_json_encode( wp_kses_allowed_html( 'post' ) ) . ';', | ||
| 'after' | ||
| ); | ||
| } | ||
|
|
@@ -239,6 +240,35 @@ function gutenberg_set_collaboration_option_on_activation() { | |
| } | ||
| add_action( 'activate_gutenberg/gutenberg.php', 'gutenberg_set_collaboration_option_on_activation' ); | ||
|
|
||
| if ( ! function_exists( 'gutenberg_clear_sync_contributors_on_save' ) ) { | ||
| /** | ||
| * Clears the sync contributor tracking list when a post is saved. | ||
| * | ||
| * After a save, the content in the database is authoritative. The contributor | ||
| * list is reset so that the shared-permissions check starts fresh for | ||
| * subsequent collaborative edits. | ||
| * | ||
| * @param int $post_id Post ID. | ||
| * @param WP_Post $post Post object. | ||
| */ | ||
| function gutenberg_clear_sync_contributors_on_save( $post_id, $post ) { | ||
| if ( WP_Sync_Post_Meta_Storage::POST_TYPE === $post->post_type ) { | ||
| return; | ||
| } | ||
|
|
||
| if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) { | ||
| return; | ||
| } | ||
|
|
||
| $room = 'postType/' . $post->post_type . ':' . $post_id; | ||
| $storage = new WP_Sync_Post_Meta_Storage(); | ||
| if ( method_exists( $storage, 'clear_contributors' ) ) { | ||
| $storage->clear_contributors( $room ); | ||
| } | ||
| } | ||
| add_action( 'save_post', 'gutenberg_clear_sync_contributors_on_save', 10, 2 ); | ||
|
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. Are there any other actions we might want to clear out contributors for? Maybe on
Contributor
Author
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. Actually not sure on delete. I would think we might want to just leave the standard WP behavior there. |
||
| } | ||
|
|
||
| /** | ||
| * Modifies the post list UI and heartbeat responses for real-time collaboration. | ||
| * | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Maybe:
It might be helpful to keep window._wpCollaborationEnabled for a bit while wp-dev and gb get synced up with intent to remove.