@bbob/plugin-helper
Advanced tools
Comparing version 2.5.6 to 2.5.7
@@ -6,2 +6,13 @@ # Change Log | ||
## [2.5.7](https://github.com/JiLiZART/bbob/compare/v2.5.6...v2.5.7) (2020-07-05) | ||
### Bug Fixes | ||
* **html:** escape bad html ([#67](https://github.com/JiLiZART/bbob/issues/67)) ([87f38fe](https://github.com/JiLiZART/bbob/commit/87f38fe97ef7881be982b3d47c727cd280f1b057)) | ||
## [2.5.6](https://github.com/JiLiZART/bbob/compare/v2.5.5...v2.5.6) (2020-04-12) | ||
@@ -8,0 +19,0 @@ |
@@ -50,4 +50,5 @@ (function (global, factory) { | ||
var escapeQuote = function escapeQuote(value) { | ||
return value.replace(/"/g, '"'); | ||
var escapeHTML = function escapeHTML(value) { | ||
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') // eslint-disable-next-line no-script-url | ||
.replace('javascript:', 'javascript%3A'); | ||
}; | ||
@@ -72,6 +73,6 @@ /** | ||
string: function string() { | ||
return name + "=\"" + escapeQuote(value) + "\""; | ||
return name + "=\"" + escapeHTML(value) + "\""; | ||
}, | ||
object: function object() { | ||
return name + "=\"" + escapeQuote(JSON.stringify(value)) + "\""; | ||
return name + "=\"" + escapeHTML(JSON.stringify(value)) + "\""; | ||
} | ||
@@ -115,2 +116,3 @@ }; | ||
exports.attrsToString = attrsToString; | ||
exports.escapeHTML = escapeHTML; | ||
exports.getNodeLength = getNodeLength; | ||
@@ -117,0 +119,0 @@ exports.getUniqAttr = getUniqAttr; |
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).BbobPluginHelper={})}(this,(function(n){"use strict";var t=function(n){return"object"==typeof n&&!!n.tag},e=function(n){return"string"==typeof n},r=function(n){return n.replace(/"/g,""")},o=function(n,t){var e=typeof t,o={boolean:function(){return t?""+n:""},number:function(){return n+'="'+t+'"'},string:function(){return n+'="'+r(t)+'"'},object:function(){return n+'="'+r(JSON.stringify(t))+'"'}};return o[e]?o[e]():""};n.appendToNode=function(n,t){n.content.push(t)},n.attrValue=o,n.attrsToString=function(n){return void 0===n?"":Object.keys(n).reduce((function(t,e){return[].concat(t,[o(e,n[e])])}),[""]).join(" ")},n.getNodeLength=function n(r){return t(r)?r.content.reduce((function(t,e){return t+n(e)}),0):e(r)?r.length:0},n.getUniqAttr=function(n){return Object.keys(n).reduce((function(t,e){return n[e]===e?n[e]:null}),null)},n.isEOL=function(n){return"\n"===n},n.isStringNode=e,n.isTagNode=t,Object.defineProperty(n,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).BbobPluginHelper={})}(this,(function(e){"use strict";var n=function(e){return"object"==typeof e&&!!e.tag},t=function(e){return"string"==typeof e},r=function(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace("javascript:","javascript%3A")},o=function(e,n){var t=typeof n,o={boolean:function(){return n?""+e:""},number:function(){return e+'="'+n+'"'},string:function(){return e+'="'+r(n)+'"'},object:function(){return e+'="'+r(JSON.stringify(n))+'"'}};return o[t]?o[t]():""};e.appendToNode=function(e,n){e.content.push(n)},e.attrValue=o,e.attrsToString=function(e){return void 0===e?"":Object.keys(e).reduce((function(n,t){return[].concat(n,[o(t,e[t])])}),[""]).join(" ")},e.escapeHTML=r,e.getNodeLength=function e(r){return n(r)?r.content.reduce((function(n,t){return n+e(t)}),0):t(r)?r.length:0},e.getUniqAttr=function(e){return Object.keys(e).reduce((function(n,t){return e[t]===t?e[t]:null}),null)},e.isEOL=function(e){return"\n"===e},e.isStringNode=t,e.isTagNode=n,Object.defineProperty(e,"__esModule",{value:!0})})); |
"use strict"; | ||
exports.__esModule = true; | ||
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getUniqAttr = exports.getNodeLength = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0; | ||
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getUniqAttr = exports.getNodeLength = exports.escapeHTML = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0; | ||
@@ -51,3 +51,4 @@ var _char = require("./char"); | ||
var escapeQuote = value => value.replace(/"/g, '"'); | ||
var escapeHTML = value => value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') // eslint-disable-next-line no-script-url | ||
.replace('javascript:', 'javascript%3A'); | ||
/** | ||
@@ -61,2 +62,4 @@ * Acept name and value and return valid html5 attribute string | ||
exports.escapeHTML = escapeHTML; | ||
var attrValue = (name, value) => { | ||
@@ -67,4 +70,4 @@ var type = typeof value; | ||
number: () => name + "=\"" + value + "\"", | ||
string: () => name + "=\"" + escapeQuote(value) + "\"", | ||
object: () => name + "=\"" + escapeQuote(JSON.stringify(value)) + "\"" | ||
string: () => name + "=\"" + escapeHTML(value) + "\"", | ||
object: () => name + "=\"" + escapeHTML(JSON.stringify(value)) + "\"" | ||
}; | ||
@@ -71,0 +74,0 @@ return types[type] ? types[type]() : ''; |
"use strict"; | ||
exports.__esModule = true; | ||
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getUniqAttr = exports.getNodeLength = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0; | ||
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getUniqAttr = exports.getNodeLength = exports.escapeHTML = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0; | ||
@@ -59,4 +59,5 @@ var _char = require("./char"); | ||
var escapeQuote = function escapeQuote(value) { | ||
return value.replace(/"/g, '"'); | ||
var escapeHTML = function escapeHTML(value) { | ||
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') // eslint-disable-next-line no-script-url | ||
.replace('javascript:', 'javascript%3A'); | ||
}; | ||
@@ -71,2 +72,4 @@ /** | ||
exports.escapeHTML = escapeHTML; | ||
var attrValue = function attrValue(name, value) { | ||
@@ -82,6 +85,6 @@ var type = typeof value; | ||
string: function string() { | ||
return name + "=\"" + escapeQuote(value) + "\""; | ||
return name + "=\"" + escapeHTML(value) + "\""; | ||
}, | ||
object: function object() { | ||
return name + "=\"" + escapeQuote(JSON.stringify(value)) + "\""; | ||
return name + "=\"" + escapeHTML(JSON.stringify(value)) + "\""; | ||
} | ||
@@ -88,0 +91,0 @@ }; |
{ | ||
"name": "@bbob/plugin-helper", | ||
"version": "2.5.6", | ||
"version": "2.5.7", | ||
"description": "Set of utils to help write plugins for @bbob/core", | ||
@@ -57,3 +57,3 @@ "keywords": [ | ||
], | ||
"gitHead": "5af63e4158f252f901b76ba54cfa7f1bbc246ec8" | ||
"gitHead": "fe6a16b6d9850bdfe3569649583c9957bf8ebe9c" | ||
} |
@@ -30,3 +30,10 @@ import { N } from './char'; | ||
*/ | ||
const escapeQuote = (value) => value.replace(/"/g, '"'); | ||
const escapeHTML = (value) => value | ||
.replace(/&/g, '&') | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>') | ||
.replace(/"/g, '"') | ||
.replace(/'/g, ''') | ||
// eslint-disable-next-line no-script-url | ||
.replace('javascript:', 'javascript%3A'); | ||
@@ -45,4 +52,4 @@ /** | ||
number: () => `${name}="${value}"`, | ||
string: () => `${name}="${escapeQuote(value)}"`, | ||
object: () => `${name}="${escapeQuote(JSON.stringify(value))}"`, | ||
string: () => `${name}="${escapeHTML(value)}"`, | ||
object: () => `${name}="${escapeHTML(JSON.stringify(value))}"`, | ||
}; | ||
@@ -83,2 +90,3 @@ | ||
appendToNode, | ||
escapeHTML, | ||
getNodeLength, | ||
@@ -85,0 +93,0 @@ getUniqAttr, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27811
636