Comparing version 0.9.0 to 0.9.1
# Changelog | ||
## fluent 0.9.1 (October 23, 2018) | ||
- Forbid messages with `null` values and no attributes. (#299) | ||
Fix a parser behavior which caused it to parse messages without values | ||
nor attributes as `"message-id": null`. This skewed the return values of | ||
`FluentBundle.hasMessage` which would report `true` for messages which | ||
were `null`. This, in turn, would break code which assumed | ||
`FluentBundle.getMessage` would always return non-`null` values if it was | ||
guarded by a call to `hasMessage` first. | ||
## fluent 0.9.0 (October 23, 2018) | ||
@@ -4,0 +16,0 @@ |
@@ -1,2 +0,2 @@ | ||
/* fluent@0.9.0 */ | ||
/* fluent@0.9.1 */ | ||
(function (global, factory) { | ||
@@ -953,2 +953,6 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
if (attrs === null) { | ||
if (value === null) { | ||
throw new FluentError("Expected message value or attributes"); | ||
} | ||
return value; | ||
@@ -965,14 +969,15 @@ } | ||
let attrs = {}; | ||
let hasAttributes = false; | ||
while (test(RE_ATTRIBUTE_START)) { | ||
if (!hasAttributes) { | ||
hasAttributes = true; | ||
let name = match(RE_ATTRIBUTE_START); | ||
let value = parsePattern(); | ||
if (value === null) { | ||
throw new FluentError("Expected attribute value"); | ||
} | ||
let name = match(RE_ATTRIBUTE_START); | ||
attrs[name] = parsePattern(); | ||
attrs[name] = value; | ||
} | ||
return hasAttributes ? attrs : null; | ||
return Object.keys(attrs).length > 0 ? attrs : null; | ||
} | ||
@@ -1207,5 +1212,11 @@ | ||
cursor = RE_VARIANT_START.lastIndex; | ||
let value = parsePattern(); | ||
if (value === null) { | ||
throw new FluentError("Expected variant value"); | ||
} | ||
variants[count++] = { | ||
key, | ||
value: parsePattern() | ||
value | ||
}; | ||
@@ -1212,0 +1223,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/* fluent@0.9.0 */ | ||
/* fluent@0.9.1 */ | ||
(function (global, factory) { | ||
@@ -771,2 +771,5 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
if (attrs === null) { | ||
if (value === null) { | ||
throw new FluentError("Expected message value or attributes"); | ||
} | ||
return value; | ||
@@ -780,14 +783,13 @@ } | ||
let attrs = {}; | ||
let hasAttributes = false; | ||
while (test(RE_ATTRIBUTE_START)) { | ||
if (!hasAttributes) { | ||
hasAttributes = true; | ||
let name = match(RE_ATTRIBUTE_START); | ||
let value = parsePattern(); | ||
if (value === null) { | ||
throw new FluentError("Expected attribute value"); | ||
} | ||
let name = match(RE_ATTRIBUTE_START); | ||
attrs[name] = parsePattern(); | ||
attrs[name] = value; | ||
} | ||
return hasAttributes ? attrs : null; | ||
return Object.keys(attrs).length > 0 ? attrs : null; | ||
} | ||
@@ -982,3 +984,7 @@ | ||
cursor = RE_VARIANT_START.lastIndex; | ||
variants[count++] = {key, value: parsePattern()}; | ||
let value = parsePattern(); | ||
if (value === null) { | ||
throw new FluentError("Expected variant value"); | ||
} | ||
variants[count++] = {key, value}; | ||
} | ||
@@ -985,0 +991,0 @@ |
{ | ||
"name": "fluent", | ||
"description": "Localization library for expressive translations.", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"homepage": "http://projectfluent.org", | ||
@@ -6,0 +6,0 @@ "author": "Mozilla <l10n-drivers@mozilla.org>", |
@@ -153,2 +153,5 @@ import FluentError from "./error.js"; | ||
if (attrs === null) { | ||
if (value === null) { | ||
throw new FluentError("Expected message value or attributes"); | ||
} | ||
return value; | ||
@@ -162,14 +165,13 @@ } | ||
let attrs = {}; | ||
let hasAttributes = false; | ||
while (test(RE_ATTRIBUTE_START)) { | ||
if (!hasAttributes) { | ||
hasAttributes = true; | ||
let name = match(RE_ATTRIBUTE_START); | ||
let value = parsePattern(); | ||
if (value === null) { | ||
throw new FluentError("Expected attribute value"); | ||
} | ||
let name = match(RE_ATTRIBUTE_START); | ||
attrs[name] = parsePattern(); | ||
attrs[name] = value; | ||
} | ||
return hasAttributes ? attrs : null; | ||
return Object.keys(attrs).length > 0 ? attrs : null; | ||
} | ||
@@ -364,3 +366,7 @@ | ||
cursor = RE_VARIANT_START.lastIndex; | ||
variants[count++] = {key, value: parsePattern()}; | ||
let value = parsePattern(); | ||
if (value === null) { | ||
throw new FluentError("Expected variant value"); | ||
} | ||
variants[count++] = {key, value}; | ||
} | ||
@@ -367,0 +373,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
142917
3769