Skip to content

Commit f799c07

Browse files
committed
[parser] store double-quoted strings correctly
1 parent 45d4cfa commit f799c07

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

lib/parser/pbxproj.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/parser/pbxproj.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ StringValue
190190
= QuotedString / LiteralString
191191

192192
QuotedString
193-
= DoubleQuote str:QuotedBody DoubleQuote { return str }
193+
= DoubleQuote str:QuotedBody DoubleQuote { return '"' + str + '"' }
194194

195195
QuotedBody
196196
= str:NonQuote+ { return str.join('') }
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 45;
7+
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
8+
objects = {
9+
/* Begin PBXVariantGroup section */
10+
1F766FDC13BBADB100FB74C0 /* Localizable.strings */ = {
11+
isa = PBXVariantGroup;
12+
children = (
13+
1F766FDD13BBADB100FB74C0 /* en */,
14+
);
15+
name = Localizable.strings;
16+
sourceTree = "<group>";
17+
};
18+
1F766FDF13BBADB100FB74C0 /* Localizable.strings */ = {
19+
isa = PBXVariantGroup;
20+
children = (
21+
1F766FE013BBADB100FB74C0 /* es */,
22+
);
23+
name = Localizable.strings;
24+
sourceTree = "<group>";
25+
};
26+
/* End PBXVariantGroup section */
27+
};
28+
}

test/parser/section-entries.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var PEG = require('pegjs'),
2+
fs = require('fs'),
3+
pbx = fs.readFileSync('test/parser/projects/section-entries.pbxproj', 'utf-8'),
4+
grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'),
5+
parser = PEG.buildParser(grammar),
6+
rawProj = parser.parse(pbx),
7+
project = rawProj.project;
8+
9+
exports['should have a PBXVariantGroup section'] = function (test) {
10+
test.ok(project.objects['PBXVariantGroup']);
11+
test.done();
12+
}
13+
14+
exports['should have two children for PBXVariantGroup'] = function (test) {
15+
test.ok(project.objects['PBXVariantGroup']['1F766FDF13BBADB100FB74C0']);
16+
test.ok(project.objects['PBXVariantGroup']['1F766FDC13BBADB100FB74C0']);
17+
test.done();
18+
}
19+
20+
exports['should store quote-surround values correctly'] = function (test) {
21+
var localizable = project.objects['PBXVariantGroup']['1F766FDF13BBADB100FB74C0'];
22+
23+
test.equal(localizable.sourceTree, '"<group>"');
24+
test.done();
25+
}

0 commit comments

Comments
 (0)