The most intelligent Java IDE
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Reply Bookmark it! Watch this topic JavaRanch » Forums » This Site » Ranch Office
 
RSS feed
 
New topic
Author

Error in HTML escaping

Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

When I post this sentence:

List<List<?>> lists = new ArrayList<List<?>>();

and the checkbox "Disable HTML in this message" is off then it will result in:

List<List><?>> lists = new ArrayList<List><?>>();

When the checkbox is checked then it works fine.

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Messages: 486

I see no difference between the two. What is everyone else seeing?

SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

I see
List [Less-than sign] List [More-than sign] [Less-than sign] ? [More-than sign][More-than sign]
while it should be:
List [Less-than sign] List [Less-than sign] ? [More-than sign][More-than sign]

I hope you can read it

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Messages: 486

OK, I lied. I see it now.

So many signs and no TV and no beer make Homer something...something...

SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Messages: 1163

I think this is known issue. Search this forum.

This message was edited 1 time. Last update was at by Vikas Kapoor

Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

In my first search attempt (before I posted) I found nothing. In my second search I found this.
But using &lt; instead of < doesn't sound like a solution to this problem.

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
Ulf Dittmer
Sheriff

Joined: Mar 22, 2005
Messages: 26787

This is a known issue with the forum software. It uses a library for sorting out the HTML, and that library gets confused by Java generics (which also use angle brackets, but have rather different notions about what constitutes wellformedness). So far, we haven't been able to get anyone to look into this :-(

Java web chartsImageJ PluginsSpecification URLsJava FAQs
Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

I looked at the code of the forum software. I found a lot of undocumented code and somewhat old technologies which I'm not familiar with.

I also found this:


That looks right. So I viewed ViewCommon.java:260

That looks also right but above that method I found this:

And that is wrong because the less than sign is missing a semicolon
I didn't test if correcting this would fix our problem. But it's a start

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
Christophe Verré
Bartender

Joined: Nov 24, 2005
Messages: 11133

Thank you. A semi-colon is missing indeed. But it appears that this method is not used. The problem comes from a third party library, not by jforum.

[SCWCD Wall of Fame] [SCBCD Wall of Fame]
All roads lead to JavaRanch
Ulf Dittmer
Sheriff

Joined: Mar 22, 2005
Messages: 26787

That's an interesting find, but a quick grep through the source shows that this method isn't called from anywhere (maybe not too surprising since it's called "espaceHtml" instead of "escapeHtml" - not too obvious :-)

No, the problem is somewhere within the http://htmlparser.sourceforge.net/ library, which has bugs, but is abandoned now. I recall that we fixed at least one bug in it (for which luckily a patch had been posted on SourceForge).

Java web chartsImageJ PluginsSpecification URLsJava FAQs
Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

I don't know if the method is used. Eclipse couldn't find references. However the method could be called from the "view" because java code is used there and I don't think eclipse can track that.

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
Ulf Dittmer
Sheriff

Joined: Mar 22, 2005
Messages: 26787

Just to show that the library has other problems as well: This is the RSS feed for the Ranch Office forum (the link for which you can find on the forum home page). The entry for this topic starts with "When I post this sentence: >" - which has an extra closing angle bracket; that can be found in many RSS feed entries. It's trying to sanitize HTML by adding angle brackets where it thinks they're missing, but is thrown off by the generics notation, since that isn't nested in the same way as HTML/XML.

Java web chartsImageJ PluginsSpecification URLsJava FAQs
Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

I had some posts that had an > at the end. I thought I had made a typo but now I know it was the library. I did a test run with the library version 1.5 (currently used by jforum) and I can confirm that the library is to blame.

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

Version 1.6 doesn't solve it and 2.0SNAPSHOT has a different architecture. If I have time for it I'll look into it tomorrow.

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

The snapshot version doesn't have a different architecture but my IDE thought it would be funny to mark valid imports as invalid. Now the bad news the snapshot version doesn't solve it
Now I'm going to bed. It's 2.30 AM

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
Christophe Verré
Bartender

Joined: Nov 24, 2005
Messages: 11133

Good night

[SCWCD Wall of Fame] [SCBCD Wall of Fame]
All roads lead to JavaRanch
Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

I've been thinking (to be honest I've been dreaming about the problem ). A simple solution would be to set "Disable HTML in this message" default to true because 99.9% of the posts is without HTML.

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
Ulf Dittmer
Sheriff

Joined: Mar 22, 2005
Messages: 26787

Hmm ... it is true that for most HTML tags we allow, UBB alternatives exist. Still, it would be nice to fix that library for the RSS feeds.

Java web chartsImageJ PluginsSpecification URLsJava FAQs
Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

That is true. I tried to put the text in <![CDATA[ tags but that didn't help >

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
Wouter Oet
Ranch Hand

Joined: Oct 25, 2008
Messages: 500

But will my suggestion be implemented?

"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
Ulf Dittmer
Sheriff

Joined: Mar 22, 2005
Messages: 26787

That checkbox is based on the "Allow HTML" setting in your profile, so you can turn it off by default for all of your posts. Given that -thanks to UBB- there is really not much need for HTML posting, I think it makes sense to change the profile to not allow HTML by default for new accounts, though. Most people will probably leave it turned off and never notice the difference :-)

Java web chartsImageJ PluginsSpecification URLsJava FAQs
Ulf Dittmer
Sheriff

Joined: Mar 22, 2005
Messages: 26787

Generics code is now properly displayed, no matter what the "Disable HTML" setting is set to.

Java web chartsImageJ PluginsSpecification URLsJava FAQs
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » This Site » Ranch Office
 
RSS feed
 
New topic
MyEclipse Enterprise Workbench