Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Issues
  • #29741
Closed
Open
Issue created Nov 26, 2019 by Administrator@rootContributor

build/generate-sri.js doesn't work if single-quotes are used in config.yml

Created by: Noah2610

We use a fork of bootstrap for our design system, and we just noticed (and fixed) a bug regarding the build/generate-sri.js script. The script is supposed to replace all SRI hashes in config.yml, where the hashes are wrapped in " (double-quotes). In our project we use ' (single-quotes), and the script doesn't work correctly with single-quotes; it replaces ALL values wrapped in single-quotes, with each generated hash.

Our solution requires some regular expression tweaking: https://github.com/twbs/bootstrap/blob/master/build/generate-sri.js#L58

sh.sed(
  '-i',
  new RegExp(`(\\s*${file.configPropertyName}:\\s*("|\'))(\\S*)(("|\'))`),
  // NOTE: Using capture groups 1 and 4, because there are multiple,
  // smaller capture groups used, for the "|' or-ing to work properly.
  `$1${integrity}$4`,
  configFile
)

Here we wrap the "|' "or"-ing in capture groups, which fixes the issue. We then also need to adjust the used capture group number in the replacement part of the function call ($3 -> $4). (I also made the whitespace matching a bit more generous, using * instead of +, not sure if this is a good idea.)

I have not tested this extensively, but this fixes the issue for us. Somebody may want to look at this regular expression again, or use (a reviewed version of) our RegExp.

Tested on node.js versions:

  • v12.13.0
  • v10.15.3
Assignee
Assign to
Time tracking