Skip to content

Commit

Permalink
fix: book with single quotes cannot be opened
Browse files Browse the repository at this point in the history
  • Loading branch information
Anxcye committed Nov 23, 2024
1 parent a71ae4f commit 6b83be9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
## Unreleased
- Feat: Drag to group books
- Fix: Bottom navigation bar covers menu bar
- Fix: Windows no longer deletes original files when importing
- Fix: Books with single quotes cannot be opened

- 新增:拖拽实现书籍分组
- 修复:底部导航栏覆盖菜单栏
- 修复: Windows 端导入时删除原文件的问题
- 修复: 包含单引号的书籍无法打开

## 1.2.0 2024-11-17
❗Anx-Reader has changed the Android version signature, please back up and reinstall Anx-Reader❗
Expand Down
12 changes: 8 additions & 4 deletions lib/utils/webView/webview_initial_variable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ void webviewInitialVariable(

const minWebviewVersion = 92;

String replaceSingleQuote(String value) {
return value.replaceAll("'", "\\'");
}

final script = '''
console.log(navigator.userAgent)
const webviewVersion = navigator.userAgent.match(/Chrome\\/(\\d+)/)?.[1]
Expand All @@ -37,12 +41,12 @@ void webviewInitialVariable(
window.flutter_inappwebview.callHandler('webviewVersion', webviewVersion)
}
const importing = $importing
const url = '$url'
let initialCfi = '$cfi'
const url = '${replaceSingleQuote(url)}'
let initialCfi = '${replaceSingleQuote(cfi)}'
let style = {
fontSize: ${bookStyle.fontSize},
fontName: '$fontName',
fontPath: '$fontPath',
fontName: '${replaceSingleQuote(fontName)}',
fontPath: '${replaceSingleQuote(fontPath)}',
letterSpacing: ${bookStyle.letterSpacing},
spacing: ${bookStyle.lineHeight},
paragraphSpacing: ${bookStyle.paragraphSpacing},
Expand Down

0 comments on commit 6b83be9

Please sign in to comment.