File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

data characters that can break the html

 
Jesus Angeles
Ranch Hand
Posts: 2068
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

(The data I will display is dynamic and will come from a database. It can contain special characters. I heard another team's html was broken by an & character, and I will also read that database and display its data.)

What characters can damage the html?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you input your data into the db it probably should be escaped/encoded.

Any character that can be in html markup. <>"'/\ etc

If you are not escapeing user input, I am sure there is a big security hole with JavaScript injection in your application.

Eric
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The data was formerly used primarily only in mainframe, i.e., CICS, batch jcl, etc. That is most likely the reason why this never became a problem.

Maybe a layer that translates between these 2 worlds will do. Like a utility class method that input the data from MVS and returns a web-friendly string.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using a database, you are probably using a server-side language. If it is servlets and JSP then use of the JSTL <cut> action will automatically encode output properly.

I will disagree with Eric with regards to encoding the data sent to the database. That limits it usefulness for environments other than the web. The data should be encoded on output.
[ October 16, 2006: Message edited by: Bear Bibeault ]
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My installation is only J2EE 1.3.

I researched but not able to get an answer if JSTL is required by specs for containers to support, for J2EE 1.3.

Anyone know?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSTL 1.0 is compatible with JSP 1.2, JSTL 1.1 is compatible with JSP 2.0.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course it would also be very easy to write your own custom tag to perform this encoding should you not wish to adopt JSTL.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic