Skip to content

Commit

Permalink
This almost works, but does not help to get a proper display for desc…
Browse files Browse the repository at this point in the history
…riptions such as $ <strong>y < a, x</strong> $.
  • Loading branch information
Zerline committed Jun 15, 2020
1 parent 2e8c38c commit 7f296f0
Showing 1 changed file with 41 additions and 23 deletions.
64 changes: 41 additions & 23 deletions packages/base-manager/src/manager-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,47 @@ function default_plaintext_sanitize(s: string): string {
* Sanitize HTML-formatted descriptions.
*/
function default_inline_sanitize(html: string): string {
return sanitize(html, {
allowedTags: [
'a',
'abbr',
'b',
'code',
'em',
'i',
'img',
'li',
'ol',
'span',
'strong',
'style',
'ul'
],
allowedAttributes: {
'*': ['aria-*', 'style', 'title'],
a: ['href'],
img: ['src'],
style: ['media', 'type']
}
});
var allowedTags = [
'a',
'abbr',
'b',
'code',
'em',
'i',
'img',
'li',
'ol',
'span',
'strong',
'style',
'ul'
];
var allowedAttributes = {
'*': ['aria-*', 'style', 'title'],
a: ['href'],
img: ['src'],
style: ['media', 'type']
};
var res = '';
var m = html.match(/\$[^$]+\$/);
while (1) {
if (m == null) break;
var matched = String(m);
res +=
'$' +
sanitize(matched.substr(1, matched.length - 1), {
allowedTags: allowedTags,
allowedAttributes: allowedAttributes
}) +
'$';
var ind = m.index;
if (ind == undefined) break;
var len = matched.length;
if (len == undefined) break;
html = html.substr(ind + len);
m = html.match(/\$[^$]+\$/);
}
return res;
}

export interface IState extends PartialJSONObject {
Expand Down

0 comments on commit 7f296f0

Please sign in to comment.