Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid method that assume default platform encoding is suitable. #232

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arturobernalg
Copy link
Member

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.

Copy link
Contributor

@juanpablo-santos juanpablo-santos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes requested

@@ -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 ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@@ -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 ) ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@arturobernalg arturobernalg force-pushed the featue/defaultEncodig branch 2 times, most recently from 95ca649 to 0cd3e4b Compare May 6, 2023 21:12
@arturobernalg arturobernalg force-pushed the featue/defaultEncodig branch 4 times, most recently from 24997f4 to 2a910fe Compare October 19, 2023 20:19
@arturobernalg
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants