Skip to content

Commit

Permalink
Codegen: fixed text string escaping problem (now use base64 encoding)
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldsteinlechner committed Nov 15, 2018
1 parent 39f0df4 commit 322e9d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ bin/Debug
*.g.fs
/.vs/aardvark.media/v15/*.suo
/.vs
/src/Scratch/11 - GeoJsonViewer/*.user
3 changes: 2 additions & 1 deletion src/Aardvark.UI/Javascript.fs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ module JSExpr =
| l -> l |> String.concat "\r\n"

| InnerText(target,text) ->
sprintf "%s.textContent = \"%s\";" (toStringInternal target) (escape text)
let base64 = System.Text.Encoding.UTF8.GetBytes text |> System.Convert.ToBase64String
sprintf "%s.textContent = top.window.atob(\"%s\");" (toStringInternal target) base64

| AppendChild(parent,inner) ->
let parent = toStringInternal parent
Expand Down
11 changes: 11 additions & 0 deletions src/Scratch/07 - UIUpdatePerformance/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,19 @@ let dependencies =
{ url = "support.js"; name = "support"; kind = Script }
]

let illegalString = """
abc
new line then \²³²]³\nsuper2929
k' " , . / \ ; : & % $ # @ *
"""

let view (model : MModel) =
div [] [
br []
text illegalString
br []
text (sprintf "%A" (Some dependencies))
br []
onBoot "doIt(__ID__)" (div [clazz "jsUpdater"] [text "nothing"])
text "Hello World"
br []
Expand Down

0 comments on commit 322e9d1

Please sign in to comment.