Skip to content
This repository was archived by the owner on Jan 14, 2022. It is now read-only.

Commit 8ced653

Browse files
authored
Merge pull request #87 from pwa-builder/ignore_shortcut_entries
Null hardening changes
2 parents adb657a + 67700d3 commit 8ced653

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

lib/manifestTools/validationRules/w3cManifestSchema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = function (manifestContent, callback) {
4040
});
4141
}
4242

43-
var member = err.dataPath.split('/').pop();
43+
var member = err.dataPath && typeof err.dataPath === "string" && err.dataPath.split('/').pop();
4444
if (err.code !== tv4.errorCodes.UNKNOWN_PROPERTY || (member && member.indexOf('_') < 0)) {
4545
validationResults.push({
4646
'description': message,

lib/processTools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var node_modules = 'node_modules';
1414

1515
function writeOutput(text, bufferedOutput, source, title) {
1616

17-
var lines = (title + bufferedOutput + text).split(/\r?\n/);
17+
var lines = ("" + title + bufferedOutput + text).split(/\r?\n/);
1818
bufferedOutput = lines.pop();
1919

2020
lines.forEach(function (line) {

lib/projectBuilder.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ function createApps(w3cManifestInfo, rootDir, platforms, options, href, callback
115115
}
116116
}
117117

118+
if (!w3cManifestInfo || !w3cManifestInfo.content) {
119+
return Q.reject(new Error("missing manifest information")).nodeify(callback);
120+
}
121+
118122
if (!href) {
119123
href = '/';
120124
}

lib/validations.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
'use strict';
22

33
var platformTools = require('./platformTools'),
44
manifestTools = require('./manifestTools');
@@ -36,13 +36,21 @@ function manifestFormatValid(format) {
3636
}
3737

3838
function isExpectedValidationError(errorResult) {
39-
const checkForPurposeList = errorResult.member.includes("icons") && errorResult.member.includes("purpose")
39+
if (!errorResult.member) {
40+
return false;
41+
}
42+
43+
const checkForPurposeList = errorResult.member.includes("icons") && errorResult.member.includes("purpose");
4044

4145
return checkForPurposeList
4246
}
4347

4448
function isExpectedCase(errorResult, w3cManifestInfo) {
45-
const errorParams = errorResult.member.split('/').slice(1) //example: /icons/0/purpose -> ['icons', '0', 'purpose']
49+
if (!errorResult.member) {
50+
return true;
51+
}
52+
53+
const errorParams = errorResult.member.split('/').slice(1); //example: /icons/0/purpose -> ['icons', '0', 'purpose']
4654
const isIconsPurpose = errorResult.member.includes("icons") && errorResult.member.includes("purpose");
4755
const isShortcuts = errorResult.member.includes("shortcuts");
4856
const isScreenshots = errorResult.member.includes("screenshots"); // in the case we need to extend it to screenshots as well...
@@ -52,13 +60,14 @@ function isExpectedCase(errorResult, w3cManifestInfo) {
5260
return true;
5361

5462
} else if (isIconsPurpose) {
55-
const [icons, index, purpose] = errorParams
63+
const [icons, index, purpose] = errorParams;
5664

5765
return w3cManifestInfo.content.icons
5866
&& w3cManifestInfo.content.icons[index]
67+
&& w3cManifestInfo.content.icons[index].purpose
5968
&& w3cManifestInfo.content.icons[index].purpose.split(" ").filter(entry => {
6069
return (entry === "any" || entry === "maskable" || entry === "monochrome");
61-
}).length > 0
70+
}).length > 0;
6271
}
6372

6473
return false;

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pwabuilder-lib",
3-
"version": "2.1.10",
3+
"version": "2.1.11",
44
"description": "PWA Builder Core Library",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)