Skip to content

Commit

Permalink
fix: added escaping of meta tag attribute value (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub-swierk authored and yyx990803 committed Apr 15, 2018
1 parent 5bcf914 commit 15a1ac8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = async function build (sourceDir, cliOptions = {}) {
const webpack = require('webpack')
const readline = require('readline')
const { promisify } = require('util')
const escape = require('escape-html')
const rimraf = promisify(require('rimraf'))
const mkdirp = promisify(require('mkdirp'))
const readFile = promisify(fs.readFile)
Expand Down Expand Up @@ -123,7 +124,7 @@ module.exports = async function build (sourceDir, cliOptions = {}) {
function renderAttrs (attrs = {}) {
const keys = Object.keys(attrs)
if (keys.length) {
return ' ' + keys.map(name => `${name}="${attrs[name]}"`).join(' ')
return ' ' + keys.map(name => `${name}="${escape(attrs[name])}"`).join(' ')
} else {
return ''
}
Expand Down Expand Up @@ -162,7 +163,7 @@ module.exports = async function build (sourceDir, cliOptions = {}) {
return meta.map(m => {
let res = `<meta`
Object.keys(m).forEach(key => {
res += ` ${key}="${m[key]}"`
res += ` ${key}="${escape(m[key])}"`
})
return res + `>`
}).join('')
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.11",
"es6-promise": "^4.2.4",
"escape-html": "^1.0.3",
"file-loader": "^1.1.11",
"globby": "^8.0.1",
"html-webpack-plugin": "^3.2.0",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ es6-promise@^4.2.4:
version "4.2.4"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29"

escape-html@~1.0.1:
escape-html@^1.0.3, escape-html@~1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"

Expand Down

0 comments on commit 15a1ac8

Please sign in to comment.