You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by GitBox <gi...@apache.org> on 2022/10/08 06:56:02 UTC

[GitHub] [jspwiki] arturobernalg opened a new pull request, #232: Avoid method that assume default platform encoding is suitable.

arturobernalg opened a new pull request, #232:
URL: https://github.com/apache/jspwiki/pull/232

   Dm: Reliance on default encoding (DM_DEFAULT_ENCODING)
   
   Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behavior to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jspwiki.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Avoid method that assume default platform encoding is suitable. [jspwiki]

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on PR #232:
URL: https://github.com/apache/jspwiki/pull/232#issuecomment-1771658384

   Hi @juanpablo-santos,
   
   I've made changes to avoid reliance on default platform encoding,  I think this would be a nice addition to the 2.12.2 release. Please take a look.
   
   Best,
   Arturo 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jspwiki.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Avoid method that assume default platform encoding is suitable. (jspwiki)

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on code in PR #232:
URL: https://github.com/apache/jspwiki/pull/232#discussion_r1186746895


##########
jspwiki-util/src/main/java/org/apache/wiki/util/Serializer.java:
##########
@@ -89,7 +89,7 @@ public static String serializeToBase64(final Map< String, Serializable > map ) t
         
         // Transform to Base64-encoded String
         final byte[] result = Base64.getEncoder().encode( bytesOut.toByteArray() );
-        return new String( result ) ;
+        return new String( result, StandardCharsets.UTF_8 ) ;

Review Comment:
   changed



##########
jspwiki-util/src/main/java/org/apache/wiki/util/FileUtil.java:
##########
@@ -108,8 +108,8 @@ public static String runSimpleCommand( final String command, final String direct
         final StringBuilder result = new StringBuilder();
         final Process process = Runtime.getRuntime().exec( command, null, new File( directory ) );
 
-        try( final BufferedReader stdout = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
-             final BufferedReader stderr = new BufferedReader( new InputStreamReader( process.getErrorStream() ) ) ) {
+        try( final BufferedReader stdout = new BufferedReader( new InputStreamReader( process.getInputStream(), StandardCharsets.UTF_8 ) );

Review Comment:
   changed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jspwiki.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Avoid method that assume default platform encoding is suitable. (jspwiki)

Posted by "juanpablo-santos (via GitHub)" <gi...@apache.org>.
juanpablo-santos commented on code in PR #232:
URL: https://github.com/apache/jspwiki/pull/232#discussion_r1148020915


##########
jspwiki-util/src/main/java/org/apache/wiki/util/FileUtil.java:
##########
@@ -108,8 +108,8 @@ public static String runSimpleCommand( final String command, final String direct
         final StringBuilder result = new StringBuilder();
         final Process process = Runtime.getRuntime().exec( command, null, new File( directory ) );
 
-        try( final BufferedReader stdout = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
-             final BufferedReader stderr = new BufferedReader( new InputStreamReader( process.getErrorStream() ) ) ) {
+        try( final BufferedReader stdout = new BufferedReader( new InputStreamReader( process.getInputStream(), StandardCharsets.UTF_8 ) );

Review Comment:
   the only method using this one is expecting it to be on ISO-8859. Perhaps passing as an argument `engine.getContentEncoding()` and use it, ensuring it's used throughout the entire call, would be better?



##########
jspwiki-util/src/main/java/org/apache/wiki/util/Serializer.java:
##########
@@ -89,7 +89,7 @@ public static String serializeToBase64(final Map< String, Serializable > map ) t
         
         // Transform to Base64-encoded String
         final byte[] result = Base64.getEncoder().encode( bytesOut.toByteArray() );
-        return new String( result ) ;
+        return new String( result, StandardCharsets.UTF_8 ) ;

Review Comment:
   same as above?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jspwiki.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org