Bug 1436790 - Update Fluent in Gecko to 0.6.2. r=Pike a=lizzard
authorZibi Braniecki <zbraniecki@mozilla.com>
Thu, 08 Feb 2018 10:59:29 -0800
changeset 454809 e61b91204cce35bc148e0bf6fa1e4bb537a51db0
parent 454808 5c4e1b96f6c92116ac6b9073934eb2961ff60ba4
child 454810 c891235f733c6ab19dd5a523232570ab804bba1b
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPike, lizzard
bugs1436790
milestone59.0
Bug 1436790 - Update Fluent in Gecko to 0.6.2. r=Pike a=lizzard MozReview-Commit-ID: BC2oTIGLips
intl/l10n/MessageContext.jsm
--- a/intl/l10n/MessageContext.jsm
+++ b/intl/l10n/MessageContext.jsm
@@ -90,17 +90,18 @@ class RuntimeParser {
       throw this.error(`Expected an entry to start
         at the beginning of the file or on a new line.`);
     }
 
     const ch = this._source[this._index];
 
     // We don't care about comments or sections at runtime
     if (ch === '/' ||
-      (ch === '#' && [' ', '#'].includes(this._source[this._index + 1]))) {
+      (ch === '#' &&
+        [' ', '#', '\n'].includes(this._source[this._index + 1]))) {
       this.skipComment();
       return;
     }
 
     if (ch === '[') {
       this.skipSection();
       return;
     }
@@ -355,17 +356,19 @@ class RuntimeParser {
       return this.getComplexPattern();
     }
 
     this._index = eol + 1;
 
     this.skipBlankLines();
 
     if (this._source[this._index] !== ' ') {
-      // No indentation means we're done with this message.
+      // No indentation means we're done with this message. Callers should check
+      // if the return value here is null. It may be OK for messages, but not OK
+      // for terms, attributes and variants.
       return firstLineContent;
     }
 
     const lineStart = this._index;
 
     this.skipInlineWS();
 
     if (this._source[this._index] === '.') {
@@ -774,16 +777,20 @@ class RuntimeParser {
         throw this.error('Expected "="');
       }
       this._index++;
 
       this.skipInlineWS();
 
       const val = this.getPattern();
 
+      if (val === null) {
+        throw this.error('Expected attribute to have a value');
+      }
+
       if (typeof val === 'string') {
         attrs[key] = val;
       } else {
         attrs[key] = {
           val
         };
       }
 
@@ -821,21 +828,23 @@ class RuntimeParser {
       }
 
       this._index++;
 
       const key = this.getVariantKey();
 
       this.skipInlineWS();
 
-      const variant = {
-        key,
-        val: this.getPattern()
-      };
-      variants[index++] = variant;
+      const val = this.getPattern();
+
+      if (val === null) {
+        throw this.error('Expected variant to have a value');
+      }
+
+      variants[index++] = {key, val};
 
       this.skipWS();
     }
 
     return [variants, defaultIndex];
   }
 
   /**