From 711c1619194da4b63ee3a9c0fa11b3a81d3808c0 Mon Sep 17 00:00:00 2001 From: Eli Skeggs Date: Sun, 21 Oct 2018 04:40:15 -0400 Subject: [PATCH] Forbid unicode in domain literals Per RFC 6531, the addition of unicode doesn't extend to domain literals. --- lib/parser.js | 4 ++-- test/tests.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/parser.js b/lib/parser.js index 4f63f5a..2f69cb5 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -314,7 +314,7 @@ class Parser { case '"': // End of quoted string - if (needBeQuoted || !this._normalizeUnnecessaryQuoted) { + if (needBeQuoted || !this._normalizeUnnecessaryQuoted || !string) { return `"${string}"`; } @@ -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; diff --git a/test/tests.json b/test/tests.json index 0926c52..3d2c60d 100644 --- a/test/tests.json +++ b/test/tests.json @@ -127,7 +127,7 @@ ["test@iana.org(comment\\)", "errUnclosedComment"], ["test@iana.org(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"],