This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line!
See this thread for details.
Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

data characters that can break the html

 
Ranch Hand
Posts: 2107
  • 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?
 
author
Posts: 15385
6
  • 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: 2107
  • 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.
 
Marshal
Posts: 67361
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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 <c:out> 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: 2107
  • 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
Marshal
Posts: 67361
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Marshal
Posts: 67361
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
expectation is the root of all heartache - shakespeare. tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!