Skip to content

Commit

Permalink
fix todo list with XSS
Browse files Browse the repository at this point in the history
  • Loading branch information
tamlok committed Jun 27, 2024
1 parent 743e63e commit 44b5251
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/data/extra/extra.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
<file>web/js/markdown-it/markdown-it-texmath.js</file>
<file>web/js/markdown-it/markdown-it-mark.min.js</file>
<file>web/js/markdown-it/markdown-it-inject-linenumbers.js</file>
<file>web/js/markdown-it/markdown-it-xss.min.js</file>
<file>web/js/markdown-it/xss.min.js</file>
<file>web/js/markdown-it/markdown-it-xss.js</file>
<file>web/js/markdown-it/markdown-it-implicit-figure.js</file>
<file>web/js/markdown-it/markdown-it.min.js</file>
<file>web/js/markdownit.js</file>
Expand Down
3 changes: 0 additions & 3 deletions src/data/extra/web/js/markdown-it/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ Vitaly Puzrin
v0.0.0
Modified by Le Tan

# [markdown-it-xss](https://github.com/yzyeengang/markdown-it-xss)
v1.0.0

# [markdonw-it-anchor](https://github.com/valeriangalliat/markdown-it-anchor)
v6.0.1

Expand Down
21 changes: 21 additions & 0 deletions src/data/extra/web/js/markdown-it/markdown-it-xss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownItXSS = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';

module.exports = function protect_xss(md, opts = {}) {
const proxy = (tokens, idx, options, env, self) => self.renderToken(tokens, idx, options);
const defaultHtmlInlineRenderer = md.renderer.rules.html_inline || proxy;

function protectFromXSS(html) {
return filterXSS(html, opts);
}

function filterContent(tokens, idx, options, env, slf) {
tokens[idx].content = protectFromXSS(tokens[idx].content);
return defaultHtmlInlineRenderer(tokens, idx, options, env, slf);
}

md.renderer.rules.html_inline = filterContent;
};

},{}]},{},[1])(1)
});
Loading

0 comments on commit 44b5251

Please sign in to comment.