Parser: Allow empty attributes in default parsers #11690
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since the introduction of the default parser in #8083 we have had a
subtle bug in the parsing which failed when empty attributes were
specified in a block's comment delimiter -
{}
The absense of attributes was fine but empty attributes were a
failure. This is due to using
+?
in the RegExp tokenizer instead ofusing
*?
(which allows for no inner content in the JSON string).This patch updates the quantifier to restore functionality and fix the
bug. This didn't appear in practice because we don't intentionally set
{}
as the attributes - the serializer drops it altogther, and ourtests didn't catch it for similar reasons.
Testing
Open up a post with the code editor.
Enter
<!-- wp:test {} /-->
and see if it breaks.If it breaks, once you hit
Save Draft
it will replace it with<p><!-- wp:test {} /--></p>
If it's working, you won't see it change on
Save Draft
Checklist: