Closed Bug 1340145 Opened 3 years ago Closed 3 years ago

HTML-comments shouldn't be enabled for module-code

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla54
Tracking Status
firefox54 --- fixed

People

(Reporter: anba, Assigned: jonco)

References

Details

Attachments

(1 file, 1 obsolete file)

Test case:
---
print(JSON.stringify(Reflect.parse("a <!-- b", {target: "module", loc: false}), null, " "))
---

HTML-comments (https://tc39.github.io/ecma262/#sec-html-like-comments) shouldn't enabled when the parse goal is |Module|.


Expected parse tree:
---
{
 "loc": null,
 "type": "Program",
 "body": [
  {
   "loc": null,
   "type": "ExpressionStatement",
   "expression": {
    "loc": null,
    "type": "BinaryExpression",
    "operator": "<",
    "left": {
     "loc": null,
     "type": "Identifier",
     "name": "a"
    },
    "right": {
     "loc": null,
     "type": "UnaryExpression",
     "operator": "!",
     "argument": {
      "loc": null,
      "type": "UpdateExpression",
      "operator": "--",
      "argument": {
       "loc": null,
       "type": "Identifier",
       "name": "b"
      },
      "prefix": true
     },
     "prefix": true
    }
   }
  }
 ]
}
---

Actual parse tree:
---
{
 "loc": null,
 "type": "Program",
 "body": [
  {
   "loc": null,
   "type": "ExpressionStatement",
   "expression": {
    "loc": null,
    "type": "Identifier",
    "name": "a"
   }
  }
 ]
}
---
Attached patch bug1340145-module-comments (obsolete) — Splinter Review
Patch to make accepting HTML comments a compiler option.
Assignee: nobody → jcoppeard
Attachment #8839477 - Flags: review?(andrebargull)
Comment on attachment 8839477 [details] [diff] [review]
bug1340145-module-comments

Review of attachment 8839477 [details] [diff] [review]:
-----------------------------------------------------------------

We also need to disallow the html end-comment marker `-->` in https://dxr.mozilla.org/mozilla-central/rev/d0462b0948e0b1147dcce615bddcc46379bdadb2/js/src/frontend/TokenStream.cpp#1867-1874
Attachment #8839477 - Flags: review?(andrebargull) → review-
Fixed.
Attachment #8839477 - Attachment is obsolete: true
Attachment #8839500 - Flags: review?(andrebargull)
Comment on attachment 8839500 [details] [diff] [review]
bug1340145-module-comments v2

Review of attachment 8839500 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good!
Attachment #8839500 - Flags: review?(andrebargull) → review+
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/c7a4c2e34e6e
Don't allow HTML comments in module scripts r=anba
https://hg.mozilla.org/mozilla-central/rev/c7a4c2e34e6e
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in before you can comment on or make changes to this bug.