Skip to content
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

Functions hooked to the pre_term_description hook may corrupt json #2157

Closed
Tymvie opened this issue Apr 22, 2019 · 3 comments · Fixed by #2158
Closed

Functions hooked to the pre_term_description hook may corrupt json #2157

Tymvie opened this issue Apr 22, 2019 · 3 comments · Fixed by #2158
Labels
Bug Something isn't working
Milestone

Comments

@Tymvie
Copy link

Tymvie commented Apr 22, 2019

This warning occurs when viewing a validated URL in the admin:

PHP Warning:  ksort() expects parameter 1 to be array, null given in /wp-content/plugins/amp/includes/validation/class-amp-validation-error-taxonomy.php on line 418
PHP Stack trace:
PHP   1. {main}() /wp-admin/post.php:0
PHP   2. include() /wp-admin/post.php:197
PHP   3. do_action() /wp-admin/edit-form-advanced.php:540
PHP   4. WP_Hook->do_action() /wp-includes/plugin.php:465
PHP   5. WP_Hook->apply_filters() /wp-includes/class-wp-hook.php:310
PHP   6. AMP_Validated_URL_Post_Type::render_single_url_list_table() /wp-includes/class-wp-hook.php:286
PHP   7. WP_List_Table->display() /wp-content/plugins/amp/includes/validation/class-amp-validated-url-post-type.php:1877
PHP   8. WP_Terms_List_Table->display_rows_or_placeholder() /wp-admin/includes/class-wp-list-table.php:1175
PHP   9. WP_Terms_List_Table->single_row() /wp-admin/includes/class-wp-terms-list-table.php:257
PHP  10. WP_List_Table->single_row_columns() /wp-admin/includes/class-wp-terms-list-table.php:336
PHP  11. WP_Terms_List_Table->handle_row_actions() /wp-admin/includes/class-wp-list-table.php:1333
PHP  12. apply_filters() /wp-admin/includes/class-wp-terms-list-table.php:494
PHP  13. WP_Hook->apply_filters() /wp-includes/plugin.php:208
PHP  14. AMP_Validation_Error_Taxonomy::filter_tag_row_actions() /wp-includes/class-wp-hook.php:286
PHP  15. AMP_Validation_Error_Taxonomy::get_validation_error_sanitization() /wp-content/plugins/amp/includes/validation/class-amp-validation-error-taxonomy.php:1608
PHP  16. AMP_Validation_Error_Taxonomy::prepare_validation_error_taxonomy_term() /wp-content/plugins/amp/includes/validation/class-amp-validation-error-taxonomy.php:458
PHP  17. ksort() /wp-content/plugins/amp/includes/validation/class-amp-validation-error-taxonomy.php:418

To reproduce this, create a post that contains this code:

<script>
document.write( '<a href="#" target="_blank">test</a>' );
</script>

The json-encoded term description will be passed through the wp_targeted_link_rel function because the link contains the target attribute. As a result, the json will become corrupted

@Tymvie Tymvie changed the title Function hooked to the pre_term_description hook may corrupt json Functions hooked to the pre_term_description hook may corrupt json Apr 22, 2019
@westonruter
Copy link
Member

Thank you very much for reporting this. I can reproduce it.

@westonruter
Copy link
Member

westonruter commented Apr 22, 2019

@Tymvie Would you please test #2158? Note that you'll need to ensure that a new validation error is created, either by tweaking the text of your example above, or by resetting all validation error data via wp amp reset-site-validation --yes.

@Tymvie
Copy link
Author

Tymvie commented Apr 22, 2019

@westonruter it works, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
2 participants