Skip to content

Commit

Permalink
使用 sanitizeHtml 库
Browse files Browse the repository at this point in the history
  • Loading branch information
expoli committed Apr 20, 2023
1 parent 3a2b3a5 commit e2b323e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions components/PrismMac.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'prismjs/plugins/line-numbers/prism-line-numbers.css'
// mermaid图
import BLOG from '@/blog.config'
import { isBrowser, loadExternalResource } from '@/lib/utils'
import escapeHTML from 'escape-html'
import sanitizeHtml from 'sanitize-html';

/**
* @author https://github.com/txs/
Expand Down Expand Up @@ -44,7 +44,7 @@ const renderMermaid = async() => {
const mermaidPres = document.querySelectorAll('pre.notion-code.language-mermaid')
if (mermaidPres) {
for (const e of mermaidPres) {
const chart = escapeHTML(e.querySelector('code').textContent)
const chart = sanitizeHtml(e.querySelector('code').textContent)
if (chart && !e.querySelector('.mermaid')) {
const m = document.createElement('div')
m.className = 'mermaid'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"aos": "^3.0.0-beta.6",
"axios": "^1.3.5",
"copy-to-clipboard": "^3.3.3",
"escape-html": "^1.0.3",
"eslint-plugin-react-hooks": "^4.6.0",
"feed": "^4.2.2",
"js-md5": "^0.7.3",
Expand All @@ -53,6 +52,7 @@
"react-notion-x": "6.16.0",
"react-share": "^4.4.1",
"react-tweet-embed": "~2.0.0",
"sanitize-html": "^2.10.0",
"smoothscroll-polyfill": "^0.4.4",
"twikoo": "1.6.16",
"typed.js": "^2.0.15",
Expand Down
4 changes: 2 additions & 2 deletions themes/fukasawa/LayoutSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { useRouter } from 'next/router'
import { useEffect } from 'react'
import Mark from 'mark.js'
import { isBrowser } from '@/lib/utils'
import escapeHTML from 'escape-html'
import sanitizeHtml from 'sanitize-html';

export const LayoutSearch = (props) => {
const { keyword } = props
const router = useRouter()
const currentSearch = escapeHTML(keyword || router?.query?.s)
const currentSearch = sanitizeHtml(keyword || router?.query?.s)
useEffect(() => {
setTimeout(() => {
const container = isBrowser() && document.getElementById('container')
Expand Down
4 changes: 2 additions & 2 deletions themes/hexo/LayoutSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import Mark from 'mark.js'
import TagItemMini from './components/TagItemMini'
import Card from './components/Card'
import Link from 'next/link'
import escapeHTML from 'escape-html'
import sanitizeHtml from 'sanitize-html';

export const LayoutSearch = props => {
const { keyword, tagOptions, categoryOptions } = props
const { locale } = useGlobal()
const router = useRouter()
const tempSearch = escapeHTML(keyword || router?.query?.s)
const tempSearch = sanitizeHtml(keyword || router?.query?.s)
const currentSearch = tempSearch
const cRef = useRef(null)

Expand Down
4 changes: 2 additions & 2 deletions themes/matery/LayoutSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import Mark from 'mark.js'
import TagItemMini from './components/TagItemMini'
import Card from './components/Card'
import Link from 'next/link'
import escapeHTML from 'escape-html'
import sanitizeHtml from 'sanitize-html';

export const LayoutSearch = props => {
const { keyword, tagOptions, categoryOptions } = props
const { locale } = useGlobal()
const router = useRouter()
const tempSearch = escapeHTML(keyword || router?.query?.s)
const tempSearch = sanitizeHtml(keyword || router?.query?.s)
const currentSearch = tempSearch
const cRef = useRef(null)

Expand Down
4 changes: 2 additions & 2 deletions themes/matery/components/WordCount.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from 'react'
import escapeHTML from 'escape-html'
import sanitizeHtml from 'sanitize-html';

/**
* 字数统计
Expand Down Expand Up @@ -42,7 +42,7 @@ function deleteHtmlTag(str) {
if (!str) {
return ''
}
str = escapeHTML(str)
str = sanitizeHtml(str)
return str
}

Expand Down
4 changes: 2 additions & 2 deletions themes/next/components/WordCount.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from 'react'
import escapeHTML from 'escape-html'
import sanitizeHtml from 'sanitize-html';

/**
* 字数统计
Expand Down Expand Up @@ -33,7 +33,7 @@ function deleteHtmlTag(str) {
if (!str) {
return ''
}
str = escapeHTML(str)// 去掉所有的html标签和 之类的特殊符合
str = sanitizeHtml(str)// 去掉所有的html标签和 之类的特殊符合
return str
}

Expand Down

0 comments on commit e2b323e

Please sign in to comment.