Questions tagged [stringescapeutils]

'StringEscapeUtils' is a java class in the Text subproject of the Commons project from Apache Software Foundation (ASF). The class was formerly in the Lang subproject. The purpose of the class is to escape and unescape strings for Java, Java Script, HTML and XML. Use this tag for questions regarding the StringEscapeUtils class.

StringEscapeUtils is a java class in the Apache Commons Text project. The class was originally part of the Commons Lang project but was migrated to the Commons Text project. The class is used to convert characters in strings to their equivalent entity and vice-versa. This is known as escaping (or unescaping) characters. For example the [HTML] entity for the & (ampersand) character is &. Hence class StringEscapeUtils contains methods for converting & to & as well as methods for converting & to &. The class also contains methods for escaping and unescaping characters in JavaScript and XML as well as HTML.

82 questions
0
votes
1 answer

stringescapeutils unescape en dash with code –

I am getting an xml from a third party system in utf-8 format and I am trying to parse it properly and save it in my db. For example below are 4 lines of the xml that I am getting and when I try to use unescapeXML it works for everything except en…
anuj
  • 201
  • 5
  • 16
0
votes
1 answer

Replacing of HTML 5 codes with equivalent characters in Java

I'm trying to replace symbols of HTML 5 using StringEscapeUtils.unescapeHtml4(), but I still have a lot of symbols which haven't been replaced such as " "," &". What will you recommend to use?
Lucky_girl
  • 4,543
  • 6
  • 42
  • 82
0
votes
1 answer

Can I escape both HTML and JavaScript at the same time?

For example, in my Java servlet project I return the text that user entered on the site to the same site (and on multiple places inside HTML and JavaScript, potential XSS attack). Is it correct to use Apache StringEscapeUtils class to escape both…
Šime Tokić
  • 700
  • 1
  • 9
  • 22
0
votes
1 answer

Exclude five basic XML entities when using StringEscapeUtils.escapeHtml()

I am trying to StringEscapeUtils.escapeHtml(String string) to convert the special characters on my web page to HTML entities. But it also escapes the five basic XML entities which are <, >, ", ', and &, which makes my HTML not render correctly since…
mcspiral
  • 147
  • 1
  • 10
0
votes
0 answers

When we click on back button we are getting some escape character in ckeditor

I am using CKeditor in Java for sending email functionality. But when I am trying to add an HTML by clicking source, there is no issue in first case but after clicking Next and going Back to the same page, I am getting some Special characters as ÃÂ…
0
votes
1 answer

Escaping special characters in XML 1.0 using java

A third party system is sending an XML file having '&' character in data. They are not even using CDATA. (Poorly designed system it is). In Java, how to read that XML file and escape the & and other special characters (<, >, ", ')? I know this…
Abhishek
  • 2,095
  • 2
  • 21
  • 25
0
votes
1 answer

Why I can't use the org.apache.commons.lang.StringEscapeUtils to convert this String containing character as &apos and è?

I am trying to do some experiment with the org.apache.commons.lang.StringEscapeUtils class but I am finding some difficulties. I have the following situation in my code: String notNormalized = "c'è"; System.out.println("NOT NORMALIZED:…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
0
votes
1 answer

vietnamese text send to javascript from objective c gets distorted

I am sending a json string from Objective C to javascript code. But the text string gets distorted {"data":{"type":"new","id":"xyz","text":"Thêm nhóm ês","userid":["16"]},"type":"hello","action":"update"} The vietnamese string Thêm nhóm ês gets…
Swati
  • 2,870
  • 7
  • 45
  • 87
0
votes
1 answer

How to Get back the URLEncoded feature after BufferReader process to Decode and display the special character?

Page URL is "//host:port/abc/testr-email.html?ans1=NÃO&ans2=NÃO&ans3=NÃO&ans4=SIM&ans5=NÃO&cntr=1&ts=5&pname=TAAA" after using the URLEncoder.encode(String,"UTF-8"); on the page path became as below with the special characters…
krish
  • 469
  • 1
  • 15
  • 34
0
votes
1 answer

use string escape utility function with using Apache common library (StringEscapeUtils)

I want to know if there is any other way to output the same results without using Apache common Library. I did this way but i need to know how to do it without any external imports. Thanks a lot ahead. import…
Karkool
  • 41
  • 2
  • 9
0
votes
0 answers

Escape String in Grails to avoid JSON error

I have few strings like "12.10 On-Going Submission of ""Made Up"" Samples." 10. PRODUCT STANDARDS; APPROVAL. which I render as JSON in grails. The quotes and any other possible special characters are giving me trouble i.e they make the JSON…
krs8785
  • 1,097
  • 2
  • 14
  • 24
0
votes
1 answer

AntLR - String Recognition Error

I have an ANTLR grammar file with the string definition as below STRING : '"' (EscapeSequence | ~('\\'|'"') )* '"' ; fragment EscapeSequence : '\\' . ; But this Lexer rule ignore the escape character at the first instance of the quotes. The…
Sudeep Hazra
  • 118
  • 15
0
votes
1 answer

Issue with StringEscapeUtils call and JSP form submit value

I am passing some param with value from my JSP file and before that I am using Apache StringEscapeUtils to avoid any XSS attack script execution using param value for example, if somebody inserting value like this and gain access Cross script test…
0
votes
2 answers

how to convert html string in java string

I'm retrieving an XML from the Google Maps Directions API. The result is something like this: OK I-40 W
DamianFox
  • 902
  • 3
  • 20
  • 45
0
votes
1 answer

Unescaping entities in Java

I have a string which might have already been escaped. I want to unescape it and get the string in UTF-8. I am thinking of applying all the unescape functions from Apache commons lang StringEscapeUtils My question is will it have any effect in the…
Sudar
  • 18,954
  • 30
  • 85
  • 131