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

Paste: Omit <style> tags #10019

Merged
merged 3 commits into from Sep 20, 2018
Merged

Paste: Omit <style> tags #10019

merged 3 commits into from Sep 20, 2018

Conversation

@mcsf
Copy link
Contributor

@mcsf mcsf commented Sep 18, 2018

Description

Fixes #9719

How has this been tested?

  • Verify all block-conversion integration tests pass, including newly added ms-word-styled.
  • Try reproducing parent issue.
  • Stress-test pasting or classic-to-blocks conversion with whatever input.

Questions

  • Properly investigate the regression (this was seemingly working in 2.0), rather than "just fix" as I did.
  • Figure out if it's worth keeping a dedicated HTML.replace call to strip meta tags instead of relying on proper node processing.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
@mcsf mcsf added this to the 4.0 milestone Sep 18, 2018
@mcsf mcsf requested a review from ellatrix Sep 18, 2018
@mcsf mcsf force-pushed the fix/raw-handling-word-doc-style branch to 2467448 Sep 18, 2018
@@ -79,7 +80,7 @@ function getRawTransformations() {
*/
export default function rawHandler( { HTML = '', plainText = '', mode = 'AUTO', tagName, canUserUseUnfilteredHTML = false } ) {
// First of all, strip any meta tags.
HTML = HTML.replace( /<meta[^>]+>/, '' );
// HTML = HTML.replace( /<meta[^>]+>/, '' );

This comment has been minimized.

@ellatrix

ellatrix Sep 19, 2018
Member

This is still needed for internal paste (pasting blocks, which is handled right below).

This comment has been minimized.

@ellatrix

ellatrix Sep 19, 2018
Member

Maybe needs more comment.

This comment has been minimized.

@mcsf

mcsf Sep 19, 2018
Author Contributor

I did imagine it would affect the following pieces, but wanted to try this anyway. The tests still pass, so I think we need both comments and also some new tests that fail if this line is commented. Would you have some?

This comment has been minimized.

@ellatrix

ellatrix Sep 19, 2018
Member

Sure, I'll have a look.

This comment has been minimized.

@ellatrix

ellatrix Sep 20, 2018
Member

Pushed.

This comment has been minimized.

@mcsf

mcsf Sep 20, 2018
Author Contributor

Thanks!

export default function( node ) {
if (
node.nodeName !== 'META' &&
node.nodeName !== 'STYLE'

This comment has been minimized.

@ellatrix

ellatrix Sep 19, 2018
Member

Interesting that we stopped stripping these. Maybe this happened with the paste rewrite, but that was ages ago... If we want to continue with this fix, maybe it's not a bad idea to think about all HTML tags that should be stripped entirely (as opposed to unwrapped), like script etc.

This comment has been minimized.

@mcsf

mcsf Sep 19, 2018
Author Contributor

Yeah, script would be another one. I can’t see a use for just unwrapping them.

This comment has been minimized.

@ellatrix

ellatrix Sep 19, 2018
Member

I'd say script, style, noscript and template. meta is fine I think, it cannot have any child nodes. I wouldn't expect it in pasted HTML, but maybe it's prudent to strip head as well.

@@ -0,0 +1,12 @@
export default function( node ) {

This comment has been minimized.

@ellatrix

ellatrix Sep 20, 2018
Member

Just noting that, unlike the other filters, this has its own folder. Any reason why?

This comment has been minimized.

@mcsf

mcsf Sep 20, 2018
Author Contributor

Habit. :) I'll change for consistency.

mcsf and others added 3 commits Sep 18, 2018
- Input file for integration test `ms-word-styled` is a truncated
version of file provided by issue reporter. See
#9719 (comment)
@mcsf mcsf force-pushed the fix/raw-handling-word-doc-style branch from e6ed53e to 46c377a Sep 20, 2018
@mcsf mcsf merged commit 640eb98 into master Sep 20, 2018
2 checks passed
2 checks passed
codecov/project 48.67% (+0.01%) compared to 6e2caf1
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@ellatrix ellatrix deleted the fix/raw-handling-word-doc-style branch Sep 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.