mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-21 08:19:43 +02:00
#2209 Combining sanitasion approaches
This commit is contained in:
@@ -56,17 +56,11 @@ subgraph CompositeState
|
||||
|
||||
end
|
||||
</div>
|
||||
<div class="mermaid3" style="width: 100%; height: 20%;">
|
||||
stateDiagram-v2
|
||||
state CompositeState {
|
||||
state AnotherCompositeState1234567890 {
|
||||
YourState
|
||||
}
|
||||
}
|
||||
|
||||
</div>
|
||||
javascript:alert('XSS')
|
||||
<div class="mermaid" style="width: 100%; height: 20%;">
|
||||
graph TD
|
||||
A["<img src=`https://via.placeholder.com/64/`>"]
|
||||
</div>
|
||||
<div class="mermaid2" style="width: 100%; height: 20%;">
|
||||
flowchart TD
|
||||
Link --> b
|
||||
click Link href "javascript:alert('XSS')" "Tooltip for
|
||||
|
@@ -36,8 +36,36 @@ export const removeScript = (txt) => {
|
||||
return rs;
|
||||
};
|
||||
|
||||
const sanitizeMore = (text, config) => {
|
||||
let txt = text;
|
||||
let htmlLabels = true;
|
||||
if (
|
||||
config.flowchart &&
|
||||
(config.flowchart.htmlLabels === false || config.flowchart.htmlLabels === 'false')
|
||||
) {
|
||||
htmlLabels = false;
|
||||
}
|
||||
|
||||
if (htmlLabels) {
|
||||
const level = config.securityLevel;
|
||||
|
||||
if (level === 'antiscript') {
|
||||
txt = removeScript(txt);
|
||||
} else if (level !== 'loose') {
|
||||
// eslint-disable-line
|
||||
txt = breakToPlaceholder(txt);
|
||||
txt = txt.replace(/</g, '<').replace(/>/g, '>');
|
||||
txt = txt.replace(/=/g, '=');
|
||||
txt = placeholderToBreak(txt);
|
||||
}
|
||||
}
|
||||
|
||||
return txt;
|
||||
};
|
||||
|
||||
export const sanitizeText = (text) => {
|
||||
const txt = DOMPurify.sanitize(text);
|
||||
const txt = sanitizeMore(DOMPurify.sanitize(text));
|
||||
|
||||
return txt;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user