diff --git a/projects/sys/default.wmf.yaml b/projects/sys/default.wmf.yaml
index 9f9f9ef7..6f51e13d 100644
--- a/projects/sys/default.wmf.yaml
+++ b/projects/sys/default.wmf.yaml
@@ -11,7 +11,6 @@ paths:
- path: sys/parsoid.js
options:
host: '{{options.parsoid.host}}'
- disabled_storage: '{{options.parsoid.disabled_storage}}'
response_cache_control: '{{options.purged_cache_control}}'
grace_ttl: '{{default(options.parsoid.grace_ttl, 86400)}}'
# A list of pages that we don't want to re-render on each edit.
diff --git a/sys/parsoid.js b/sys/parsoid.js
index 653e6d7e..057617b4 100644
--- a/sys/parsoid.js
+++ b/sys/parsoid.js
@@ -6,23 +6,11 @@ const URI = HyperSwitch.URI;
const HTTPError = HyperSwitch.HTTPError;
const uuidv1 = require('uuid').v1;
-const uuidUtils = require('../lib/uuidUtils');
const mwUtil = require('../lib/mwUtil');
const spec = HyperSwitch.utils.loadSpec(`${__dirname}/parsoid.yaml`);
-// Temporary work-around for Parsoid issue
-// https://phabricator.wikimedia.org/T93715
-function normalizeHtml(html) {
- return html && html.toString &&
- html.toString()
- .replace(/ about="[^"]+"(?=[/> ])|]{0,128}>/g, '');
-}
-function sameHtml(a, b) {
- return normalizeHtml(a) === normalizeHtml(b);
-}
-
/**
* Makes sure we have a meta tag for the tid in our output
* @param {string} html original HTML content
@@ -45,26 +33,6 @@ function extractTidMeta(html) {
return tidMatch && (tidMatch[1] || tidMatch[2]);
}
-/**
- * Checks whether the content has been modified since the timestamp
- * in `if-unmodified-since` header of the request
- * @param {Object} req the request
- * @param {Object} res the response
- * @return {boolean} true if content has beed modified
- */
-function isModifiedSince(req, res) {
- try {
- if (req.headers['if-unmodified-since']) {
- const jobTime = Date.parse(req.headers['if-unmodified-since']);
- const revInfo = mwUtil.parseETag(res.headers.etag);
- return revInfo && uuidUtils.getDate(revInfo.tid) >= jobTime;
- }
- } catch (e) {
- // Ignore errors from date parsing
- }
- return false;
-}
-
/** HTML resource_change event emission
* @param {HyperSwitch} hyper the hyperswitch router object
* @param {Object} req the request
@@ -72,6 +40,7 @@ function isModifiedSince(req, res) {
* @return {Object} update response
*/
function _dependenciesUpdate(hyper, req, newContent = true) {
+ // FIXME: we still need to do this purging!
const rp = req.params;
return mwUtil.getSiteInfo(hyper, req)
.then((siteInfo) => {
@@ -90,15 +59,6 @@ function _dependenciesUpdate(hyper, req, newContent = true) {
});
}
-function compileReRenderBlacklist(blacklist) {
- const result = {};
- blacklist = blacklist || {};
- Object.keys(blacklist).forEach((domain) => {
- result[domain] = mwUtil.constructRegex(blacklist[domain]);
- });
- return result;
-}
-
class ParsoidService {
constructor(options) {
this._initOpts(options);
@@ -120,9 +80,7 @@ class ParsoidService {
_initOpts(opts = {}) {
this.options = opts;
this.parsoidUri = opts.host || opts.parsoidHost;
- this.options.stash_ratelimit = opts.stash_ratelimit || 5;
delete this.options.parsoidHost;
- this._blacklist = compileReRenderBlacklist(opts.rerenderBlacklist);
if (!this.parsoidUri) {
throw new Error('Parsoid module: the option host must be provided!');
}
@@ -132,47 +90,6 @@ class ParsoidService {
}
}
- _isStorageDisabled(domain) {
- if (!this.options.disabled_storage) {
- return false;
- }
-
- if (this.options.disabled_storage === true) {
- return true;
- }
-
- return this.options.disabled_storage[domain] || this.options.disabled_storage.default;
- }
-
- _checkStashRate(hyper, req) {
- if (!hyper.ratelimiter) {
- return;
- }
- if (hyper._rootReq.headers['x-request-class'] !== 'external') {
- return;
- }
- if (!((req.query && req.query.stash) || (req.body && req.body.stash))) {
- return;
- }
- const key = `${hyper.config.service_name}.parsoid_stash|` +
- `${hyper._rootReq.headers['x-client-ip']}`;
- if (hyper.ratelimiter.isAboveLimit(key, this.options.stash_ratelimit)) {
- hyper.logger.log('warn/parsoid/stashlimit', {
- key,
- rate_limit_per_second: this.options.stash_ratelimit,
- message: 'Stashing rate limit exceeded'
- });
- throw new HTTPError({
- status: 429,
- body: {
- type: 'request_rate_exceeded',
- title: 'Stashing rate limit exceeded',
- rate_limit_per_second: this.options.stash_ratelimit
- }
- });
- }
- }
-
/**
* Assembles the request that is to be used to call the Parsoid service
*
@@ -190,35 +107,6 @@ class ParsoidService {
};
}
- /**
- * Gets the URI of a bucket for the latest Parsoid content
- *
- * @param {string} domain the domain name
- * @param {string} title the article title
- * @return {HyperSwitch.URI}
- */
- _getLatestBucketURI(domain, title) {
- return new URI([
- domain, 'sys', 'key_value', 'parsoidphp', title
- ]);
- }
-
- /**
- * Gets the URI of a bucket for stashing Parsoid content. Used both for stashing
- * original HTML/Data-Parsoid for normal edits as well as for stashing transforms
- *
- * @param {string} domain the domain name
- * @param {string} title the article title
- * @param {number} revision the revision of the article
- * @param {string} tid the TID of the content
- * @return {HyperSwitch.URI}
- */
- _getStashBucketURI(domain, title, revision, tid) {
- return new URI([
- domain, 'sys', 'key_value', 'parsoidphp-stash', `${title}:${revision}:${tid}`
- ]);
- }
-
getFormatAndCheck(format, hyper, req) {
return this.getFormat(format, hyper, req)
.tap((res) => {
@@ -234,174 +122,6 @@ class ParsoidService {
});
}
- /**
- * Get full content from the stash bucket.
- * @param {HyperSwitch} hyper the hyper object to route requests
- * @param {string} domain the domain name
- * @param {string} title the article title
- * @param {number} revision the article revision
- * @param {string} tid the render TID
- * @return {Promise