2020-05-17 02:28:03 +02:00
diff --git a/src/Lexer.js b/src/Lexer.js
2023-04-01 15:15:53 +00:00
strip some features
2020-05-17 02:28:03 +02:00
--- a/src/Lexer.js
+++ b/src/Lexer.js
2022-12-02 21:39:04 +00:00
@@ -7,5 +7,5 @@ import { repeatString } from './helpers.js';
2020-04-26 23:43:26 +02:00
* smartypants text replacement
2022-12-02 21:39:04 +00:00
* @param {string} text
2020-04-26 23:43:26 +02:00
- */
+ *
function smartypants(text) {
2020-05-17 02:28:03 +02:00
return text
2022-12-02 21:39:04 +00:00
@@ -29,5 +29,5 @@ function smartypants(text) {
2020-04-26 23:43:26 +02:00
* mangle email addresses
2022-12-02 21:39:04 +00:00
* @param {string} text
2020-04-26 23:43:26 +02:00
- */
+ *
function mangle(text) {
2020-05-17 02:28:03 +02:00
let out = '',
2022-12-02 21:39:04 +00:00
@@ -478,5 +478,5 @@ export class Lexer {
2020-05-17 02:28:03 +02:00
2020-04-26 23:43:26 +02:00
// autolink
- if (token = this.tokenizer.autolink(src, mangle)) {
+ if (token = this.tokenizer.autolink(src)) {
src = src.substring(token.raw.length);
2020-05-17 02:28:03 +02:00
tokens.push(token);
2022-12-02 21:39:04 +00:00
@@ -485,5 +485,5 @@ export class Lexer {
2020-05-17 02:28:03 +02:00
2020-04-26 23:43:26 +02:00
// url (gfm)
2021-09-17 09:10:33 +02:00
- if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) {
+ if (!this.state.inLink && (token = this.tokenizer.url(src))) {
2020-04-26 23:43:26 +02:00
src = src.substring(token.raw.length);
2020-05-17 02:28:03 +02:00
tokens.push(token);
2022-12-02 21:39:04 +00:00
@@ -506,5 +506,5 @@ export class Lexer {
2021-09-17 09:10:33 +02:00
}
}
- if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
+ if (token = this.tokenizer.inlineText(cutSrc)) {
2020-04-26 23:43:26 +02:00
src = src.substring(token.raw.length);
2021-09-17 09:10:33 +02:00
this.ln = token.ln || this.ln;
2020-05-17 02:28:03 +02:00
diff --git a/src/Renderer.js b/src/Renderer.js
--- a/src/Renderer.js
+++ b/src/Renderer.js
2022-12-02 21:39:04 +00:00
@@ -173,5 +173,5 @@ export class Renderer {
*/
2020-04-26 23:43:26 +02:00
link(href, title, text) {
- href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
+ href = cleanUrl(this.options.baseUrl, href);
if (href === null) {
2020-05-17 02:28:03 +02:00
return text;
2022-12-02 21:39:04 +00:00
@@ -191,5 +191,5 @@ export class Renderer {
*/
2020-04-26 23:43:26 +02:00
image(href, title, text) {
- href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
+ href = cleanUrl(this.options.baseUrl, href);
if (href === null) {
2020-05-17 02:28:03 +02:00
return text;
diff --git a/src/Tokenizer.js b/src/Tokenizer.js
--- a/src/Tokenizer.js
+++ b/src/Tokenizer.js
2023-04-01 15:15:53 +00:00
@@ -367,14 +367,7 @@ export class Tokenizer {
2021-09-17 09:10:33 +02:00
type: 'html',
2020-05-17 02:28:03 +02:00
raw: cap[0],
2020-04-26 23:43:26 +02:00
- pre: !this.options.sanitizer
- && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
2021-09-17 09:10:33 +02:00
+ pre: (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
text: cap[0]
2020-04-26 23:43:26 +02:00
};
2021-09-17 09:10:33 +02:00
- if (this.options.sanitize) {
2022-12-02 21:39:04 +00:00
- const text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
2021-09-17 09:10:33 +02:00
- token.type = 'paragraph';
2022-12-02 21:39:04 +00:00
- token.text = text;
- token.tokens = this.lexer.inline(text);
2021-09-17 09:10:33 +02:00
- }
return token;
2020-05-17 02:28:03 +02:00
}
2023-04-01 15:15:53 +00:00
@@ -517,15 +510,9 @@ export class Tokenizer {
2020-05-17 02:28:03 +02:00
2020-04-26 23:43:26 +02:00
return {
- type: this.options.sanitize
- ? 'text'
- : 'html',
+ type: 'html',
raw: cap[0],
2021-09-17 09:10:33 +02:00
inLink: this.lexer.state.inLink,
inRawBlock: this.lexer.state.inRawBlock,
2020-04-26 23:43:26 +02:00
- text: this.options.sanitize
- ? (this.options.sanitizer
- ? this.options.sanitizer(cap[0])
- : escape(cap[0]))
- : cap[0]
+ text: cap[0]
};
2020-05-17 02:28:03 +02:00
}
2023-04-01 15:15:53 +00:00
@@ -714,10 +701,10 @@ export class Tokenizer {
2020-05-17 02:28:03 +02:00
}
2020-04-26 23:43:26 +02:00
- autolink(src, mangle) {
+ autolink(src) {
const cap = this.rules.inline.autolink.exec(src);
2020-05-17 02:28:03 +02:00
if (cap) {
let text, href;
2020-04-26 23:43:26 +02:00
if (cap[2] === '@') {
- text = escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
+ text = escape(cap[1]);
href = 'mailto:' + text;
2020-05-17 02:28:03 +02:00
} else {
2023-04-01 15:15:53 +00:00
@@ -742,10 +729,10 @@ export class Tokenizer {
2020-05-17 02:28:03 +02:00
}
2020-04-26 23:43:26 +02:00
- url(src, mangle) {
+ url(src) {
let cap;
2020-05-17 02:28:03 +02:00
if (cap = this.rules.inline.url.exec(src)) {
let text, href;
2020-04-26 23:43:26 +02:00
if (cap[2] === '@') {
- text = escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
+ text = escape(cap[0]);
href = 'mailto:' + text;
2020-05-17 02:28:03 +02:00
} else {
2023-04-01 15:15:53 +00:00
@@ -779,12 +766,12 @@ export class Tokenizer {
2020-05-17 02:28:03 +02:00
}
2020-04-26 23:43:26 +02:00
2021-09-17 09:10:33 +02:00
- inlineText(src, smartypants) {
+ inlineText(src) {
2020-04-26 23:43:26 +02:00
const cap = this.rules.inline.text.exec(src);
2020-05-17 02:28:03 +02:00
if (cap) {
let text;
2021-09-17 09:10:33 +02:00
if (this.lexer.state.inRawBlock) {
2020-04-26 23:43:26 +02:00
- text = this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0];
+ text = cap[0];
} else {
- text = escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
+ text = escape(cap[0]);
}
2020-05-17 02:28:03 +02:00
return {
diff --git a/src/defaults.js b/src/defaults.js
--- a/src/defaults.js
+++ b/src/defaults.js
2023-04-01 15:15:53 +00:00
@@ -11,11 +11,7 @@ export function getDefaults() {
hooks: null,
2020-05-17 02:28:03 +02:00
langPrefix: 'language-',
- mangle: true,
pedantic: false,
renderer: null,
- sanitize: false,
- sanitizer: null,
silent: false,
- smartypants: false,
tokenizer: null,
walkTokens: null,
diff --git a/src/helpers.js b/src/helpers.js
--- a/src/helpers.js
+++ b/src/helpers.js
2022-12-02 21:39:04 +00:00
@@ -78,18 +78,5 @@ const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
* @param {string} href
*/
2021-12-07 01:12:32 +01:00
-export function cleanUrl(sanitize, base, href) {
2020-05-17 02:28:03 +02:00
- if (sanitize) {
- let prot;
- try {
- prot = decodeURIComponent(unescape(href))
- .replace(nonWordAndColonTest, '')
- .toLowerCase();
- } catch (e) {
- return null;
- }
- if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
- return null;
- }
- }
2021-12-07 01:12:32 +01:00
+export function cleanUrl(base, href) {
2020-05-17 02:28:03 +02:00
if (base && !originIndependentUrl.test(href)) {
href = resolveUrl(base, href);
2023-04-01 15:15:53 +00:00
@@ -233,10 +220,4 @@ export function findClosingBracket(str, b) {
2020-05-17 02:28:03 +02:00
}
2021-12-07 01:12:32 +01:00
-export function checkSanitizeDeprecation(opt) {
2020-05-17 02:28:03 +02:00
- if (opt && opt.sanitize && !opt.silent) {
- console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
- }
-}
-
2021-09-17 09:10:33 +02:00
// copied from https://stackoverflow.com/a/5450113/806777
2022-12-02 21:39:04 +00:00
/**
2020-05-17 02:28:03 +02:00
diff --git a/src/marked.js b/src/marked.js
--- a/src/marked.js
+++ b/src/marked.js
2021-12-07 01:12:32 +01:00
@@ -7,5 +7,4 @@ import { Slugger } from './Slugger.js';
2023-04-01 15:15:53 +00:00
import { Hooks } from './Hooks.js';
2021-12-07 01:12:32 +01:00
import {
2020-05-17 02:28:03 +02:00
- checkSanitizeDeprecation,
escape
2021-12-07 01:12:32 +01:00
} from './helpers.js';
2023-04-01 15:15:53 +00:00
@@ -18,5 +17,5 @@ import {
function onError(silent, async, callback) {
return (e) => {
2020-05-17 02:28:03 +02:00
- e.message += '\nPlease report this to https://github.com/markedjs/marked.';
+ e.message += '\nmake issue @ https://github.com/9001/copyparty';
2023-04-01 15:15:53 +00:00
if (silent) {
@@ -65,6 +64,4 @@ function parseMarkdown(lexer, parser) {
}
- checkSanitizeDeprecation(opt);
-
if (opt.hooks) {
opt.hooks.options = opt;
2020-05-17 02:28:03 +02:00
diff --git a/test/bench.js b/test/bench.js
--- a/test/bench.js
+++ b/test/bench.js
2022-12-02 21:39:04 +00:00
@@ -39,5 +39,4 @@ export async function runBench(options) {
2020-05-17 02:28:03 +02:00
breaks: false,
2020-04-26 23:43:26 +02:00
pedantic: false,
2022-12-02 21:39:04 +00:00
- sanitize: false
2020-05-17 02:28:03 +02:00
});
2022-12-02 21:39:04 +00:00
if (options.marked) {
@@ -50,5 +49,4 @@ export async function runBench(options) {
2020-05-17 02:28:03 +02:00
breaks: false,
2020-04-26 23:43:26 +02:00
pedantic: false,
2022-12-02 21:39:04 +00:00
- sanitize: false
2020-05-17 02:28:03 +02:00
});
2022-12-02 21:39:04 +00:00
if (options.marked) {
@@ -61,5 +59,4 @@ export async function runBench(options) {
// breaks: false,
// pedantic: false,
- // sanitize: false
// });
// if (options.marked) {
2020-05-17 02:28:03 +02:00
diff --git a/test/specs/run-spec.js b/test/specs/run-spec.js
--- a/test/specs/run-spec.js
+++ b/test/specs/run-spec.js
2021-12-07 01:12:32 +01:00
@@ -25,9 +25,4 @@ function runSpecs(title, dir, showCompletionTable, options) {
2020-04-26 23:43:26 +02:00
}
2020-05-17 02:28:03 +02:00
2020-04-26 23:43:26 +02:00
- if (spec.options.sanitizer) {
- // eslint-disable-next-line no-eval
- spec.options.sanitizer = eval(spec.options.sanitizer);
- }
2021-09-17 09:10:33 +02:00
-
2020-04-26 23:43:26 +02:00
(spec.only ? fit : (spec.skip ? xit : it))('should ' + passFail + example, async() => {
2021-09-17 09:10:33 +02:00
const before = process.hrtime();
2021-12-07 01:12:32 +01:00
@@ -56,3 +51,2 @@ runSpecs('Original', './original', false, { gfm: false, pedantic: true });
2020-05-17 02:28:03 +02:00
runSpecs('New', './new');
2020-04-26 23:43:26 +02:00
runSpecs('ReDOS', './redos');
-runSpecs('Security', './security', false, { silent: true }); // silent - do not show deprecation warning
2020-05-17 02:28:03 +02:00
diff --git a/test/unit/Lexer-spec.js b/test/unit/Lexer-spec.js
--- a/test/unit/Lexer-spec.js
+++ b/test/unit/Lexer-spec.js
2023-04-01 15:15:53 +00:00
@@ -794,5 +794,5 @@ paragraph
2020-05-17 02:28:03 +02:00
});
2020-04-26 23:43:26 +02:00
- it('sanitize', () => {
+ /*it('sanitize', () => {
expectTokens({
2020-05-17 02:28:03 +02:00
md: '<div>html</div>',
2023-04-01 15:15:53 +00:00
@@ -812,5 +812,5 @@ paragraph
2020-05-17 02:28:03 +02:00
]
2020-04-26 23:43:26 +02:00
});
- });
+ });*/
});
2020-05-17 02:28:03 +02:00
2023-04-01 15:15:53 +00:00
@@ -892,5 +892,5 @@ paragraph
2020-05-17 02:28:03 +02:00
});
2020-04-26 23:43:26 +02:00
- it('html sanitize', () => {
+ /*it('html sanitize', () => {
expectInlineTokens({
2020-05-17 02:28:03 +02:00
md: '<div>html</div>',
2023-04-01 15:15:53 +00:00
@@ -900,5 +900,5 @@ paragraph
2020-05-17 02:28:03 +02:00
]
2020-04-26 23:43:26 +02:00
});
- });
+ });*/
2020-05-17 02:28:03 +02:00
it('link', () => {
2023-04-01 15:15:53 +00:00
@@ -1211,5 +1211,5 @@ paragraph
2020-05-17 02:28:03 +02:00
});
2020-04-26 23:43:26 +02:00
- it('autolink mangle email', () => {
+ /*it('autolink mangle email', () => {
expectInlineTokens({
2020-05-17 02:28:03 +02:00
md: '<test@example.com>',
2023-04-01 15:15:53 +00:00
@@ -1231,5 +1231,5 @@ paragraph
2020-05-17 02:28:03 +02:00
]
2020-04-26 23:43:26 +02:00
});
- });
+ });*/
2020-05-17 02:28:03 +02:00
it('url', () => {
2023-04-01 15:15:53 +00:00
@@ -1268,5 +1268,5 @@ paragraph
2020-05-17 02:28:03 +02:00
});
2020-04-26 23:43:26 +02:00
- it('url mangle email', () => {
+ /*it('url mangle email', () => {
expectInlineTokens({
2020-05-17 02:28:03 +02:00
md: 'test@example.com',
2023-04-01 15:15:53 +00:00
@@ -1288,5 +1288,5 @@ paragraph
2020-05-17 02:28:03 +02:00
]
2020-04-26 23:43:26 +02:00
});
- });
+ });*/
});
2020-05-17 02:28:03 +02:00
2023-04-01 15:15:53 +00:00
@@ -1304,5 +1304,5 @@ paragraph
2020-05-17 02:28:03 +02:00
});
2020-04-26 23:43:26 +02:00
- describe('smartypants', () => {
+ /*describe('smartypants', () => {
it('single quotes', () => {
2020-05-17 02:28:03 +02:00
expectInlineTokens({
2023-04-01 15:15:53 +00:00
@@ -1374,5 +1374,5 @@ paragraph
2020-05-17 02:28:03 +02:00
});
2020-04-26 23:43:26 +02:00
});
- });
+ });*/
});
2020-05-17 02:28:03 +02:00
});