https://issues.apache.org/bugzilla/show_bug.cgi?id=50715

           Summary: Specifying encoding of <sql> task doesn't result in
                    filtering out malformed input
           Product: Ant
           Version: 1.8.2
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: [email protected]
        ReportedBy: [email protected]


Observed problem:
If you specify the 'encoding' attribute of the <sql> task, you would expect
that the task fails when some illegal characters are passed as input. Current
behavior is to replace them with U+FFFD REPLACEMENT CHARACTER, which is useless
in the database world.

Background:
Stackoverflow question:
http://stackoverflow.com/questions/4886460/why-does-us-ascii-encoding-accept-non-us-ascii-characters

Suggested solution: 
When encoding is specified, explicitly specify 'CharsetDecoder' with
CodingErrorAction.REPORT as the input to InputStreamReader instead of simple
encoding.

Semi-patch:
reader = (encoding == null) ? new InputStreamReader(is) : new
InputStreamReader(is, encoding);

could be replaced with:

if (encoding == null) {
   reader = new InputStreamReader(is);
} else {
   CharsetDecoder decoder = Charset.forName(encoding).newDecoder();
   decoder.onMalformedInput(CodingErrorAction.REPORT);
   reader = new InputStreamReader(bais, decoder);  
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to