Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
troyeguo committed Mar 18, 2023
1 parent aadaf63 commit 51b72c2
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 21 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ brew install --cask koodo-reader
docker-compose up -d
```

<a href="https://flathub.org/apps/details/io.github.troyeguo.koodo-reader"><img height="50" alt="Download on Flathub" src="https://flathub.org/assets/badges/flathub-badge-en.png"/></a>

## Screenshot

<div align="center">
Expand Down
2 changes: 2 additions & 0 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ brew install --cask koodo-reader
docker-compose up -d
```

<a href="https://flathub.org/apps/details/io.github.troyeguo.koodo-reader"><img height="50" alt="Download on Flathub" src="https://flathub.org/assets/badges/flathub-badge-en.png"/></a>

## 截图

<div align="center">
Expand Down
2 changes: 2 additions & 0 deletions README_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ brew install --cask koodo-reader
docker-compose up -d
```

<a href="https://flathub.org/apps/details/io.github.troyeguo.koodo-reader"><img height="50" alt="Download on Flathub" src="https://flathub.org/assets/badges/flathub-badge-en.png"/></a>

## Capturas de tela

<div align="center">
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"axios": "^0.19.2",
"bing-translate-api": "^2.7.0",
"copy-text-to-clipboard": "^2.2.0",
"dompurify": "^3.0.1",
"electron-is-dev": "^1.1.0",
"electron-store": "^8.0.1",
"epub-cfi-resolver": "^1.0.2",
Expand Down
10 changes: 5 additions & 5 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@
width: 100%;
}
</style>
<!-- <script>
<script>
var script = document.createElement("script");
if (document.location.href.indexOf("localhost:3000") > -1) {
script.src = "http://127.0.0.1:5500/dist/kookit.umd.js";
} else {
script.src = "/lib/kookit/kookit.min.js";
script.src = "%PUBLIC_URL%/lib/kookit/kookit.min.js";
}
document.head.appendChild(script);
</script> -->
</script>
<title>Koodo Reader</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>

<div id="root"></div>
<canvas id="the-canvas"></canvas>
<script
<!-- <script
type="text/javascript"
src="%PUBLIC_URL%/lib/kookit/kookit.min.js"
></script>
></script> -->
<script
type="text/javascript"
src="%PUBLIC_URL%/lib/JSZip/jszip.min.js"
Expand Down
10 changes: 5 additions & 5 deletions public/lib/kookit/kookit.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/components/bookCoverItem/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import RecordLocation from "../../utils/readUtils/recordLocation";
import { isElectron } from "react-device-detect";
import EmptyCover from "../emptyCover";
import Parser from "html-react-parser";
import * as DOMPurify from "dompurify";

import { Trans } from "react-i18next";
import BookUtil from "../../utils/fileUtils/bookUtil";
import toast from "react-hot-toast";
Expand Down Expand Up @@ -197,7 +199,7 @@ class BookCoverItem extends React.Component<BookCoverProps, BookCoverState> {
<div className="book-cover-item-desc">
<Trans>Description</Trans>:&nbsp;
{this.props.book.description ? (
Parser(this.props.book.description)
Parser(DOMPurify.sanitize(this.props.book.description))
) : (
<Trans>Empty</Trans>
)}
Expand Down
6 changes: 5 additions & 1 deletion src/components/dialogs/actionDialog/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { ActionDialogProps } from "./interface";
import AddTrash from "../../../utils/readUtils/addTrash";
import FileSaver from "file-saver";
import Parser from "html-react-parser";
import * as DOMPurify from "dompurify";

import ShelfUtil from "../../../utils/readUtils/shelfUtil";
import toast from "react-hot-toast";
import BookUtil from "../../../utils/fileUtils/bookUtil";
Expand Down Expand Up @@ -204,7 +206,9 @@ class ActionDialog extends React.Component<ActionDialogProps> {
<Trans>Description</Trans>:
</p>
<div className="action-dialog-book-detail">
{Parser(this.props.currentBook.description || " ")}
{Parser(
DOMPurify.sanitize(this.props.currentBook.description) || " "
)}
</div>
</div>
</div>
Expand Down
14 changes: 9 additions & 5 deletions src/components/dialogs/settingDialog/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ class SettingDialog extends React.Component<
currentThemeIndex: window._.findLastIndex(themeList, {
name: StorageUtil.getReaderConfig("themeColor"),
}),
storageLocation: isElectron
? localStorage.getItem("storageLocation")
? localStorage.getItem("storageLocation")
: window
.require("electron")
.ipcRenderer.sendSync("storage-location", "ping")
: "",
};
}
componentDidMount() {
Expand Down Expand Up @@ -180,6 +187,7 @@ class SettingDialog extends React.Component<
toast.error(this.props.t("Change Failed"));
}
localStorage.setItem("storageLocation", path.filePaths[0]);
this.setState({ storageLocation: path.filePaths[0] });
document.getElementsByClassName(
"setting-dialog-location-title"
)[0].innerHTML =
Expand Down Expand Up @@ -342,11 +350,7 @@ class SettingDialog extends React.Component<
</span>
</div>
<div className="setting-dialog-location-title">
{localStorage.getItem("storageLocation")
? localStorage.getItem("storageLocation")
: window
.require("electron")
.ipcRenderer.sendSync("storage-location", "ping")}
{this.state.storageLocation}
</div>
</>
)}
Expand Down
1 change: 1 addition & 0 deletions src/components/dialogs/settingDialog/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface SettingInfoState {
isPreventTrigger: boolean;
isMergeWord: boolean;
appSkin: string;
storageLocation: string;
isImportPath: boolean;
isOpenBook: boolean;
isExpandContent: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/containers/lists/bookList/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,4 @@ class BookList extends React.Component<BookListProps, BookListState> {
}
}

export default withRouter(BookList);
export default withRouter(BookList as any);
4 changes: 2 additions & 2 deletions src/containers/panels/navigationPanel/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SearchBox from "../../../components/searchBox";
import Parser from "html-react-parser";
import EmptyCover from "../../../components/emptyCover";
import StorageUtil from "../../../utils/serviceUtils/storageUtil";

import * as DOMPurify from "dompurify";
import CFI from "epub-cfi-resolver";
import { getTooltip } from "../../../utils/commonUtil";
class NavigationPanel extends React.Component<
Expand Down Expand Up @@ -108,7 +108,7 @@ class NavigationPanel extends React.Component<
}
}}
>
{Parser(item.excerpt)}
{Parser(DOMPurify.sanitize(item.excerpt))}
</li>
);
});
Expand Down
3 changes: 2 additions & 1 deletion src/containers/panels/operationPanel/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class OperationPanel extends React.Component<
handleExit() {
StorageUtil.setReaderConfig("isFullscreen", "no");
this.props.handleReadingState(false);
this.props.handleSearch(false);
window.speechSynthesis.cancel();
ReadingTime.setTime(this.props.currentBook.key, this.props.time);
this.handleExitFullScreen();
Expand Down Expand Up @@ -206,4 +207,4 @@ class OperationPanel extends React.Component<
}
}

export default withRouter(OperationPanel);
export default withRouter(OperationPanel as any);
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4754,6 +4754,11 @@ domhandler@^4.0.0, domhandler@^4.2.0, domhandler@^4.3.1:
dependencies:
domelementtype "^2.2.0"

dompurify@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.0.1.tgz#a0933f38931b3238934dd632043b727e53004289"
integrity sha512-60tsgvPKwItxZZdfLmamp0MTcecCta3avOhsLgPZ0qcWt96OasFfhkeIRbJ6br5i0fQawT1/RBGB5L58/Jpwuw==

domutils@^1.5.1, domutils@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a"
Expand Down

0 comments on commit 51b72c2

Please sign in to comment.