From 64fd7ae4546424c42a9e2022e05b83379411109a Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 9 Jun 2019 22:35:15 -0400 Subject: 1339963 - Part 3: Check IdentifierName in ExportClause without from. --- js/src/frontend/Parser.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'js/src/frontend/Parser.cpp') diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index f382ec5e9..ffece5721 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -5124,6 +5124,31 @@ Parser::exportBatch(uint32_t begin) return exportFrom(begin, kid); } +template<> +bool +Parser::checkLocalExportNames(ParseNode* node) +{ + // ES 2017 draft 15.2.3.1. + for (ParseNode* next = node->pn_head; next; next = next->pn_next) { + ParseNode* name = next->pn_left; + MOZ_ASSERT(name->isKind(PNK_NAME)); + + RootedPropertyName ident(context, name->pn_atom->asPropertyName()); + if (!checkLocalExportName(ident, name->pn_pos.begin)) + return false; + } + + return true; +} + +template<> +bool +Parser::checkLocalExportNames(Node node) +{ + MOZ_ALWAYS_FALSE(abortIfSyntaxParser()); + return false; +} + template typename ParseHandler::Node Parser::exportClause(uint32_t begin) @@ -5211,6 +5236,9 @@ Parser::exportClause(uint32_t begin) if (!matchOrInsertSemicolonAfterNonExpression()) return null(); + if (!checkLocalExportNames(kid)) + return null(); + Node node = handler.newExportDeclaration(kid, TokenPos(begin, pos().end)); if (!node) return null(); -- cgit v1.2.3