Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function postProcess(_text, namedValues, params, count) {
let text = _text;
// test for parsable interval string
if (/\|/.test(text)) {
text = parsePluralInterval(text, count);
}
// replace the counter
if (typeof count == 'number') {
text = vsprintf(text, [parseInt(count, 10)]);
}
// if the text string contains {{Mustache}} patterns we render it as a mini tempalate
if (/\{\{.*\}\}/.test(text)) {
text = Mustache.render(text, namedValues);
}
// if we have extra arguments with values to get replaced,
// an additional substition injects those strings afterwards
if (/%/.test(text) && params.length) {
text = vsprintf(text, params);
}
return text;
}
}
// replace the counter
if (typeof count == 'number') {
text = vsprintf(text, [parseInt(count, 10)]);
}
// if the text string contains {{Mustache}} patterns we render it as a mini tempalate
if (/\{\{.*\}\}/.test(text)) {
text = Mustache.render(text, namedValues);
}
// if we have extra arguments with values to get replaced,
// an additional substition injects those strings afterwards
if (/%/.test(text) && params.length) {
text = vsprintf(text, params);
}
return text;
}
var postProcess = function(msg, namedValues, args, count) {
// test for parsable interval string
if ((/\|/).test(msg)) {
msg = parsePluralInterval(msg, count);
}
// replace the counter
if (typeof count === 'number') {
msg = vsprintf(msg, [parseInt(count, 10)]);
}
// if the msg string contains {{Mustache}} patterns we render it as a mini tempalate
if ((/{{.*}}/).test(msg)) {
msg = Mustache.render(msg, namedValues);
}
// if we have extra arguments with values to get replaced,
// an additional substition injects those strings afterwards
if ((/%/).test(msg) && args && args.length > 0) {
msg = vsprintf(msg, args);
}
return msg;
};
function printRow(format, values) {
console.log(vsprintf(format, values));
}
res.writeHead(200, {
'Content-Type': 'text/xml'
});
res.write('');
res.write('');
res.write('');
var title = vsprintf(rssConfig.title, [appConfig.name + ' - ' + stype]);
var link = appConfig.domain;
var desc = vsprintf(rssConfig.description, [appConfig.name]);
var lang = language;
var copy = vsprintf(rssConfig.copyright, [appConfig.name]);
var editor = vsprintf(rssConfig.managingEditor, [appConfig.name]);
var master = vsprintf(rssConfig.webMaster, [appConfig.name]);
var lastBuild = moment().toString();
var gen = rssConfig.generator;
var docs = 'http://www.rssboard.org/rss-specification';
var ttl = rssConfig.ttl;
var img = {
title: title,
link: link,
desc: desc,
url: appConfig.domain + '/modules/core/client/img/rss.jpeg'
};
res.write('<title>' + getEscapeData(title) + '</title>');
res.write('' + getEscapeData(link) + '');
res.write('' + getEscapeData(desc) + '');
res.write('' + getEscapeData(lang, false) + '');
res.write('' + getEscapeData(copy) + '');
function fmtText(session, prompts, args) {
var fmt = Message.randomPrompt(prompts);
if (session) {
fmt = session.gettext(fmt);
}
return args && args.length > 0 ? sprintf.vsprintf(fmt, args) : fmt;
}
exports.fmtText = fmtText;
function announceTorrentToIRC(torrent, req) {
//irc announce
if (ircConfig.enable) {
var msg = '';
var client = req.app.get('ircClient');
if (torrent.torrent_type === 'tvserial') {
msg = vsprintf(ircConfig.tvserialMsgFormat, [
torrent.user.displayName,
torrent.torrent_filename,
torrent.torrent_type,
torrent.torrent_size,
torrent.torrent_seasons,
torrent.torrent_episodes,
torrent.torrent_sale_status,
appConfig.domain + '/api/torrents/download/' + torrent._id,
moment().format('YYYY-MM-DD HH:mm:ss')
]);
} else {
msg = vsprintf(ircConfig.defaultMsgFormat, [
torrent.user.displayName,
torrent.torrent_filename,
torrent.torrent_type,
torrent.torrent_size,
var client = req.app.get('ircClient');
if (torrent.torrent_type === 'tvserial') {
msg = vsprintf(ircConfig.tvserialMsgFormat, [
torrent.user.displayName,
torrent.torrent_filename,
torrent.torrent_type,
torrent.torrent_size,
torrent.torrent_seasons,
torrent.torrent_episodes,
torrent.torrent_sale_status,
appConfig.domain + '/api/torrents/download/' + torrent._id,
moment().format('YYYY-MM-DD HH:mm:ss')
]);
} else {
msg = vsprintf(ircConfig.defaultMsgFormat, [
torrent.user.displayName,
torrent.torrent_filename,
torrent.torrent_type,
torrent.torrent_size,
torrent.torrent_sale_status,
appConfig.domain + '/api/torrents/download/' + torrent._id,
moment().format('YYYY-MM-DD HH:mm:ss')
]);
}
client.notice(ircConfig.channel, msg);
}
}
Message.composePrompt = function (session, prompts, args) {
var connector = '';
var prompt = '';
for (var i = 0; i < prompts.length; i++) {
var txt = Message.randomPrompt(prompts[i]);
prompt += connector + (session ? session.gettext(txt) : txt);
connector = ' ';
}
return args && args.length > 0 ? sprintf.vsprintf(prompt, args) : prompt;
};
//-------------------