-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
supports.html = false doesn't escape HTML (regression?) #13218
Comments
AFAIK, This option is not about HTML escaping, it's about enabling/disabling the HTML mode for this block. |
Oh, well I still believe the behavior has changed. I think all entities used to be escaped when stored in the database. Even if I'm remembering wrong, the |
Yes, probably. I believe I saw similar issues about HTML escaping. |
Closed #11624 in favor of this issue because it is more concise. Please see the screenshots at #11624 (comment). |
@designsimply okay, I don't think I'm going to be taken seriously anymore. thank you for remembering me:) |
The issue here may be the fact that the Code Block defines its var el = document.createElement( 'div' );
el.innerHTML = '<code>chicken > ribs</code>';
el.firstChild.textContent;
// "chicken > ribs"
el.firstChild.innerHTML;
// "chicken > ribs" |
i can determine which script this problem occurs because by comparing classic editor with gutenbeerg's html switch, classic editor is correct at present, only gutenberg is incorrect, but I can't modify the code directly because I am not competent and familiar with the new block editor. |
I don't believe so as it's being saved unescaped when it should be being escaped. Right now it's a weird mix of escaped and unescaped due to stuff like kses. |
i went through two kinds of editors: gutenberg and classic editor to compare articles published. obviously this only happens in the background editor. the front-end display is consistent. that is to say, it just happens between html/content switching, but this will cause problems. i think it is the pair of parentheses on the right that have not been escaped. this is usually caused by a js in the block editor when it is converted. it's missing a filter or an end, but tomorrow i'll have to concentrate on gutenberg code to locate it. i almost gave up on this issue, but when i saw the concern of so many officials and developers, i had new hope:) |
It may be a combination. I think another issue is that the Code block's gutenberg/packages/block-library/src/code/index.js Lines 70 to 72 in 8cce5f2
|
i noticed that only < transformed & lt; & transformed & amp; other transformations will not occur, so the problem is &. so which js is in control <pre-class="wp-block-code"> <! - / wp: code - >' and maybe this here: gutenberg/bin/generate-public-grammar.js Lines 8 to 15 in 8cce5f2
gutenberg/packages/escape-html/src/index.js Lines 28 to 30 in 8cce5f2
|
Hi, I waited to update to Gutenberg until Wordpress 5.1 hoping it would work, now my entire coding blog is broken and the code is all invalid! I use SyntaxHighlighter Evolved, the author of the plugin says the fix is needed in core, can anyone tell me when this will work again or how I can fix it... bit of a nightmare. THANKS. |
Hi,David |
for anyone following up on this issue, The author of the issue, Viper007Bond or alex, has died, you can follow his journey of fighting with cancer at https://alex.blog/ |
i was very depressed to hear that. i suddenly did not know the direction. our great plug-in author worked hard until the last moment of his life. i came too late. i was very sad. i should have solved this problem earlier, but i didn't! |
I am so sorry to hear about Viper007Bond, amazing that he kept on working on the plugin, a true coder. Please see Automattic/syntaxhighlighter#98 (comment) for a temporary workaround/solution. |
Sorry to hear that about Alex 😔 I am using his "Regenerate Thumbnails" quite often... Wrapping the code with "code" blocks:
...seems to work well now. |
The original issue was meant to have been resolved with #13996 (for the code block). However, in repeating the test case from the original comment (Step 2 of "To Reproduce"), it seems that a block can still become invalidated after reloading the page. I think it's specifically related to cases where the author manually escapes their own entities. Automatic escaping from #13996 seems to work well enough. cc @davilera
This is a separate question to the original issue. I think this escaping will always be expected to avoid dealing with complexities of the ampersand (related resource). In any case, it would be for its own issue if you'd like to create one. The scope of this one is targeting the code block. As previously mentioned, the |
I guess the question is: should code blocks show the same characters the user typed (that is, if they wrote In personally agree with @aduth. Code blocks should respect code as written, which means that there shouldn't be any transformations like shortcode or embed processing. But I'd go a step further and say that written HTML entities should also be shown as written. If you want to write HTML entities, then use an HTML block. Otherwise, the chars you type are the chars that should be shown. Does this make sense? What do you think? |
Yes, I agree with this. The problem is: Currently a block becomes marked as invalid the next time you edit (repeating the steps from the original comment). |
I see. I think the problem comes down to how the block is parsed for re-editing: it's probably using |
@aduth, I just created a PR for this issue. Unfortunately, it introduces a breaking change (a test does not pass, now). And I didn't have time to include any new tests... I will when I have the time, but it'd be great if someone could please review it. |
i don't have much ability to test this problem after every new version of wp updates, but it still exists. my intuition tells me that the escape is hidden in a deep js or symbol. the only way to solve it is to compare the escape methods of gutenberg and classic editor. but i can't do this. track to the specific escape function, because i have tried many times to find, but i failed. |
This is still broken :( |
supports.html = false
doesn't seem to work anymore. I swear it used to escape HTML entities properly.To Reproduce
core/code
block.Expected behavior
Code content should stay the same. It does initially but if you edit the post again, there's raw
<
in the source and things like<
have been converted to<
. The escaping of HTML hasn't been done.Should be something like this:
Desktop
Additional context
The text was updated successfully, but these errors were encountered: