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

Version 2.2.2 uri load bug #1513

Closed
JYLEE1988 opened this issue Oct 20, 2022 · 5 comments · Fixed by #1601
Closed

Version 2.2.2 uri load bug #1513

JYLEE1988 opened this issue Oct 20, 2022 · 5 comments · Fixed by #1601
Labels
help wanted Issues that are up for grabs + are good candidates for community PRs

Comments

@JYLEE1988
Copy link

Describe the bug
uri starting with file:/// is not loaded.
A change occurred in the file creation method in version 2.2.2, which is expected to be related to this.
#1466

override fun map(data: Uri, options: Options): File? {
        if (!isApplicable(data)) return null
        val uri = if (data.scheme == null) data else data.buildUpon().scheme(null).build()
        return File(uri.toString())
    }

In version 2.2.1, the uri image loads well.

To Reproduce
Try to load a uri starting with file:///.
For example file:///storage/emulated/0/android/data/{package-name}/cache/images/temp.jpg

Version
2.2.2

@colinrtwhite colinrtwhite added the help wanted Issues that are up for grabs + are good candidates for community PRs label Oct 20, 2022
@colinrtwhite
Copy link
Member

colinrtwhite commented Oct 20, 2022

Thanks for the report - I'll take a look (or someone else feel free to submit a fix). As a work-around looks like removing the file:// prefix should work?

@JYLEE1988
Copy link
Author

Yes, but in version 2.2.2, the File path is created like this
///storage/emulated/0/android/data/{package-name}/cache/images/temp.jpg

@colinrtwhite
Copy link
Member

colinrtwhite commented Oct 22, 2022

@JYLEE1988 Where are you getting this file URI from? There's already a regression test for file:// URIs, which is passing, which makes me think this is related to the file's location. Is there another way I can reproduce this?

@JYLEE1988
Copy link
Author

@colinrtwhite
The file name contained a +, which seems to be the cause.
When I remove the +, it works fine.

@DjakaTechnology
Copy link

I encountered this problem and ended up downgrading the version to 2.2.1. Here's the URI:
file:///storage/emulated/0/Download/Foo%20Bar/732234b189214a33a84d77609f60012e.jpg

colinrtwhite pushed a commit that referenced this issue Jan 30, 2023
A previous change to fix #1344 to handle # characters in literal no-scheme
paths broke file:// scheme URI parsing by including the entire literal URI in
the file path, which breaks encoded paths (like those with spaces) and URIs
with non-path data (such as query parameters).

This partially reverts the prior fix, so that # is not supported in file://
URIs, requiring the user to either use a no-scheme URI or encode the path,
as # is reserved in URIs for fragment declarations.

Fixes: #1513

Test: FileUriMapperTest#ignoresAfterPathCorrectly
Test: FileUriMapperTest#decodesEncodedPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that are up for grabs + are good candidates for community PRs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants