Feature(challenges): add code-uri utils
Fix(nav): points nav item propTypes
This commit is contained in:
@@ -1,42 +1,17 @@
|
||||
import { compose } from 'redux';
|
||||
import flow from 'lodash/flow';
|
||||
import { bonfire, html, js } from '../../utils/challengeTypes';
|
||||
import { decodeScriptTags } from '../../../utils/encode-decode';
|
||||
import protect from '../../utils/empty-protector';
|
||||
|
||||
export function encodeScriptTags(value) {
|
||||
return value
|
||||
.replace(/<script>/gi, 'fccss')
|
||||
.replace(/<\/script>/gi, 'fcces');
|
||||
}
|
||||
|
||||
export function decodeSafeTags(value) {
|
||||
return value
|
||||
.replace(/fccss/gi, '<script>')
|
||||
.replace(/fcces/gi, '</script>');
|
||||
}
|
||||
|
||||
export function encodeFormAction(value) {
|
||||
return value.replace(
|
||||
/<form[^>]*>/,
|
||||
val => val.replace(/action(\s*?)=/, 'fccfaa$1=')
|
||||
);
|
||||
}
|
||||
|
||||
export function decodeFccfaaAttr(value) {
|
||||
return value.replace(
|
||||
/<form[^>]*>/,
|
||||
val => val.replace(/fccfaa(\s*?)=/, 'action$1=')
|
||||
);
|
||||
}
|
||||
|
||||
export function arrayToString(seedData = ['']) {
|
||||
seedData = Array.isArray(seedData) ? seedData : [seedData];
|
||||
return seedData.reduce((seed, line) => '' + seed + line + '\n', '\n');
|
||||
}
|
||||
|
||||
export function buildSeed({ challengeSeed = [] } = {}) {
|
||||
return compose(
|
||||
decodeSafeTags,
|
||||
arrayToString
|
||||
return flow(
|
||||
arrayToString,
|
||||
decodeScriptTags
|
||||
)(challengeSeed);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user