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

Fix Markdown paste containing HTML #6298

Merged
merged 3 commits into from
Apr 20, 2018
Merged

Fix Markdown paste containing HTML #6298

merged 3 commits into from
Apr 20, 2018

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Apr 19, 2018

Description

This branch fixes the following issue: when pasting Markdown that contains any (unencoded) HTML, isPlain( HTML ) will stumble upon the tag and return false, skipping Markdown parsing and pasting the content inline. The solution here is to not pass any HTML at all to the rawHandler when no HTML has been pasted.

How has this been tested?

Paste any Markdown that contains HTML tags (which is valid Markdown). On the master branch this will not paste nicely (inline). On this branch the Markdown should be parsed and blocks should be inserted.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@ellatrix ellatrix requested a review from a team April 19, 2018 23:06
Copy link
Contributor

@mcsf mcsf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -54,7 +54,7 @@ export default function rawHandler( { HTML, plainText = '', mode = 'AUTO', tagNa
// Parse Markdown (and HTML) if:
// * There is a plain text version.
// * The HTML version has no formatting.
if ( plainText && isPlain( HTML ) ) {
if ( plainText && ( ! HTML || isPlain( HTML ) ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above needs updating.

@mcsf mcsf added this to the 2.8 milestone Apr 20, 2018
@ellatrix
Copy link
Member Author

Thanks for the quick review, @mcsf!

@ellatrix ellatrix merged commit eee9278 into master Apr 20, 2018
@ellatrix ellatrix deleted the fix/md-paste-html branch April 20, 2018 16:24
nuzzio pushed a commit to nuzzio/gutenberg that referenced this pull request Apr 25, 2018
* Fix Markdown paste containing HTML

* Add test case

* Update comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants