Bug 1436790 - Update Fluent in Gecko to 0.6.2. r=Pike
authorZibi Braniecki <zbraniecki@mozilla.com>
Thu, 08 Feb 2018 10:59:29 -0800
changeset 402995 0cd30c515243de41469c58335e95b2cb34d6c00a
parent 402994 366477a25fd7eeab9d3838ad6f1f223008ed0260
child 402996 4e2bf17f806d4451e4390dc5f6bd83daeca1b8ce
push id33408
push usercsabou@mozilla.com
push dateFri, 09 Feb 2018 00:28:58 +0000
treeherdermozilla-central@75f63c4d1ebc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPike
bugs1436790
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1436790 - Update Fluent in Gecko to 0.6.2. r=Pike 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];
   }
 
   /**