Skip to content

cssHash's hash() function may generate invalid CSS identifiers #6821

Open
@Bilge

Description

@Bilge

Describe the bug

cssHash: ({hash}) => hash('foo'), returns 2nhsez, which is an invalid CSS identifier since it starts with a number, unless the identifier is escaped, which Svelte does not do.

Reproduction

{
    test: /\.svelte$/,
    loader: 'svelte-loader',
    options: {
        compilerOptions: {
            cssHash: ({hash}) => hash('foo'),
        },
    },
},

Logs

No response

System Info

System:
    OS: Windows 10 10.0.18363
    CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
    Memory: 11.64 GB / 31.94 GB
  Binaries:
    Node: 14.15.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.9 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 94.0.4606.71
    Edge: Spartan (44.18362.1593.0)
    Internet Explorer: 11.0.18362.1766
  npmPackages:
    svelte: ^3.43.1 => 3.43.1
    webpack: ^5.11.0 => 5.53.0

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions