phax / as2-lib

A generic Java AS2 library, servlet and server
107 stars 43 forks source link

Escape dollar signs used in DispositionType text #19

Closed EdMcBane closed 8 years ago

EdMcBane commented 8 years ago

Exceptions and exception stack traces can contain literal dollar signs, such as names of anonymous inner classes, that get incorrectly expanded by AbstractParameterParser.format.

This causes as2lib to fail and not send a proper MDN back in certain conditions.

phax commented 8 years ago

Thanks for the note - tricky one ;-) To be more generic I decided to add a getTextEscaped method in DispositionException and using it at the only place where the old getText was used. Can you please check if that also fixes your problem. Thx

EdMcBane commented 8 years ago

Hello. In my case, I got an invalid key exception in AbstractParser.parseFormat, since it contained unescaped dollar signs from the stacktrace of the exception caught in AS2ReceiverHandler. Your patch escapes ALL dollar signs in the DispositionException text, and so sidesteps my problem, but I'm afraid it also prevents proper placeholders (e.g. from AbstractActiveNetModule.DISP_VALIDATION_FAILED) to be expanded.

phax commented 8 years ago

You are aboslutely right - my mistake. I changed it to your idea by explicitly escaping only the 3 special cases. Anyway I added a helper method to do that. Thanks again!!!