Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Forbid unicode in domain literals
Browse files Browse the repository at this point in the history
Per RFC 6531, the addition of unicode doesn't extend to domain literals.
  • Loading branch information
skeggse committed Oct 21, 2018
1 parent e65460a commit 711c161
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class Parser {

case '"':
// End of quoted string
if (needBeQuoted || !this._normalizeUnnecessaryQuoted) {
if (needBeQuoted || !this._normalizeUnnecessaryQuoted || !string) {
return `"${string}"`;
}

Expand Down Expand Up @@ -848,7 +848,7 @@ class Parser {
const code = rune.codePointAt(0);

// '\r', '\n', ' ', and '\t' have already been parsed above
if ((code !== 127 && internals.c1Controls(code)) || code === 0 || rune === '[') {
if ((code !== 127 && internals.c1Controls(code)) || code === 0 || code > 127 || rune === '[') {
// Fatal error
this.diagnose(Constants.diagnoses.errExpectingDTEXT);
break;
Expand Down
2 changes: 1 addition & 1 deletion test/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
["[email protected](comment\\)", "errUnclosedComment"],
["[email protected](comment\\", "errBackslashEnd"],
["test@[RFC-5322-domain-literal]", "rfc5322DomainLiteral"],
["test@[RFC-5322-郵件ñó-domain-literal]", "rfc5322DomainLiteral"],
["test@[RFC-5322-郵件ñó-domain-literal]", "errExpectingDTEXT"],
["test@[RFC-5322]-domain-literal]", "errATEXTAfterDomainLiteral"],
["test@[RFC-5322].domain-literal]", "errDotAfterDomainLiteral"],
["test@[RFC-5322-[domain-literal]", "errExpectingDTEXT"],
Expand Down

0 comments on commit 711c161

Please sign in to comment.