Skip to content

Commit 4ebd503

Browse files
authored
Merge pull request #880 from xxdavid/feature-strip-html-from-title
Strip HTML tags from the note title
2 parents 2cf46a3 + 0907bc8 commit 4ebd503

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

browser/main/Detail/MarkdownNoteDetail.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import InfoPanel from './InfoPanel'
2020
import InfoPanelTrashed from './InfoPanelTrashed'
2121
import { formatDate } from 'browser/lib/date-formatter'
2222
import { getTodoPercentageOfCompleted } from 'browser/lib/getTodoStatus'
23+
import striptags from 'striptags'
2324

2425
const electron = require('electron')
2526
const { remote } = electron
@@ -76,7 +77,7 @@ class MarkdownNoteDetail extends React.Component {
7677

7778
note.content = this.refs.content.value
7879
if (this.refs.tags) note.tags = this.refs.tags.value
79-
note.title = markdown.strip(findNoteTitle(note.content))
80+
note.title = markdown.strip(striptags(findNoteTitle(note.content)))
8081
note.updatedAt = new Date()
8182

8283
this.setState({

browser/main/NoteList/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import fs from 'fs'
1313
import { hashHistory } from 'react-router'
1414
import markdown from 'browser/lib/markdown'
1515
import { findNoteTitle } from 'browser/lib/findNoteTitle'
16+
import stripgtags from 'striptags'
1617

1718
const { remote } = require('electron')
1819
const { Menu, MenuItem, dialog } = remote
@@ -363,7 +364,7 @@ class NoteList extends React.Component {
363364
const newNote = {
364365
content: content,
365366
folder: folderKey,
366-
title: markdown.strip(findNoteTitle(content)),
367+
title: markdown.strip(striptags(findNoteTitle(content))),
367368
type: 'MARKDOWN_NOTE'
368369
}
369370
dataApi.createNote(storageKey, newNote)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"react-redux": "^4.4.5",
8080
"redux": "^3.5.2",
8181
"sander": "^0.5.1",
82+
"striptags": "^3.1.0",
8283
"superagent": "^1.2.0",
8384
"superagent-promise": "^1.0.3"
8485
},

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6075,6 +6075,10 @@ strip-json-comments@~2.0.1:
60756075
version "2.0.1"
60766076
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
60776077

6078+
striptags@^3.1.0:
6079+
version "3.1.0"
6080+
resolved "https://registry.yarnpkg.com/striptags/-/striptags-3.1.0.tgz#763e534338d9cf542f004a4b1eb099e32d295e44"
6081+
60786082
style-loader@^0.12.4:
60796083
version "0.12.4"
60806084
resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-0.12.4.tgz#ae7d0665dc4dc653daa2fe97bb90914bc1d22d9b"

0 commit comments

Comments
 (0)