FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Cannot parse slashes in unquoted attribute values · Issue #36932 · angular/angular · GitHub

Cannot parse slashes in unquoted attribute values #36932

Description

🐞 bug report

Affected Package

The issue is caused by package @angular/compiler.

Is this a regression?

No.

Description

Context: prettier#14, prettier/prettier#8210

According to the HTML spec:

The attribute name, followed by zero or more ASCII whitespace, followed by a single U+003D EQUALS SIGN character, followed by zero or more ASCII whitespace, followed by the attribute value, which, in addition to the requirements given above for attribute values, must not contain any literal ASCII whitespace, any U+0022 QUOTATION MARK characters ("), U+0027 APOSTROPHE characters ('), U+003D EQUALS SIGN characters (=), U+003C LESS-THAN SIGN characters (<), U+003E GREATER-THAN SIGN characters (>), or U+0060 GRAVE ACCENT characters (`), and must not be the empty string.

U+002F SLASH characters (/) are valid unquoted attribute values, but the parser treat them as end signals:

this._beginToken(TokenType.ATTR_VALUE);
const valueStart = this._cursor.clone();
this._requireCharCodeUntilFn(isNameEnd, 1);
value = this._cursor.getChars(valueStart);
this._endToken([this._processCarriageReturns(value)]);

function isNameEnd(code: number): boolean {
return chars.isWhitespace(code) || code === chars.$GT || code === chars.$SLASH ||
code === chars.$SQ || code === chars.$DQ || code === chars.$EQ;
}

🔬 Minimal Reproduction

const {parseTemplate} = require("@angular/compiler");
const ast = parseTemplate("<a href=https://angular.io/>Link</a>");
console.log(ast.errors); //=> Unexpected closing tag "a".

🔥 Exception or Error

Unexpected closing tag "a". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags

🌍 Your Environment

Angular Version:

@angular/compiler@9.1.4

Anything else relevant?

No.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussionarea: compilerIssues related to `ngc`, Angular's template compilercompiler: parserstate: confirmedtype: bug/fix

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL