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

Incorrectly assumed encoding when accessing content with project.resources.text.fromUri on Windows #25213

Open
hsz opened this issue May 29, 2023 · 3 comments
Labels
a:bug has:workaround Indicates that the issue has a workaround in:resource-handler resources files

Comments

@hsz
Copy link
Contributor

hsz commented May 29, 2023

Expected Behavior

Fetch text file in proper UTF-8 encoding.

Current Behavior

Gradle downloads resources from the remote location in incorrect encoding — probably falls back to the OS default encoding instead of the one provided by the server or UTF-8.

Context (optional)

No response

Steps to Reproduce

Create and run the following task:

tasks {
    register<Sync>("testEncoding") {
from(project.resources.text.fromUri("https://gist.githubusercontent.com/hsz/5bf5c84a6a2e36f2a6716f28f287783c/raw/b0ba02f53f5937643701b848cb3728b0f3dfb144/updates.xml"))
        into(temporaryDir)
    }
}

This task should create the build/tmp/testEncoding/wrappedInternalText....txt file with the following content:

Here's a bullet character: •

Instead, it provides a file with:

Here's a bullet character: �

Gradle version

8.1.1

Build scan URL (optional)

Windows 11

Your Environment (optional)

No response

@hsz
Copy link
Contributor Author

hsz commented May 31, 2023

Just with the project.resources.text.fromUri("...").asFile("UTF-8"), the content is resolved in the expected encoding.

@eskatos eskatos added in:remoting has:workaround Indicates that the issue has a workaround and removed to-triage labels May 31, 2023
@eskatos
Copy link
Member

eskatos commented May 31, 2023

Thank you for providing a valid reproducer.

The issue is in the backlog of the relevant team, but the existence of a workaround makes it non-critical, so it might take a while before a fix is made.

@hsz
Copy link
Contributor Author

hsz commented May 31, 2023

Please also see #25237

@eskatos eskatos added in:resource-handler resources files and removed in:remoting labels Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug has:workaround Indicates that the issue has a workaround in:resource-handler resources files
Projects
None yet
Development

No branches or pull requests

3 participants