Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Characters unnecessarily escaped by toString method of XML elements #57

Open
som-snytt opened this issue Jun 6, 2015 · 6 comments · Fixed by #279
Open

Characters unnecessarily escaped by toString method of XML elements #57

som-snytt opened this issue Jun 6, 2015 · 6 comments · Fixed by #279

Comments

@som-snytt
Copy link
Contributor

https://issues.scala-lang.org/browse/SI-5645

@raymank26
Copy link

The buildString method of Text class seems broken(see

Utility.escape(data, sb)
). The possible workaround is to define VerbatimText class and override buildString method without escape functionality.

Maintainers, is PR needed?

@schmitch
Copy link

schmitch commented Sep 3, 2015

Currently this is totally expected since XML has two different "values" one is CDATA and one is PCDATA.
PCDATA means escaped values and all XML values are automatically escaped if you don't wrap your data with a CDATA field.

@som-snytt
Copy link
Contributor Author

My comment on the scala ticket was:

toString encodes, but text does not. Pick one. Or, I wonder if ScalaTags has special smarts for scripters, embedding in comments etc.

This suggestion may be out of scope, but the API is confusing. toString is not normally used for specialized string representations, arguably.

@lutzh
Copy link

lutzh commented Dec 20, 2017

It seems nothing in the XML specification says that double quotes " are an illegal character within the text of an element. So generally encoding them as "&quot" seems somewhat arbitrary.

@coreyoconnor
Copy link

I found this to be an effective work around:

      val verbatimAtom = new xml.Atom(verbatimText) {                                                                                              
        override def buildString(sb: StringBuilder): StringBuilder =                                                                                
          sb.append(importMapStr)                                                                                                                   
      }                                                                                                                                             

@SethTisue
Copy link
Member

fix was reverted because it caused #413 — someone want to see if they can solve them both at once?

@SethTisue SethTisue removed this from the 2.0 milestone Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants