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: Pasting MsoListParagraph from MS Word throws an error #1682

Merged
merged 1 commit into from
Nov 30, 2021

Conversation

paddya
Copy link
Contributor

@paddya paddya commented Jul 14, 2021

Please check if the PR fulfills these requirements

  • It's the right issue type on the title
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • It does not introduce a breaking change or has a description of the breaking change

Description

My users tried to copy text from a rather convoluted Word document. The relevant HTML markup looks like this:

<p class=MsoListParagraph style='margin-left:11.15pt;text-indent:0cm;
line-height:9.05pt;mso-line-height-rule:exactly'><a name="OLE_LINK7"></a><a
name="OLE_LINK8"></a><a name="OLE_LINK11"></a><a name="OLE_LINK9"></a><a
name="OLE_LINK10"><span style='mso-bookmark:OLE_LINK9'><span style='mso-bookmark:
OLE_LINK11'><span style='mso-bookmark:OLE_LINK8'><span style='mso-bookmark:
OLE_LINK7'><b style='mso-bidi-font-weight:normal'><span style='font-size:9.0pt;
mso-bidi-font-size:11.0pt;font-family:"Arial",sans-serif;mso-bidi-font-family:
"Yu Gothic UI";background:aqua;mso-highlight:aqua;mso-ansi-language:DE'>Some
text </span></b></span></span></span></span></a><span style='mso-bookmark:OLE_LINK10'><span
style='mso-bookmark:OLE_LINK9'><span style='mso-bookmark:OLE_LINK11'><span
style='mso-bookmark:OLE_LINK8'><span style='mso-bookmark:OLE_LINK7'><b
style='mso-bidi-font-weight:normal'><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:"Arial",sans-serif;mso-bidi-font-family:"Yu Gothic UI";
color:#7030A0;mso-ansi-language:DE'>ABC</span></b></span></span></span></span></span><span
style='mso-bookmark:OLE_LINK10'><span style='mso-bookmark:OLE_LINK9'><span
style='mso-bookmark:OLE_LINK11'><span style='mso-bookmark:OLE_LINK8'><span
style='mso-bookmark:OLE_LINK7'><b style='mso-bidi-font-weight:normal'><span
style='font-size:9.0pt;mso-bidi-font-size:11.0pt;font-family:"Arial",sans-serif;
mso-bidi-font-family:"Yu Gothic UI";background:aqua;mso-highlight:aqua;
mso-ansi-language:DE'><o:p></o:p></span></b></span></span></span></span></span></p>

<span style='mso-bookmark:OLE_LINK9'></span><span style='mso-bookmark:OLE_LINK10'></span>

<p class=MsoBodyText style='margin-top:2.65pt;margin-right:25.3pt;margin-bottom:
0cm;margin-left:11.15pt;margin-bottom:.0001pt;line-height:68%'><span
style='mso-bookmark:OLE_LINK11'><span style='mso-bookmark:OLE_LINK8'><span
style='mso-bookmark:OLE_LINK7'><span style='letter-spacing:-.1pt;background:
aqua;mso-highlight:aqua;mso-font-width:105%;mso-ansi-language:DE'>More text</span></span></span></span><span
style='mso-bookmark:OLE_LINK11'><span style='mso-bookmark:OLE_LINK8'><span
style='mso-bookmark:OLE_LINK7'><span style='background:aqua;mso-highlight:aqua;
mso-ansi-language:DE'><o:p></o:p></span></span></span></span></p>

The problem here is that p.MsoListParagraph does not have the mso-list CSS property that is expected by createListItemDataFromParagraph:

function createListItemDataFromParagraph(para, index) {
const styleAttr = para.getAttribute('style');
const [, listItemInfo] = styleAttr.match(MSO_STYLE_LIST_RX);

The solution I came up with is to just not treat such elements as list elements. That avoids the error, but I'm not sure it is a proper solution.

This issue also seems to affect v3.x but I can't reproduce it because text copied from that Word document is inserted as a Base64-encoded image instead.

@js87zz
Copy link
Contributor

js87zz commented Aug 2, 2021

@paddya
I'm so sorry I haven't answered for a long time 🙏. I was busy with 3.x bug fixes and other projects. I will review this PR within this week. Thank you!!

@stale
Copy link

stale bot commented Sep 3, 2021

This issue has been automatically marked as inactive because there hasn’t been much going on it lately. It is going to be closed after 7 days. Thanks!

@stale stale bot added the inactive label Sep 3, 2021
@js87zz js87zz added Bug and removed inactive labels Sep 7, 2021
@js87zz js87zz merged commit 3163a91 into nhn:2.x Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants