Skip to content

Commit 391831e

Browse files
author
春秋一语
authored
Merge pull request #17 from Coding/tencent
Tencent
2 parents 3dbed70 + 2cd1b9c commit 391831e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

app/commons/Tab/TabLabel.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ let TabLabel = observer(({ tab, removeTab, activateTab, openContextMenu, dbClick
1818
data-droppable='TABLABEL'
1919
draggable='true'
2020
onClick={e => activateTab(tab.id)}
21+
onMouseUp={e => { e.button === 1 && removeTab(tab.id) }}
2122
onDoubleClick={() => {
2223
if (!tab.isActive) {
2324
activateTab(tab.id)

app/components/MonacoEditor/Editors/MarkDownEditor.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ import scrollMixin from './scrollMixin';
1212

1313
// CodeEditor.use(mdMixin)
1414

15+
const eventXSSReg = /\son[a-z]{3,20}=('\S*'|"\S*")/ig;
16+
const hrefXSSReg = /\shref=('javascript:\S+'|"javascript:\S+")/ig;
17+
const scriptLt = /<(?=\/?script)/ig;
18+
const scriptGt = /(?<=\/?script)>/ig;
19+
1520
const md = new Remarkable('full', {
16-
html: false, // Enable HTML tags in source
21+
html: true, // Enable HTML tags in source
1722
xhtmlOut: false, // Use '/' to close single tags (<br />)
1823
breaks: false, // Convert '\n' in paragraphs into <br>
1924
langPrefix: 'language-', // CSS language prefix for fenced blocks
@@ -98,9 +103,10 @@ class PreviewEditor extends Component {
98103

99104
render () {
100105
const { content } = this.props
106+
const html = md.render(content).replace(eventXSSReg, '').replace(hrefXSSReg, '').replace(scriptLt, '&lt;').replace(scriptGt, '&gt;');
101107
return (
102108
<div name='markdown_preview' className='markdown content'>
103-
{ this.makeHTMLComponent(md.render(content)) }
109+
{this.makeHTMLComponent(html) }
104110
</div>
105111
)
106112
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
"loader-utils": "^1.0.2",
119119
"localforage": "^1.5.0",
120120
"lodash": "^4.14.2",
121-
"marked": "^0.3.6",
122121
"minimatch": "^3.0.4",
123122
"mobx": "^3.1.8",
124123
"mobx-react": "^4.1.5",

0 commit comments

Comments
 (0)