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 "spyhunter99 (via GitHub) via dev" <de...@jspwiki.apache.org>.
spyhunter99 merged PR #232:
URL: https://github.com/apache/jspwiki/pull/232
--
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 "spyhunter99 (via GitHub)" <gi...@apache.org>.
spyhunter99 commented on code in PR #232:
URL: https://github.com/apache/jspwiki/pull/232#discussion_r2505192976
##########
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:
honestly it should probably all be standardized on utf8. is there a reason for this specific setup to use (basically) ascii? we have a ton of internationalization code within jspwiki, this just seems a bit off
--
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-6340879763
Hi @juanpablo-santos, @spyhunter99, sorry for the long delay. The requested changes are done: I rebased this PR on the current master and reworked it, so it is ready for another look.
The encoding used for the output of the external command is now the wiki one (engine.getContentEncoding()), as suggested, and it is applied throughout the call. While doing this I found that ExternalDiffProvider kept re-encoding the output as ISO-8859-1 and decoding it again, which turned characters outside Latin-1 (for example the euro sign) into "?". The output is now decoded once, with the encoding the temporary files are written with. ExternalDiffProviderTest fails on master and passes with this change.
On the Base64 String in Serializer: Base64 output is always ASCII, which is the same byte sequence in UTF-8, so the choice does not restrict internationalization; the attribute values are inside the serialized bytes before they are Base64 encoded. The method keeps its signature, so no public API changes. FileUtil#runSimpleCommand keeps its two argument variant and gains one that takes the charset.
--
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