tex encoding to mathman now uses encodeURIComponent sans escape

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 <cdiffrient@instructure.com>
Product-Review: brian kirkby <bkirkby@instructure.com>
QA-Review: Collin Parrish <cparrish@instructure.com>
Tested-by: Jenkins
This commit is contained in:
brian kirkby 2017-11-08 23:17:49 -07:00
parent 08b1df3440
commit 804c5a6959
2 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -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: ->