From c773b5d07611ca917bee760231e3b45422a54ed1 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Thu, 12 Oct 2017 15:42:09 +0300 Subject: [PATCH] Remove a brittle test which can make a pad inaccessible, switch from transformFunction to (new) patchTransformer and add another DOM.normalize() which is needed --- www/common/sframe-app-framework.js | 20 ++++---------------- www/pad/inner.js | 1 + 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index 9935cf1d8..0a22fefc7 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -236,21 +236,6 @@ define([ cpNfInner.metadataMgr.updateMetadata(extractMetadata(newContent)); newContent = normalize(newContent); contentUpdate(newContent); - - if (!readOnly) { - var newContent2NoMeta = normalize(contentGetter()); - var newContent2StrNoMeta = JSONSortify(newContent2NoMeta); - var newContentStrNoMeta = JSONSortify(newContent); - - if (newContent2StrNoMeta !== newContentStrNoMeta) { - console.log('err'); - console.error("shjson2 !== shjson"); - console.log(newContent2StrNoMeta); - console.log(newContentStrNoMeta); - Cryptpad.errorLoadingScreen(Messages.wrongApp); - throw new Error(); - } - } } else { title.updateTitle(Cryptpad.initialName || title.defaultTitle); evOnDefaultContentNeeded.fire(); @@ -346,7 +331,8 @@ define([ }).nThen(function (waitFor) { cpNfInner = common.startRealtime({ // really basic operational transform - transformFunction: options.transformFunction || JsonOT.transform, + //transformFunction: options.transformFunction || JsonOT.validate, + patchTransformer: options.patchTransformer || JsonOT.patchTransformer, // cryptpad debug logging (default is 1) // logLevel: 0, validateContent: options.validateContent || function (content) { @@ -355,6 +341,8 @@ define([ return true; } catch (e) { console.log("Failed to parse, rejecting patch"); + console.log(e.stack); + console.log(content); return false; } }, diff --git a/www/pad/inner.js b/www/pad/inner.js index 9f14d813a..11b36a62b 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -410,6 +410,7 @@ define([ framework.setContentGetter(function () { displayMediaTags(framework, inner, mediaTagMap); + inner.normalize(); return Hyperjson.fromDOM(inner, isNotMagicLine, hjsonFilters); });