Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'.result-debug-content',
JSON.stringify(mdSrc.parse(source, { references: {} }), null, 2),
'json'
);
} else { /*defaults._view === 'html'*/
$('.result-html').html(mdHtml.render(source));
}
// reset lines mapping cache on content update
scrollMap = null;
try {
if (source) {
// serialize state - source and options
permalink.href = '#md3=' + mdurl.encode(JSON.stringify({
source: source,
defaults: _.omit(defaults, 'highlight')
}), '-_.!~', false);
} else {
permalink.href = '';
}
} catch (__) {
permalink.href = '';
}
}
if (parsed.hostname) {
// Encode hostnames in urls like:
// `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
//
// We don't encode unknown schemas, because it's likely that we encode
// something we shouldn't (e.g. `skype:name` treated as `skype:host`)
//
if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
try {
parsed.hostname = punycode.toASCII(parsed.hostname);
} catch (er) { /**/ }
}
}
return mdurl.encode(mdurl.format(parsed));
}
if (parsed.hostname) {
// Encode hostnames in urls like:
// `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
//
// We don't encode unknown schemas, because it's likely that we encode
// something we shouldn't (e.g. `skype:name` treated as `skype:host`)
//
if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
try {
parsed.hostname = punycode.toASCII(parsed.hostname);
} catch (er) { /**/ }
}
}
return mdurl.encode(mdurl.format(parsed));
}
if (parsed.hostname) {
// Encode hostnames in urls like:
// `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
//
// We don't encode unknown schemas, because it's likely that we encode
// something we shouldn't (e.g. `skype:name` treated as `skype:host`)
//
if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
try {
parsed.hostname = punycode.toASCII(parsed.hostname);
} catch (er) {/**/}
}
}
return mdurl.encode(mdurl.format(parsed));
}
_.forEach(params, function (value, key) {
result += result.length ? '&' : '?';
result += encode(String(key), encode.componentChars);
result += '=';
// Don't dump protected params
if (PROTECTED_PARAMS.indexOf(key) !== -1) result += '****';
// Do not dump nested objects.
else if (_.isObject(value)) result += '{...}';
else result += encode(String(value), encode.componentChars);
if (result.length > MAX_PARAMS_LOG_LENGTH) {
result = result.slice(0, MAX_PARAMS_LOG_LENGTH);
return false; // terminate
}
});
const content = token.content.split('\n').slice(0, -1).map(line => {
const match = /!\[[^\]]*]\(([^\)]*)\)/.exec(line)
if (match) {
return mdurl.encode(match[1])
} else {
return mdurl.encode(line)
}
}).join('\n')
return renderedHTML.replace(new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '(?:(?:\\\/|%5C)[\\w.]+)+', 'g'), function (match) {
var encodedPathSeparators = new RegExp(mdurl.encode(path.win32.sep) + '|' + mdurl.encode(path.posix.sep), 'g')
return match.replace(encodedPathSeparators, path.sep).replace(new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER, 'g'), 'file:///' + path.join(storagePath, DESTINATION_FOLDER))
})
}
function updateResult() {
var source = $('.source').val();
setLinkifiedContent('.result-html', source);
if (source) {
permalink.href = '#t1=' + mdurl.encode(source, mdurl.encode.componentChars);
} else {
permalink.href = '';
}
}
function removeStorageAndNoteReferences (input, noteKey) {
return input.replace(new RegExp(mdurl.encode(path.sep), 'g'), path.sep).replace(new RegExp(STORAGE_FOLDER_PLACEHOLDER + '(' + escapeStringRegexp(path.sep) + noteKey + ')?', 'g'), DESTINATION_FOLDER)
}