Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

data characters that can break the html

 
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Look! It's Leonardo da Vinci! And he brought a tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic