There have been instances where an author has managed to copy and paste inline styling from Word into our CMS, which then breaks Interweave SSR.
We are fixing this by sanitising pasted content in our CMS, but thought it might be worth documenting in case someone also runs into the following error:
SyntaxError: /([^;])+/i
at Object.module.exports [as default] (webpack://[REPO]/./node_modules/style-parser/index.js?:36:11)
at createStyleDeclaration (webpack://[REPO]/./node_modules/interweave-ssr/lib/index.js?:61:45)
at Object.createElement (webpack://[REPO]/./node_modules/interweave-ssr/lib/index.js?:117:23)
at Parser._insertElement (webpack://[REPO]/./node_modules/parse5/lib/parser/index.js?:559:42)
at bStartTagInBody (webpack://[REPO]/./node_modules/parse5/lib/parser/index.js?:1481:7)
at Object.startTagInBody [as START_TAG_TOKEN] (webpack://[REPO]/./node_modules/parse5/lib/parser/index.js?:1702:17)
at Parser._processToken (webpack://[REPO]/./node_modules/parse5/lib/parser/index.js?:657:55)
at Parser._processInputToken (webpack://[REPO]/./node_modules/parse5/lib/parser/index.js?:684:18)
at Parser._runParsingLoop (webpack://[REPO]/./node_modules/parse5/lib/parser/index.js?:440:18)
at Parser.parse (webpack://[REPO]/./node_modules/parse5/lib/parser/index.js?:344:14)
at Object.parse (webpack://[REPO]/./node_modules/parse5/lib/index.js?:10:19)
at parseHTML (webpack://[REPO]/./node_modules/interweave-ssr/lib/index.js?:140:17)
at Object.set (webpack://[REPO]/./node_modules/interweave-ssr/lib/index.js?:158:50)
at Parser.createContainer (webpack://[REPO]/./app/javascript/packs/server-bundle.ts_+_1359_modules?:19718:20)
at new Parser (webpack://[REPO]/./app/javascript/packs/server-bundle.ts_+_1359_modules?:19521:27)
at esm_Markup (webpack://[REPO]/./app/javascript/packs/server-bundle.ts_+_1359_modules?:20072:18)
This error is triggered when Interweave SSR tries to parse the inline styles, and one of the styles has a property but no value:
<p><em style="border: 0px solid rgb(229, 231, 235); color: ;"><b>I'm pasted from Word but missing the color value</b></em></p>
It would be ideal if we could handle the SyntaxError thrown in createStyleDeclaration in situations like this, so it fails more gracefully. For example, skipping the offending property and logging a warning.
There have been instances where an author has managed to copy and paste inline styling from Word into our CMS, which then breaks Interweave SSR.
We are fixing this by sanitising pasted content in our CMS, but thought it might be worth documenting in case someone also runs into the following error:
This error is triggered when Interweave SSR tries to parse the inline styles, and one of the styles has a property but no value:
<p><em style="border: 0px solid rgb(229, 231, 235); color: ;"><b>I'm pasted from Word but missing the color value</b></em></p>It would be ideal if we could handle the
SyntaxErrorthrown increateStyleDeclarationin situations like this, so it fails more gracefully. For example, skipping the offending property and logging a warning.