Cscott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/58243


Change subject: Clean up use of (broken) jshashes; use built-in 'crypto' 
package instead.
......................................................................

Clean up use of (broken) jshashes; use built-in 'crypto' package instead.

jshashes is completely broken at the moment (see
https://github.com/h2non/jsHashes/issues/6 ).  Using crypto makes a few
more tests pass (and a few more fail) due to the totally broken
caching (all cache keys identical) in mediawiki.TokenTransformManager.js.

Change-Id: I593dfe031d43b47f42807cdd27bb74dd6dc22b17
---
M js/lib/mediawiki.TokenTransformManager.js
M js/package.json
2 files changed, 6 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/43/58243/1

diff --git a/js/lib/mediawiki.TokenTransformManager.js 
b/js/lib/mediawiki.TokenTransformManager.js
index 557a2b2..e7faa77 100644
--- a/js/lib/mediawiki.TokenTransformManager.js
+++ b/js/lib/mediawiki.TokenTransformManager.js
@@ -17,7 +17,7 @@
 
 var events = require('events'),
        LRU = require("lru-cache"),
-       jshashes = require('jshashes'),
+       crypto = require('crypto'),
        Util = require('./mediawiki.Util.js').Util;
 
 
@@ -1310,9 +1310,11 @@
        // the cache key instead, as this would allow sharing of all expansions 
of
        // a template with identical expanded parameters independent of its
        // containing frame.
-       var MD5 = new jshashes.MD5();
+       var MD5 = function(text) {
+               return crypto.createHash('md5').update(text).digest('hex');
+       };
        if ( args._cacheKey === undefined ) {
-               args._cacheKey = MD5.hex( JSON.stringify( args ) );
+               args._cacheKey = MD5( JSON.stringify( args ) );
        }
 
        if ( parentFrame ) {
@@ -1320,7 +1322,7 @@
                this.depth = parentFrame.depth + 1;
                // FIXME: Since our args are unexpanded, the expanded value 
might
                // depend on the parent frame.
-               this._cacheKey = MD5.hex( parentFrame._cacheKey + 
args._cacheKey );
+               this._cacheKey = MD5( parentFrame._cacheKey + args._cacheKey );
        } else {
                this.parentFrame = null;
                this.depth = 0;
diff --git a/js/package.json b/js/package.json
index 1e54566..e787040 100644
--- a/js/package.json
+++ b/js/package.json
@@ -8,7 +8,6 @@
                "request": "2.x.x",
                "querystring": "0.x.x",
                "path": "0.x.x",
-               "jshashes": "1.x.x",
                "optimist": "0.x.x",
                "assert": "0.x.x",
                "domino": "~1.0.9",

-- 
To view, visit https://gerrit.wikimedia.org/r/58243
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I593dfe031d43b47f42807cdd27bb74dd6dc22b17
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to