mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Fix 3007 (#3028)
* fix code fences never sanitized
* fix mermaid xss
* Revert "fix mermaid xss"
This reverts commit 1ff179a1bd.
* configuable mermaid HTML label
* add locales for mermaid configuration
This commit is contained in:
@@ -341,6 +341,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
smartArrows={config.preview.smartArrows}
|
smartArrows={config.preview.smartArrows}
|
||||||
breaks={config.preview.breaks}
|
breaks={config.preview.breaks}
|
||||||
sanitize={config.preview.sanitize}
|
sanitize={config.preview.sanitize}
|
||||||
|
mermaidHTMLLabel={config.preview.mermaidHTMLLabel}
|
||||||
ref='preview'
|
ref='preview'
|
||||||
onContextMenu={(e) => this.handleContextMenu(e)}
|
onContextMenu={(e) => this.handleContextMenu(e)}
|
||||||
onDoubleClick={(e) => this.handleDoubleClick(e)}
|
onDoubleClick={(e) => this.handleDoubleClick(e)}
|
||||||
|
|||||||
@@ -560,6 +560,7 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
if (
|
if (
|
||||||
prevProps.smartQuotes !== this.props.smartQuotes ||
|
prevProps.smartQuotes !== this.props.smartQuotes ||
|
||||||
prevProps.sanitize !== this.props.sanitize ||
|
prevProps.sanitize !== this.props.sanitize ||
|
||||||
|
prevProps.mermaidHTMLLabel !== this.props.mermaidHTMLLabel ||
|
||||||
prevProps.smartArrows !== this.props.smartArrows ||
|
prevProps.smartArrows !== this.props.smartArrows ||
|
||||||
prevProps.breaks !== this.props.breaks ||
|
prevProps.breaks !== this.props.breaks ||
|
||||||
prevProps.lineThroughCheckbox !== this.props.lineThroughCheckbox
|
prevProps.lineThroughCheckbox !== this.props.lineThroughCheckbox
|
||||||
@@ -681,7 +682,8 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
showCopyNotification,
|
showCopyNotification,
|
||||||
storagePath,
|
storagePath,
|
||||||
noteKey,
|
noteKey,
|
||||||
sanitize
|
sanitize,
|
||||||
|
mermaidHTMLLabel
|
||||||
} = this.props
|
} = this.props
|
||||||
let { value, codeBlockTheme } = this.props
|
let { value, codeBlockTheme } = this.props
|
||||||
|
|
||||||
@@ -823,7 +825,7 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
_.forEach(
|
_.forEach(
|
||||||
this.refs.root.contentWindow.document.querySelectorAll('.mermaid'),
|
this.refs.root.contentWindow.document.querySelectorAll('.mermaid'),
|
||||||
el => {
|
el => {
|
||||||
mermaidRender(el, htmlTextHelper.decodeEntities(el.innerHTML), theme)
|
mermaidRender(el, htmlTextHelper.decodeEntities(el.innerHTML), theme, mermaidHTMLLabel)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ class MarkdownSplitEditor extends React.Component {
|
|||||||
smartArrows={config.preview.smartArrows}
|
smartArrows={config.preview.smartArrows}
|
||||||
breaks={config.preview.breaks}
|
breaks={config.preview.breaks}
|
||||||
sanitize={config.preview.sanitize}
|
sanitize={config.preview.sanitize}
|
||||||
|
mermaidHTMLLabel={config.preview.mermaidHTMLLabel}
|
||||||
ref='preview'
|
ref='preview'
|
||||||
tabInde='0'
|
tabInde='0'
|
||||||
value={value}
|
value={value}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function getId () {
|
|||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
function render (element, content, theme) {
|
function render (element, content, theme, enableHTMLLabel) {
|
||||||
try {
|
try {
|
||||||
const height = element.attributes.getNamedItem('data-height')
|
const height = element.attributes.getNamedItem('data-height')
|
||||||
if (height && height.value !== 'undefined') {
|
if (height && height.value !== 'undefined') {
|
||||||
@@ -29,7 +29,8 @@ function render (element, content, theme) {
|
|||||||
mermaidAPI.initialize({
|
mermaidAPI.initialize({
|
||||||
theme: isDarkTheme ? 'dark' : 'default',
|
theme: isDarkTheme ? 'dark' : 'default',
|
||||||
themeCSS: isDarkTheme ? darkThemeStyling : '',
|
themeCSS: isDarkTheme ? darkThemeStyling : '',
|
||||||
useMaxWidth: false
|
useMaxWidth: false,
|
||||||
|
flowchart: { htmlLabels: enableHTMLLabel }
|
||||||
})
|
})
|
||||||
mermaidAPI.render(getId(), content, (svgGraph) => {
|
mermaidAPI.render(getId(), content, (svgGraph) => {
|
||||||
element.innerHTML = svgGraph
|
element.innerHTML = svgGraph
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module.exports = function sanitizePlugin (md, options) {
|
|||||||
options
|
options
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (state.tokens[tokenIdx].type === '_fence') {
|
if (state.tokens[tokenIdx].type.match(/.*_fence$/)) {
|
||||||
// escapeHtmlCharacters has better performance
|
// escapeHtmlCharacters has better performance
|
||||||
state.tokens[tokenIdx].content = escapeHtmlCharacters(
|
state.tokens[tokenIdx].content = escapeHtmlCharacters(
|
||||||
state.tokens[tokenIdx].content,
|
state.tokens[tokenIdx].content,
|
||||||
|
|||||||
@@ -86,8 +86,10 @@ export const DEFAULT_CONFIG = {
|
|||||||
breaks: true,
|
breaks: true,
|
||||||
smartArrows: false,
|
smartArrows: false,
|
||||||
allowCustomCSS: false,
|
allowCustomCSS: false,
|
||||||
|
|
||||||
customCSS: '/* Drop Your Custom CSS Code Here */',
|
customCSS: '/* Drop Your Custom CSS Code Here */',
|
||||||
sanitize: 'STRICT', // 'STRICT', 'ALLOW_STYLES', 'NONE'
|
sanitize: 'STRICT', // 'STRICT', 'ALLOW_STYLES', 'NONE'
|
||||||
|
mermaidHTMLLabel: false,
|
||||||
lineThroughCheckbox: true
|
lineThroughCheckbox: true
|
||||||
},
|
},
|
||||||
blog: {
|
blog: {
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ class UiTab extends React.Component {
|
|||||||
breaks: this.refs.previewBreaks.checked,
|
breaks: this.refs.previewBreaks.checked,
|
||||||
smartArrows: this.refs.previewSmartArrows.checked,
|
smartArrows: this.refs.previewSmartArrows.checked,
|
||||||
sanitize: this.refs.previewSanitize.value,
|
sanitize: this.refs.previewSanitize.value,
|
||||||
|
mermaidHTMLLabel: this.refs.previewMermaidHTMLLabel.checked,
|
||||||
allowCustomCSS: this.refs.previewAllowCustomCSS.checked,
|
allowCustomCSS: this.refs.previewAllowCustomCSS.checked,
|
||||||
lineThroughCheckbox: this.refs.lineThroughCheckbox.checked,
|
lineThroughCheckbox: this.refs.lineThroughCheckbox.checked,
|
||||||
customCSS: this.customCSSCM.getCodeMirror().getValue()
|
customCSS: this.customCSSCM.getCodeMirror().getValue()
|
||||||
@@ -813,6 +814,16 @@ class UiTab extends React.Component {
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div styleName='group-checkBoxSection'>
|
||||||
|
<label>
|
||||||
|
<input onChange={(e) => this.handleUIChange(e)}
|
||||||
|
checked={this.state.config.preview.mermaidHTMLLabel}
|
||||||
|
ref='previewMermaidHTMLLabel'
|
||||||
|
type='checkbox'
|
||||||
|
/>
|
||||||
|
{i18n.__('Enable HTML label in mermaid flowcharts')}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div styleName='group-section'>
|
<div styleName='group-section'>
|
||||||
<div styleName='group-section-label'>
|
<div styleName='group-section-label'>
|
||||||
{i18n.__('LaTeX Inline Open Delimiter')}
|
{i18n.__('LaTeX Inline Open Delimiter')}
|
||||||
|
|||||||
@@ -157,5 +157,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,5 +213,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,5 +188,6 @@
|
|||||||
"New notes are tagged with the filtering tags": "New notes are tagged with the filtering tags",
|
"New notes are tagged with the filtering tags": "New notes are tagged with the filtering tags",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,5 +159,6 @@
|
|||||||
"Show menu bar": "Mostrar barra del menú",
|
"Show menu bar": "Mostrar barra del menú",
|
||||||
"Auto Detect": "Detección automática",
|
"Auto Detect": "Detección automática",
|
||||||
"Snippet Default Language": "Lenguaje por defecto de los fragmentos de código",
|
"Snippet Default Language": "Lenguaje por defecto de los fragmentos de código",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,5 +161,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,5 +173,6 @@
|
|||||||
"Snippet prefix": "Préfixe du snippet",
|
"Snippet prefix": "Préfixe du snippet",
|
||||||
"Delete Note": "Supprimer la note",
|
"Delete Note": "Supprimer la note",
|
||||||
"New notes are tagged with the filtering tags": "Les nouvelles notes sont taggées avec les tags de filtrage",
|
"New notes are tagged with the filtering tags": "Les nouvelles notes sont taggées avec les tags de filtrage",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,5 +181,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,5 +161,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,5 +220,6 @@
|
|||||||
"Spellcheck disabled": "スペルチェック無効",
|
"Spellcheck disabled": "スペルチェック無効",
|
||||||
"Show menu bar": "メニューバーを表示",
|
"Show menu bar": "メニューバーを表示",
|
||||||
"Auto Detect": "自動検出",
|
"Auto Detect": "自動検出",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "mermaid flowchartでHTMLラベルを有効にする ⚠ このオプションには潜在的なXSSの危険性があります。",
|
||||||
"Wrap line in Snippet Note": "行を右端で折り返す(Snippet Note)"
|
"Wrap line in Snippet Note": "行を右端で折り返す(Snippet Note)"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,5 +164,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,5 +157,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,5 +166,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,5 +157,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,5 +156,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,5 +154,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,5 +156,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,5 +183,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,5 +156,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,5 +221,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,5 +165,6 @@
|
|||||||
"Spellcheck disabled": "Spellcheck disabled",
|
"Spellcheck disabled": "Spellcheck disabled",
|
||||||
"Show menu bar": "Show menu bar",
|
"Show menu bar": "Show menu bar",
|
||||||
"Auto Detect": "Auto Detect",
|
"Auto Detect": "Auto Detect",
|
||||||
|
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
|
||||||
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user