mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #74 from overleaf/revert-73-bg-skip-hash-for-bad-char-replacement
Revert "skip hash check when non-BMP characters replaced"
This commit is contained in:
commit
44c36ee63b
2 changed files with 3 additions and 9 deletions
|
@ -138,13 +138,10 @@ module.exports = UpdateManager =
|
||||||
# 16-bit character of a blackboard bold character (http://www.fileformat.info/info/unicode/char/1d400/index.htm).
|
# 16-bit character of a blackboard bold character (http://www.fileformat.info/info/unicode/char/1d400/index.htm).
|
||||||
# Something must be going on client side that is screwing up the encoding and splitting the
|
# Something must be going on client side that is screwing up the encoding and splitting the
|
||||||
# two 16-bit characters so that \uD835 is standalone.
|
# two 16-bit characters so that \uD835 is standalone.
|
||||||
BAD_CHAR_REGEXP = /[\uD800-\uDFFF]/g
|
|
||||||
for op in update.op or []
|
for op in update.op or []
|
||||||
if op.i? && BAD_CHAR_REGEXP.test(op.i)
|
if op.i?
|
||||||
# Replace high and low surrogate characters with 'replacement character' (\uFFFD)
|
# Replace high and low surrogate characters with 'replacement character' (\uFFFD)
|
||||||
op.i = op.i.replace(BAD_CHAR_REGEXP, "\uFFFD")
|
op.i = op.i.replace(/[\uD800-\uDFFF]/g, "\uFFFD")
|
||||||
# remove any client-side hash because we have modified the content
|
|
||||||
delete update.hash
|
|
||||||
return update
|
return update
|
||||||
|
|
||||||
_addProjectHistoryMetadataToOps: (updates, pathname, projectHistoryId, lines) ->
|
_addProjectHistoryMetadataToOps: (updates, pathname, projectHistoryId, lines) ->
|
||||||
|
|
|
@ -212,7 +212,7 @@ describe "UpdateManager", ->
|
||||||
|
|
||||||
describe "with UTF-16 surrogate pairs in the update", ->
|
describe "with UTF-16 surrogate pairs in the update", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@update = {op: [{p: 42, i: "\uD835\uDC00"}], hash: "f1d2d2f924e986ac86fdf7b36c94bcdf32beec15"}
|
@update = {op: [{p: 42, i: "\uD835\uDC00"}]}
|
||||||
@UpdateManager.applyUpdate @project_id, @doc_id, @update, @callback
|
@UpdateManager.applyUpdate @project_id, @doc_id, @update, @callback
|
||||||
|
|
||||||
it "should apply the update but with surrogate pairs removed", ->
|
it "should apply the update but with surrogate pairs removed", ->
|
||||||
|
@ -223,9 +223,6 @@ describe "UpdateManager", ->
|
||||||
# \uFFFD is 'replacement character'
|
# \uFFFD is 'replacement character'
|
||||||
@update.op[0].i.should.equal "\uFFFD\uFFFD"
|
@update.op[0].i.should.equal "\uFFFD\uFFFD"
|
||||||
|
|
||||||
it "should skip the hash check by removing any hash field present", ->
|
|
||||||
@update.should.not.have.property('hash')
|
|
||||||
|
|
||||||
describe "with an error", ->
|
describe "with an error", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@error = new Error("something went wrong")
|
@error = new Error("something went wrong")
|
||||||
|
|
Loading…
Reference in a new issue