• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Html validator

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, i am having some troubles with your html validator, and i dont have any idea, i will also ask the author of the htmlparser since i dont believe this...

I have your same file, safehtml.java, but i just changed the reading from your systemglobals because somehow i cant do a getservletcontext there, it always returns null.

So i changed it to:

String valid_html = "u, a, img, i, li, ul, font, br, p, b";
String[] tags = valid_html.split(",");

for (int i = 0; i < tags.length; i++) {
this.welcomeTags.add(tags[i].trim());
}

I use the debugger and i see that all those values are added fine to the set.
But somehow, the validator always returns false!

private boolean isTagWelcome(Node node)
{
if (node instanceof TextNode) {
return true;
}

Tag tag = (Tag)node;
String tagname = tag.getTagName();
if (!this.welcomeTags.contains(tagname)) {
return false;
}
...

I added that string to check the value. For example, on the message "hello", tagname is "i" and "i" is in the set, but when contains gets called, it always returns false.

Do you have a possible idea on what i am doing wrong?

[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
baaaaaaaaaah, i am stupid... forgot the toUpperCase() call. Really weird, since both the tags and the set seemed to be in lowercase :?:
[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't checked this well, but i think you are using the same html tags for all fields. IMHO, different tags should be available for different text fields, i.e in the Subject field no tags should be allowed
[originally posted on jforum.net by fjleon]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!