Skip to content

UrlResource.getFilename() decodes + sign to a space #36267

@sumanparia

Description

@sumanparia

https://github.com/spring-projects/spring-framework/blob/main/spring-core/src/main/java/org/springframework/core/io/UrlResource.java

While reading the files inside jar I am using ResourcePatternResolver.getResources.
Its returning UrlResource[].

But if any file name having + sign then UrlResource.getFilename removing the + sign and replacing it with space.

sample+filename.json

I think its because of

https://github.com/spring-projects/spring-framework/blob/3666ad9d7fb0e905322b81debda7b2e2e822a4e0/spring-core/src/main/java/org/springframework/core/io/UrlResource.java#L372C3-L372C90

return (filename != null ? URLDecoder.decode(filename, StandardCharsets.UTF_8) : null);

Why we are using decode and any work around?

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: waiting-for-feedbackWe need additional information before we can continuestatus: waiting-for-triageAn issue we've not yet triaged or decided on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions