Skip to content

Commit

Permalink
use regex and not variable to get all attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
wonknu committed Sep 27, 2016
1 parent 7620186 commit 0055e00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
8 changes: 4 additions & 4 deletions dist/cli/handlebars/abe/compileAbe.js
Expand Up @@ -43,13 +43,13 @@ function compileAbe() {
value = '';
}
if (typeof hash.type !== 'undefined' && hash.type !== null && hash.type === 'rich') {
var testXSS = (0, _xss2.default)(value.replace(/&quote;/g, "'"), {
var testXSS = (0, _xss2.default)(value.replace(/"/g, '"'), {
'whiteList': _.config.htmlWhiteList,
stripIgnoreTag: true
});
return new _handlebars2.default.SafeString(testXSS);
}
return value.replace(/%27/, '\'').replace(/&quote;/g, "'");
return value.replace(/%27/, '\'');
}

var key = arguments[0].hash['key'].replace('.', '-');
Expand All @@ -61,11 +61,11 @@ function compileAbe() {
}

if (typeof hash.type !== 'undefined' && hash.type !== null && hash.type === 'rich') {
var testXSS = (0, _xss2.default)(value.replace(/&quote;/g, "'"), {
var testXSS = (0, _xss2.default)(value.replace(/"/g, '"'), {
'whiteList': _.config.htmlWhiteList,
stripIgnoreTag: true
});
return new _handlebars2.default.SafeString(testXSS);
}
return value.replace(/%27/, '\'').replace(/&quote;/g, "'");
return value.replace(/%27/, '\'');
}
4 changes: 1 addition & 3 deletions dist/cli/helpers/abe-utils.js
Expand Up @@ -572,8 +572,6 @@ var Utils = function () {

//This regex analyzes all attributes of a Abe tag
var re = /\b([a-z][a-z0-9\-]*)\s*=\s*("([^"]+)"|'([^']+)'|(\S+))/ig;
var source = (0, _.getAttr)(str, 'source');
var key = (0, _.getAttr)(str, 'key');

var attrs = {
autocomplete: null,
Expand All @@ -600,7 +598,7 @@ var Utils = function () {
}

attrs.sourceString = attrs.source;
attrs.source = typeof source !== 'undefined' && source !== null && source !== '' ? typeof json[_.config.source.name] !== 'undefined' && json[_.config.source.name] !== null && json[_.config.source.name] !== '' ? json[_.config.source.name][key] : null : null;
attrs.source = typeof attrs.source !== 'undefined' && attrs.source !== null && attrs.source !== '' ? typeof json[_.config.source.name] !== 'undefined' && json[_.config.source.name] !== null && json[_.config.source.name] !== '' ? json[_.config.source.name][attrs.key] : null : null;
attrs.editable = typeof attrs.editable === 'undefined' || attrs.editable === null || attrs.editable === '' || attrs.editable === 'false' ? false : true;

attrs = _.Hooks.instance.trigger('afterAbeAttributes', attrs, str, json);
Expand Down
6 changes: 2 additions & 4 deletions src/cli/helpers/abe-utils.js
Expand Up @@ -546,8 +546,6 @@ export default class Utils {

//This regex analyzes all attributes of a Abe tag
var re = /\b([a-z][a-z0-9\-]*)\s*=\s*("([^"]+)"|'([^']+)'|(\S+))/ig
var source = getAttr(str, 'source')
var key = getAttr(str, 'key')

var attrs = {
autocomplete: null,
Expand All @@ -574,9 +572,9 @@ export default class Utils {
}

attrs.sourceString = attrs.source
attrs.source = (typeof source !== 'undefined' && source !== null && source !== '')?
attrs.source = (typeof attrs.source !== 'undefined' && attrs.source !== null && attrs.source !== '')?
((typeof json[config.source.name] !== 'undefined' && json[config.source.name] !== null && json[config.source.name] !== '')?
json[config.source.name][key] :
json[config.source.name][attrs.key] :
null
) :
null
Expand Down

0 comments on commit 0055e00

Please sign in to comment.