ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 50715] New: Specifying encoding of <sql> task doesn't result in filtering out malformed input
Date Thu, 03 Feb 2011 14:26:23 GMT
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: notifications@ant.apache.org
        ReportedBy: grzegon@poczta.onet.pl


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.

Mime
View raw message