How-to block crashes when content contains %
- [X] I've read and understood the contribution guidelines.
- [X] I've searched for any related issues and avoided creating a duplicate issue.
If you use a % in a how-to block, then the JSON gets invalid. Resulting in console errors and you can't edit the article in WordPress anymore.
Please describe what you expected to happen and why.
Should be able to edit the article
How can we reproduce this behavior?
- Create a new article in WordPress
- Add a How to block to it
- In one of the blocks, write the following content %appdata%
- Publish the article. Now you can't edit the article anymore.
Technical info
Relevant errors: Invalid argument supplied for foreach() in D:\Dev\wpdev\wp-content\plugins\wordpress-seo\src\generators\schema\howto.php on line 61
In the editor: TypeError: Cannot read properties of undefined (reading 'map')
- If relevant, which editor is affected (or editors):
- [ ] Classic Editor
- [X] Gutenberg
- [ ] Classic Editor plugin
- Which browser is affected (or browsers):
- [X] Chrome
- [X] Firefox
- [X] Safari
- [ ] Other
Used versions
-
WordPress version: 5.9.3
-
Yoast SEO version: 18.9
-
Relevant plugins in case of a bug:
-
Tested with theme: GeneratePress and Twenty Twenty-Two
I am afraid the issue wasn't reproducible when following the instructions given in the steps you provided. No errors were shown when using the %appdata% in the Yoast SEO How-To block.
Sorry, indeed with only %appdata% it seems to work, however, when adding a \ behind the % seems to trigger the bug:
I have just tested it again with the Twenty Twenty-Two theme. %appdata% seems to work indeed (sorry about that), but changing it to the full path triggers the error:
Content of the step – Or press the Windows key + R – Type the path %appdata%\Microsoft\ and press Enter
The problem is in ending a field with a backslash (\). For some reason this tries to escape the ending quote in the JSON of the schema which breaks the editor (and the HowTo schema on the frontend). It doesn't look like the percent symbol is related to the issue.
Okay, so the only option is to remove the \ in this case? For the command, it doesn't matter in this case.
I am able to reproduce the issue and will mark it as a bug so the dev team can look into this further. Thank you for bringing this to our attention.