Skip to content

Invalid import URL causes infinite loop for operator-* rules #352

@mickyginger

Description

@mickyginger

Here is a reproduction of the issue:

const stylelint = require('stylelint');

stylelint
  .lint({
    code: `@import url('(https://example.com');`,
    config: {
      extends: ['stylelint-config-recommended-scss'],
      rules: {
        'scss/operator-no-newline-after': true,
        'scss/operator-no-newline-before': true,
        'scss/operator-no-unspaced': true,
      },
    },
  })
  .then((result) => {
    console.log(result);
  })
  .catch((error) => {
    console.log(error);
  });

The rules specified in config.rules cause the node process to consume >100% CPU resource. My guess is that stylelint is looking for a closing parenthesis for the erroneous one at the start of the URL string, and rather than throwing an error when it can't find it, ends up in an infinite loop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions