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

Unable to load images whose URL contains special characters ø, å, æ #1896

Closed
GSala opened this issue May 3, 2017 · 3 comments
Closed
Labels

Comments

@GSala
Copy link

GSala commented May 3, 2017

Glide Version:
3.7.0

Integration libraries:
Retrofit 2.2.0 which contains a dependency to OkHttp

Device/Android Version:
Nexus 5

Issue details / Repro steps / Use case background:
Trying to load a URL like this one: http://www.dlg.dk/-/media/DLG/Corporate/Landmand/Økologi/DLG-Okologi_haand.ashx fails with 404 - Not Found. Pasting the same URL in the browser resolves just fine.
Relevant: #133

Glide load line / GlideModule (if any) / list Adapter code (if any):

Glide.with(imageView.getContext())
                .load(imageUrl)
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .into(imageView);

Layout XML:
Not relevant

Stack trace / LogCat:

Request failed 404: Not Found
@sjudd
Copy link
Collaborator

sjudd commented May 8, 2017

Feel free to take a look at the logic and send a PR with changes. Thanks!

https://github.com/bumptech/glide/blob/master/library/src/main/java/com/bumptech/glide/load/model/GlideUrl.java#L86

@TWiStErRob
Copy link
Collaborator

I actually had no problem loading it:

String url = "http://www.dlg.dk/-/media/DLG/Corporate/Landmand/Økologi/DLG-Okologi_haand.ashx";
Glide
		.with(this)
		.load(url)
		.into(imageView)
;

image

Make sure that the special characters are not escaped in any way when they're in the String that you pass in to Glide. That means that for this specific url url.charAt(49) == 216, i.e. this character: http://www.fileformat.info/info/unicode/char/d8/index.htm

Log.wtf("TEST", String.valueOf(url.charAt(49) == 216));

If you're hardcoding this url, like I did, make sure your file encoding is UTF-8, similarly if you're getting it from a server make sure the transfer has the correct encoding, and that the JSON/XML/whatever is also decoded correctly.

@TWiStErRob
Copy link
Collaborator

I also tried OkHttp 2, and it works too. Note that just having OkHttp on the classpath via an unrelated (Retrofit) transitive dependency won't make Glide use it. You have to add the integration library as well:
https://github.com/bumptech/glide/wiki/Integration-Libraries

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

No branches or pull requests

3 participants