Skip to content

Commit

Permalink
Update Zotero to f0cff95
Browse files Browse the repository at this point in the history
Merge contains following changes:

commit f0cff95
Author: Dan Stillman <[email protected]>
Date:   Sun Feb 16 14:45:41 2020 -0500

    Don't include `script` and `style` elements in innerText

    JSDOM doesn't support `innerText` [1], so our shim was just forwarding
    `textContent`. Instead, remove `script` and `style` elements, which
    won't do the same thing as in the browser but will hopefully remove most
    unwanted content.

    Addresses zotero#111

    [1] jsdom/jsdom#1245

Bug: T245092
Change-Id: I5e24a0f1813960802e50c38f4b80f9bc0f23ef95
  • Loading branch information
mvolz committed Feb 24, 2020
1 parent 74ca904 commit 7297a18
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/translators
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "translation-server",
"version": "2.0.1",
"version": "2.0.3",
"description": "Zotero translation server",
"license": "AGPL-3.0-only",
"main": "index.js",
Expand Down
8 changes: 7 additions & 1 deletion src/translation/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ Object.defineProperty(Attr.interface.prototype, 'innerText', {
});
var Node = require('jsdom/lib/jsdom/living/generated/Node');
Object.defineProperty(Node.interface.prototype, 'innerText', {
get: function() { return this.textContent },
get: function() {
// innerText in the browser is more sophisticated, but this removes most unwanted content
// https://github.com/jsdom/jsdom/issues/1245#issuecomment-584677454
var el = this.cloneNode(true);
el.querySelectorAll('script,style').forEach(s => s.remove())
return el.textContent
},
set: function(value) { this.textContent = value },
configurable: true,
});
Expand Down

0 comments on commit 7297a18

Please sign in to comment.