Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • H html-validate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 23
    • Issues 23
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 8
    • Merge requests 8
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • html-validate
  • html-validate
  • Issues
  • #122
Closed
Open
Created Jun 28, 2021 by Zoltán Lehóczky@Piedone

"TypeError: Cannot read property 'trim' of undefined" exception

Html-validate 5.0.1 throws a "TypeError: Cannot read property 'trim' of undefined" exception when the markup contains an element whose style attribute ends with a space (including containing only one space).

Reduced test-case

<p style=" "></p>

This is in the following file, validated with html-validate source.html.

source.html

The above is the whole HTML used, i.e. the whole content of the file. The same exception happens in a more proper HTML document too:

<!DOCTYPE html>
<html>
<body>
<p style=" "></p>
</body>
</html>

Note that the exception still happens if the p tag is as follows (observe the space at the end of style:

<p style="text-align: justify; "></p>

Configuration

No custom configuration, just run html-validate source.html after a fresh npm install html-validate. The configuration output is as follows:

config.json

Expected result

Actual validation errors, like the ones showing after the offending space is removed ("1:4 error Inline style is not allowed no-inline-style").

Actual result

I get the following output:

html-validate source.html
Validator crashed when parsing "source.html"
Caught exception:
  TypeError: Cannot read property 'trim' of undefined
      at C:\Users\MyUser\AppData\Roaming\npm\node_modules\html-validate\dist\cjs\core.js:4242:58
      at Array.map (<anonymous>)
      at getCSSDeclarations (C:\Users\MyUser\AppData\Roaming\npm\node_modules\html-validate\dist\cjs\core.js:4240:10)
      at NoInlineStyle.allPropertiesAllowed (C:\Users\MyUser\AppData\Roaming\npm\node_modules\html-validate\dist\cjs\core.js:4333:30)
      at C:\Users\MyUser\AppData\Roaming\npm\node_modules\html-validate\dist\cjs\core.js:4302:22
      at C:\Users\MyUser\AppData\Roaming\npm\node_modules\html-validate\dist\cjs\core.js:1422:17
      at C:\Users\MyUser\AppData\Roaming\npm\node_modules\html-validate\dist\cjs\core.js:7951:22
      at Array.forEach (<anonymous>)
      at EventHandler.trigger (C:\Users\MyUser\AppData\Roaming\npm\node_modules\html-validate\dist\cjs\core.js:7950:19)
      at Parser.trigger (C:\Users\MyUser\AppData\Roaming\npm\node_modules\html-validate\dist\cjs\core.js:8430:20)
This is a bug in html-validate-5.0.1.
Please file a bug at https://gitlab.com/html-validate/html-validate/issues/new?issuable_template=Bug
and include this message in full and if possible the content of the
file being parsed (or a reduced testcase).

Version

  • html-validate: 5.0.1
  • html-validate-angular: not used
  • html-validate-vue: not used
  • html-validate-protractor: not used . any other relevant plugin: not used
Assignee
Assign to
Time tracking