adobe / helix-importer

Foundation tools for importing website content into that can be consumed in an Helix project.
Apache License 2.0
9 stars 18 forks source link

complex background-image css value break the default import #360

Closed catalan-adobe closed 5 months ago

catalan-adobe commented 5 months ago

Description Following CSS

background-image: url(/sites/gsa.gov/themes/custom/gsa/dist/css/../img/../../custom_assets/images/airPlane.svg), linear-gradient(transparent, transparent);

breaks the import.

To Reproduce Steps to reproduce the behavior:

  1. Start latest Helix Importer UI (having rebuilt helix-importer in dev mode)
  2. Open web console
  3. Import https://www.gsa.gov/ with default script => In Web console:
    log.js:35 [importer-ui] Error importing http://localhost:3001/?host=https%3A%2F%2Fwww.gsa.gov: Invalid regular expression: /\(http://localhost:3001/sites/gsa\.gov/themes/custom/gsa/custom_assets/images/airPlane.svg, linear-gradient(rgba(0, 0, 0, 0, rgba(0, 0, 0, 0\)/gm: Unterminated group 
    SyntaxError: Invalid regular expression: /\(http://localhost:3001/sites/gsa\.gov/themes/custom/gsa/custom_assets/images/airPlane.svg, linear-gradient(rgba(0, 0, 0, 0, rgba(0, 0, 0, 0\)/gm: Unterminated group
    at new RegExp (<anonymous>)
    at MDUtils.replaceSrcInMarkdown (MDUtils.js:16:1)
    at PageImporter.js:186:19
    at Array.forEach (<anonymous>)
    at InternalImporter.createMarkdown (PageImporter.js:184:1)
    at async PageImporter.js:338:1
    at async Utils.asyncForEach (Utils.js:17:1)
    at async InternalImporter.import (PageImporter.js:336:1)
    at async html2x (HTML2x.js:167:1)
    at async PollImporter.transform (pollimporter.js:160:21)

DOMUtils.getImgFromBackground is not properly parsing such background-image value.

Expected behavior Default import should handle such case, eventually just getting rid of anything else that url(...) part of the value.

Version: 16.3.21

adobe-bot commented 5 months ago

:tada: This issue has been resolved in version 3.4.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: