From 804c5a69596ba0d0b151b335177c3f5e379f7b76 Mon Sep 17 00:00:00 2001 From: brian kirkby Date: Wed, 8 Nov 2017 23:17:49 -0700 Subject: [PATCH] tex encoding to mathman now uses encodeURIComponent sans escape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes CORE-45 test plan: - config local canvas to use local mathman - in equation editor, paste the pound symbol: £ - save the equation - verify the pound symbol is rendred in the image Change-Id: I24cfc8788de784e21214c39b65c919b4b2117ff9 Reviewed-on: https://gerrit.instructure.com/132330 Reviewed-by: Clay Diffrient Product-Review: brian kirkby QA-Review: Collin Parrish Tested-by: Jenkins --- .../views/tinymce/EquationEditorView.coffee | 10 +++++++++- .../views/tinymce/EquationEditorViewSpec.coffee | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/coffeescripts/views/tinymce/EquationEditorView.coffee b/app/coffeescripts/views/tinymce/EquationEditorView.coffee index 3670b0caaa8..c3aec6572fb 100644 --- a/app/coffeescripts/views/tinymce/EquationEditorView.coffee +++ b/app/coffeescripts/views/tinymce/EquationEditorView.coffee @@ -189,12 +189,20 @@ define [ restoreCaret: -> @editor.selection.moveToBookmark(@prevSelection) + # the following is here to make it easier to unit test + @doubleEncodeEquationForUrl: (text) -> + encodeURIComponent encodeURIComponent text + + # the following will be called by onSubmit below + doubleEncodeEquationForUrl: (text) -> + @constructor.doubleEncodeEquationForUrl text + onSubmit: (event) => event.preventDefault() text = @getEquation() altText = "LaTeX: #{ text }" - url = "/equation_images/#{ encodeURIComponent escape text }" + url = "/equation_images/#{ @doubleEncodeEquationForUrl text }" $img = $(document.createElement('img')).attr src: url alt: altText diff --git a/spec/coffeescripts/views/tinymce/EquationEditorViewSpec.coffee b/spec/coffeescripts/views/tinymce/EquationEditorViewSpec.coffee index a78a6dbf4d7..ebf1fbc9b3f 100644 --- a/spec/coffeescripts/views/tinymce/EquationEditorViewSpec.coffee +++ b/spec/coffeescripts/views/tinymce/EquationEditorViewSpec.coffee @@ -20,6 +20,14 @@ define [ 'compiled/views/tinymce/EquationEditorView' ], ($, EquationEditorView) -> + QUnit.module "EquationEditorView#doubleEncodeEquationForUrl", + setup: -> + teardown: -> + + test "encodes pound sign using utf-8", -> + equation = "£" + equal(EquationEditorView.doubleEncodeEquationForUrl(equation), "%25C2%25A3") + QUnit.module "EquationEditorView#getEquationText", setup: -> teardown: ->