Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.createMessage = function (roomMember, text) {
text = ent.encode(text);
if (!text || !text.length) {
throw new InvalidInputError(); // block the trolls
}
else if (/^\/nick\s+/i.test(text)) {
return setUserNick(roomMember, text); // Change the current user's nick
}
else if (/^\/(away|afk|busy)/i.test(text)) {
return setUserBusy(roomMember, text); // away, afk, busy (with optional message)
}
else if (/^\/help/i.test(text)) {
return getHelp(roomMember, text);
}
else if (/^\/stats/i.test(text)) {
return stats(roomMember, text);
}
return callback(err);
}
// Check if we can update the main content metadata (displayName, description, ..)
opts = opts || {};
if (
opts.displayName &&
ctx.content.displayName === ctx.content.link &&
typeof opts.displayName === 'string'
) {
ctx.addContentMetadata('displayName', ent.decode(opts.displayName));
log().trace({ contentId: ctx.contentId }, 'Updating the content displayName.');
}
if (opts.description && !ctx.content.description && typeof opts.description === 'string') {
ctx.addContentMetadata('description', ent.decode(opts.description));
log().trace({ contentId: ctx.contentId }, 'Updating the content description.');
}
return callback();
});
};
const unescapeInlineHtml = (html) => {
let tmpHtml = html;
// find any inline HTML (as denoted by ```!inline-html [CODE] !inline-html```)
const regex = /<p><code>!inline-html\n[\s\S]*\n!inline-html<\/code><\/p>/;
const results = regex.exec(tmpHtml);
// we found inline HTML, unescape it and insert it into the parsed Markdown output
if (results && results.length > 0) {
const rawHtml = results[0].substring(21, results[0].length - 23);
const decodedHtml = ent.decode(rawHtml);
tmpHtml = tmpHtml.replace(regex, decodedHtml);
}
return tmpHtml;
};
</code></p>
self.htmlToPlaintext = function(html) {
// The awesomest HTML renderer ever (look out webkit):
// block element opening tags = newlines, closing tags and non-container tags just gone
html = html.replace(/<\/.*?\>/g, '');
html = html.replace(/<(h1|h2|h3|h4|h5|h6|p|br|blockquote).*?\>/gi, '\n');
html = html.replace(/<.*?\>/g, '');
return ent.decode(html);
};
convert: function (node, getVNodeKey) {
if (node.type === 'tag' || node.type === 'script' || node.type === 'style') {
return converter.convertTag(node, getVNodeKey);
} else if (node.type === 'text') {
return new VText(decode(node.data));
} else {
// converting an unsupported node, return an empty text node instead.
return new VText('');
}
},
convertTag: function (tag, getVNodeKey) {
.map(command => {
const signature =
typeof command === 'object'
? command.signature // Capitano
: capitanoizeOclifUsage(command.usage); // oclif
return `\t- [${ent.encode(signature)}](${getAnchor(signature)})`;
})
.join('\n'),
function generateTextCostSymbols(source) {
var tagged;
if (source !== undefined) {
// Get rid of / in any costs first, but only if inside {} brackets (so as not to affect +1/+1).
source = source.replace(/(\/)(?=\w\})/g,'');
// Then generate the tags through setting the innerHtml. This is the only way to preserve the text around the img tags.
// Encode the source in html, to prevent XSS nastiness. Then replace the newlines with <br>. Then insert the <img> tags.
tagged = <div>').replace(/\{([0-z,½,∞]+)\}/g, (fullMatch, firstMatch) =>
`<img height="12px/" src="./src/img/${firstMatch.toLowerCase()}.png">`
)}}></div>
}
return tagged;
}
renderer.br = function (text) {
var id = inlineIds++;
inlines[id] = React.createElement(options.br || 'br', {key: keys++}, ent.decode(text));
return '{$' + id + '$}';
};
this.response = errorBody.response;
try {
this.errors = JSON.parse(this.response.body).error.errors;
} catch (e) {}
var messages = [];
if (errorBody.message) {
messages.push(errorBody.message);
}
if (this.errors && this.errors.length === 1) {
messages.push(this.errors[0].message);
} else if (this.response && this.response.body) {
messages.push(ent.decode(errorBody.response.body.toString()));
} else if (!errorBody.message) {
messages.push('Error during request.');
}
this.message = uniq(messages).join(' - ');
});