Skip to content

Commit 533d980

Browse files
committed
Parser fix, don't treat & as a separator.
1 parent 3255689 commit 533d980

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- New pattern: `pat-tabs`. See the relevant documentation.
1111
- Bugfix: `pat-validation` still validates removed clones from `pat-clone`.
1212
- Let the next-href option of pat-inject work as advertised.
13+
- Parser fix: don't treat `&` as a separator
1314
- #436 Remove `pat-bumper` restriction that scroll container must be the direct parent.
1415

1516
## 2.0.12 - Oct. 9, 2015

src/core/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ define([
229229

230230
_parseExtendedNotation: function argParserParseExtendedNotation(argstring) {
231231
var opts = {};
232-
var parts = argstring.replace(";;", "\xff").split(";")
232+
var parts = argstring.replace(";;", "\xff").replace("&", "&amp\xff").split(/;/)
233233
.map(function(el) { return el.replace("\xff", ";"); });
234234
_.each(parts, function (part, i) {
235235
if (!part) { return; }

tests/specs/core/parser.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,16 @@ define(["underscore", "pat-parser"], function(_, ArgumentParser) {
234234
expect(opts).toEqual({foo: "bar"});
235235
});
236236

237+
it("doesn't treat an escaped ampersand as a semicolon", function() {
238+
var parser=new ArgumentParser();
239+
parser.addArgument("foo");
240+
parser.addArgument("bar");
241+
parser.addArgument("baz");
242+
var opts = parser._parse("foo: one&bar: still one;baz: three");
243+
expect(opts).toEqual({foo: "one&bar: still one",
244+
baz: "three"});
245+
});
246+
237247
it("treats semicolons as escaped when duplicated", function() {
238248
var parser=new ArgumentParser();
239249
parser.addArgument("foo");

0 commit comments

Comments
 (0)