According to the [escaping portion of the spec](http://www.w3.org/TR/2013/CR-html5-20130806/syntax.html#escapingString), quotes escaping is for attributes. When not in attributes then no quotes should be converted so the `$quotes` here should be replaced with `ENT_NOQUOTES`.