Skip to content

Commit

Permalink
Improvement: Updated Sanitizer (#1129)
Browse files Browse the repository at this point in the history
* update: GitHub workflow-dispatch

* fix: separate app for testing

* fix: separate app for testing

* fix: separate app for testing

* fix: new css for chapter content

* fix: separate app for testing

* branch: new test branch

* Enhancement: added more CSS

* build

* Enhancement: git build

* Fix: git build

* merge

* Enhancement: added more CSS

* dev: update build.yml

* dev: update sanitizer

* sanitizer: updated sanitizer

* dev: update index css

* dev: update sanitizer

* dev: update sanitizer

* sanitizer: update sanitizer

* sanitizer: added more allowed tags

* filter: fix filters

* progress-tracking: initial commit

* progress-tracking: implemented tracking

* progress-tracking: update tracker

* progress-tracking: complete rework

* progress-tracking: improvements

* sanitizer: update sanitizer

* sanitizer: block text-align

* sanitizer: update img

* sanitizer: reworked

* sanitizer: reworked

* sanitizer: fixed lazyloaded images

* sanitizer: revert sanitizer

* sanitizer: remove alt and title from images

* sanitizer: revert other changes

* sanitizer: fix

* sanitizer: update
  • Loading branch information
Batorian authored Mar 1, 2025
1 parent 4e3f817 commit 0f5eee1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
key: ${{ runner.os }}-cache-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-cache-npm-
- name: Install Dependencies
run: |
npm install
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
sed -i 's/LNReader/LNReader-r${{ env.COMMIT_COUNT }}(${{ env.COMMIT_ID }})/g' android/app/src/main/res/values/strings.xml
cd android && ./gradlew assembleRelease --no-daemon -PcustomAppId=com.rajarsheechatterjee.LNReader.commit_${{ env.COMMIT_ID }}
mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/LNReader-r${{ env.COMMIT_COUNT }}\(${{ env.COMMIT_ID }}\)-customID.apk
- name: Upload Custom APK
env:
COMMIT_COUNT: ${{ env.COMMIT_COUNT }}
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@
<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" />

</application>
</manifest>
</manifest>
2 changes: 1 addition & 1 deletion android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<resources>
<string name="app_name">LNReader</string>
</resources>
</resources>
4 changes: 2 additions & 2 deletions pidcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def parse_start_proc(line):
return line_package, '', line_pid, line_uid, ''
return None

def tag_in_tags_regex(tag, tags):
def tag_in_tags_regex(tag, tags):
return any(re.match(r'^' + t + r'$', tag) for t in map(str.strip, tags))

ps_command = base_adb_command + ['shell', 'ps']
Expand Down Expand Up @@ -407,4 +407,4 @@ def tag_in_tags_regex(tag, tags):
output(linebuf)

if (output_file):
output_file.close()
output_file.close()
30 changes: 12 additions & 18 deletions src/screens/reader/utils/sanitizeChapterText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,23 @@ export const sanitizeChapterText = (
chapterName: string,
html: string,
): string => {
let text = sanitizeHtml(html, {
allowedTags: sanitizeHtml.defaults.allowedTags.concat([
'img',
'i',
'em',
'b',
'a',
'div',
'ol',
'li',
'title',
]),
// Sanitize the HTML to remove unwanted elements
let sanitizedHtml = sanitizeHtml(html, {
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'title']),
allowedAttributes: {
'img': ['src', 'class', 'id'],
'a': ['href', 'class', 'id'],
'div': ['class', 'id'],
'p': ['class', 'id'],
'ol': ['reversed', 'start', 'type'],
a: ['href', 'class', 'id'],
div: ['class', 'id'],
img: ['src', 'class', 'id'],
ol: ['reversed', 'start', 'type'],
p: ['class', 'id'],
span: ['class', 'id'],
},
allowedSchemes: ['data', 'http', 'https', 'file'],
});

// Return the sanitized and updated HTML or an error message
return (
text ||
sanitizedHtml ||
getString('readerScreen.emptyChapterMessage', {
pluginId,
novelName,
Expand Down

0 comments on commit 0f5eee1

Please sign in to comment.