Skip to content

Commit

Permalink
fix: 🐛 fixed #30 xss problem
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanglun committed Oct 25, 2023
1 parent d9da353 commit 426cbd7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"tailwindcss-animate": "^1.0.5",
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log",
"web-vitals": "^3.1.0",
"xss": "^1.0.14",
"zustand": "^4.3.7"
},
"devDependencies": {
Expand Down
16 changes: 15 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/components/ArticleView/Detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useBearStore } from "@/stores";
import * as dataAgent from "@/helpers/dataAgent";
import { motion, AnimatePresence } from "framer-motion";
import { fetch } from "@tauri-apps/api/http";
import xss from 'xss';

function createMarkup(html: string) {
return { __html: html };
Expand Down Expand Up @@ -57,7 +58,7 @@ export const ArticleDetail = (props: ArticleDetailProps) => {
// try to get the best banner if there is no image in article content
// it will make render slower
setShowBanner(content.search(/<img[^>]+>/gi) === -1);
setPageContent(content);
setPageContent(xss(content));
});

return () => {
Expand Down

0 comments on commit 426cbd7

Please sign in to comment.