Skip to content

Commit

Permalink
FIX: escape dangerous appName and appShortName in HTML.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchel Myers authored and andy128k committed Oct 21, 2021
1 parent c447d41 commit 7ac5abf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"dependencies": {
"clone": "^2.1.2",
"colors": "^1.4.0",
"escape-html": "^1.0.3",
"image-size": "^1.0.0",
"jsontoxml": "^1.0.1",
"lodash.defaultsdeep": "^4.6.1",
Expand Down
5 changes: 3 additions & 2 deletions src/config/html.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable */
const escapeHtml = require("escape-html");

const appleIconSizes = [57, 60, 72, 76, 114, 120, 144, 152, 167, 180, 1024];

Expand Down Expand Up @@ -283,13 +284,13 @@ module.exports = {
: `<link rel="manifest" href="${relative("manifest.json")}">`,
() => `<meta name="mobile-web-app-capable" content="yes">`,
({ theme_color, background }) => `<meta name="theme-color" content="${theme_color || background}">`,
({ appName }) => appName ? `<meta name="application-name" content="${appName}">` : `<meta name="application-name">`
({ appName }) => appName ? `<meta name="application-name" content="${escapeHtml(appName)}">` : `<meta name="application-name">`
],
appleIcon: [
...appleIconSizes.map(size => ctx => appleIconGen(size, ctx)),
() => `<meta name="apple-mobile-web-app-capable" content="yes">`,
({ appleStatusBarStyle }) => `<meta name="apple-mobile-web-app-status-bar-style" content="${appleStatusBarStyle}">`,
({ appShortName, appName }) => (appShortName || appName) ? `<meta name="apple-mobile-web-app-title" content="${appShortName || appName}">` : `<meta name="apple-mobile-web-app-title">`
({ appShortName, appName }) => (appShortName || appName) ? `<meta name="apple-mobile-web-app-title" content="${escapeHtml(appShortName || appName)}">` : `<meta name="apple-mobile-web-app-title">`
],
appleStartup: appleStartupItems.map(item => ctx => appleStartupGen(item, ctx)),
coast: coastSizes.map(size => ctx => coastGen(size, ctx)),
Expand Down

0 comments on commit 7ac5abf

Please sign in to comment.