Merge pull request #728 from hgiesel/mungehtml

Move "remove null bytes" and "reverse url formatting" functionality to editor_will_munge_html hook
This commit is contained in:
Damien Elmes 2020-08-10 16:33:56 +10:00 committed by GitHub
commit d079307536
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 9 deletions

View file

@ -197,14 +197,14 @@ jobs:
uses: actions/cache@v1
with:
path: ${{ matrix.CARGO_INDEX_DIR }}
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/requirements.*') }}-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/Cargo.toml') }}-22-
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/requirements.*') }}-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/Cargo.toml') }}-23-
- name: Cache cargo registry
if: matrix.python == '3.7'
uses: actions/cache@v1
with:
path: ${{ matrix.CARGO_REGISTRY_DIR }}
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/requirements.*') }}-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/Cargo.toml') }}-22-
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/requirements.*') }}-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/Cargo.toml') }}-23-
- name: Cache cargo target
if: matrix.python == '3.7'
@ -218,7 +218,7 @@ jobs:
uses: actions/cache@v1
with:
path: ${{ github.workspace }}${{ matrix.SEP }}rslib${{ matrix.SEP }}target
key: ${{ runner.os }}-cargo-rslib-${{ hashFiles('**/requirements.*') }}-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.BUILD_TYPE }}-22-
key: ${{ runner.os }}-cargo-rslib-${{ hashFiles('**/requirements.*') }}-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.BUILD_TYPE }}-23-
- name: Cache cargo rspy
if: matrix.python == '3.7'

View file

@ -388,12 +388,9 @@ class Editor:
if nid != self.note.id:
print("ignored late blur")
return
txt = self.mungeHTML(txt)
# misbehaving apps may include a null byte in the text
txt = txt.replace("\x00", "")
# reverse the url quoting we added to get images to display
txt = self.mw.col.media.escapeImages(txt, unescape=True)
self.note.fields[ord] = txt
self.note.fields[ord] = self.mungeHTML(txt)
if not self.addMode:
self.note.flush()
self.mw.requireReset()
@ -1203,5 +1200,17 @@ def munge_html(txt, editor):
return "" if txt in ("<br>", "<div><br></div>") else txt
def remove_null_bytes(txt, editor):
# misbehaving apps may include a null byte in the text
return txt.replace("\x00", "")
def reverse_url_quoting(txt, editor):
# reverse the url quoting we added to get images to display
return editor.mw.col.media.escapeImages(txt, unescape=True)
gui_hooks.editor_will_use_font_for_field.append(fontMungeHack)
gui_hooks.editor_will_munge_html.append(munge_html)
gui_hooks.editor_will_munge_html.append(remove_null_bytes)
gui_hooks.editor_will_munge_html.append(reverse_url_quoting)