You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "netliomax25-code (via GitHub)" <gi...@apache.org> on 2026/06/02 07:31:03 UTC

[PR] decode yaml/toml/csv input streams as utf-8 [groovy]

netliomax25-code opened a new pull request, #2585:
URL: https://github.com/apache/groovy/pull/2585

   YamlSlurper, TomlSlurper and CsvSlurper wrap their stream and path inputs in `new InputStreamReader(stream)`, so bytes are decoded with the JVM default charset. Under a non-UTF-8 default (Windows-1252, Shift_JIS, or a JVM started with `-Dfile.encoding`), UTF-8 `0xC3 0xA9` reads back as `U+00C3 U+00A9` instead of `U+00E9`. YAML and TOML mandate UTF-8 and JsonSlurper already defaults byte/stream input to it, so pin these readers to UTF-8.


-- 
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: notifications-unsubscribe@groovy.apache.org

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


Re: [PR] decode yaml/toml/csv input streams as utf-8 [groovy]

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert commented on PR #2585:
URL: https://github.com/apache/groovy/pull/2585#issuecomment-4658855371

   Issue created: https://issues.apache.org/jira/browse/GROOVY-12074


-- 
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: notifications-unsubscribe@groovy.apache.org

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


Re: [PR] decode yaml/toml/csv input streams as utf-8 [groovy]

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert commented on PR #2585:
URL: https://github.com/apache/groovy/pull/2585#issuecomment-4659345816

   Merged, thanks!


-- 
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: notifications-unsubscribe@groovy.apache.org

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


Re: [PR] decode yaml/toml/csv input streams as utf-8 [groovy]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2585:
URL: https://github.com/apache/groovy/pull/2585#discussion_r3380024871


##########
subprojects/groovy-csv/src/main/java/groovy/csv/CsvSlurper.java:
##########
@@ -155,7 +156,7 @@ public List<Map<String, String>> parse(Reader reader) {
      * @return a list of maps (one per row)
      */
     public List<Map<String, String>> parse(InputStream stream) {
-        return parse(new InputStreamReader(stream));
+        return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
     }

Review Comment:
   This change fixes charset handling for InputStream/Path parsing, but there’s no regression test that would fail under a non-UTF-8 default charset (e.g., Windows). Consider adding a test that parses UTF-8 bytes containing a non-ASCII character (e.g., 'café') via the InputStream and Path overloads and asserts the character round-trips correctly.



##########
subprojects/groovy-toml/src/main/java/groovy/toml/TomlSlurper.java:
##########
@@ -78,7 +79,7 @@ public Object parse(Reader reader) {
      * @return the root node of the parsed tree of Nodes
      */
     public Object parse(InputStream stream) {
-        return parse(new InputStreamReader(stream));
+        return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
     }

Review Comment:
   This change fixes charset handling for InputStream/Path parsing, but there’s no regression test that would fail under a non-UTF-8 default charset (e.g., Windows). Consider adding a spec test that parses UTF-8 bytes containing a non-ASCII character (e.g., 'café' encoded as 0x63 0x61 0x66 0xC3 0xA9) via the InputStream/Path overloads and asserts the character round-trips correctly.



##########
subprojects/groovy-yaml/src/main/java/groovy/yaml/YamlSlurper.java:
##########
@@ -77,7 +78,7 @@ public Object parse(Reader reader) {
      * @return the root node of the parsed tree of Nodes
      */
     public Object parse(InputStream stream) {
-        return parse(new InputStreamReader(stream));
+        return parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
     }

Review Comment:
   This change fixes charset handling for InputStream/Path parsing, but there’s no regression test that would fail under a non-UTF-8 default charset (e.g., Windows). Consider adding a spec test that parses UTF-8 bytes containing a non-ASCII character (e.g., 'café' encoded as 0x63 0x61 0x66 0xC3 0xA9) via the InputStream/Path overloads and asserts the character round-trips correctly.



-- 
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: notifications-unsubscribe@groovy.apache.org

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


Re: [PR] decode yaml/toml/csv input streams as utf-8 [groovy]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #2585:
URL: https://github.com/apache/groovy/pull/2585#issuecomment-4659230503

   ## ✅ All tests passed ✅
   
   🏷️ Commit: 29a806d8e30156e76dbe30c636ceeae2a3e97308
   ▶️ Tests:  100323 executed
   ⚪️ Checks: 22/22 completed
   
   ---
   _Learn more about TestLens at [testlens.app](https://testlens.app)._
   


-- 
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: notifications-unsubscribe@groovy.apache.org

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


Re: [PR] decode yaml/toml/csv input streams as utf-8 [groovy]

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert closed pull request #2585: decode yaml/toml/csv input streams as utf-8
URL: https://github.com/apache/groovy/pull/2585


-- 
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: notifications-unsubscribe@groovy.apache.org

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