top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Strategy for remove nulls from string parameter values?

+1 vote

I've got a problem where my PostgreSQL database won't store a String that contains a null charcter, and I'm trying to figure out the best place to sanitize the parameter. Your advice is appreciated.

If it were a one-off issue, I'd handle it in the validate() method of the action, but in this case, I feel comfortable declaring that no String parameters in my app should ever contain nulls (or control characters) in their value.

Do you have recommendations about the best place to reject paramters containing nulls app-wide? A normal Java Filter, or perhaps a Struts Interceptor (subclass ParametersInterceptor to create ParameterValueInterceptor)? Or maybe I should sub-class String (ew) and then make my own StrutsTypeConverter? (that last one feels dirty and would require many changes).

This problem came up while attempting to log a message to the database about a login failure for a user that was provided like this:

I'd rather just pretend that the String excluded that 0x00 character, and was "null".

posted Jul 28, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Cleaning parameter values is perfect for an interceptor, and it's pretty easy to do.

For example, we had interceptors that removed trailing spaces, HTML-safed input, etc.

A filter would work as well, but I tend to use S2-specific artifacts when the entire system is S2.

answer Jul 28, 2014 by Dewang Chaudhary
Similar Questions
+2 votes

Remove duplicate characters from given string?

Input: "cutcopypaste"
Output: "uoyase"

+2 votes

I have a multi-line string and I need to remove the very first line from it. How can I do that? I looked at StringIO but I can't seem to figure out how to properly use it to remove the first line.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.