Skip to content

Commit

Permalink
Fix #1023: HTML escaping in HtmlTextWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarmil committed Sep 13, 2018
1 parent 51aac76 commit 318ad1e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/compiler/WebSharper.Core/Resources.fs
Expand Up @@ -22,6 +22,7 @@ module WebSharper.Core.Resources

open System
open System.IO
open System.Net
open System.Reflection

module CT = ContentTypes
Expand All @@ -43,9 +44,6 @@ type HtmlTextWriter(w: TextWriter, indentString: string) =
let mutable tagStack = System.Collections.Generic.Stack()
let currentAttributes = ResizeArray()

let encodeText (text: string) =
text // TODO dotnet: do encode

new (w) = new HtmlTextWriter(w, "\t")

override this.Write(c: char) = w.Write(c)
Expand Down Expand Up @@ -88,16 +86,18 @@ type HtmlTextWriter(w: TextWriter, indentString: string) =
this.Write(">")

member this.WriteEncodedText(text: string) =
this.Write(encodeText text)
WebUtility.HtmlEncode(text, w)

member this.AddAttribute(name: string, value: string) =
currentAttributes.Add(struct (name, value))

member this.WriteAttribute(name: string, value: string) =
this.WriteAttribute(name, value, false)

member this.WriteAttribute(name: string, value: string, encoded: bool) =
this.Write(" {0}=\"{1}\"", name, encodeText value)
this.Write(" {0}=\"", name)
WebUtility.HtmlEncode(value, w)
this.Write("\"")

#endif

Expand Down

0 comments on commit 318ad1e

Please sign in to comment.