-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[iOS] Fix image wrong scale factor when load image from file system #23446
Conversation
This change was originally made because accessing |
@cpojer Hi, can you please give more details about unsafe? 🤔 you mean the |
@zhongwuzw I actually don't know myself, but this is from the original diff that introduced this change:
|
@cpojer 😂 TBO, I don't get the whole meaning about safe things, I add a file url check that ensure path is a valid file system path, can we ping anyone to check this? |
React/Base/RCTUtils.m
Outdated
fileData = [NSData dataWithContentsOfURL:[imageURL URLByAppendingPathExtension:@"png"]]; | ||
} else { | ||
fileData = [NSData dataWithContentsOfURL:imageURL]; | ||
NSString *filePath = imageURL.path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use this instead:
NSString *filePath = [NSString stringWithUTF8String:[imageURL fileSystemRepresentation]];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@zhongwuzw merged commit e5fbd39 into |
Summary: Regression, fix image load from `~/Library` not respect scale factor. Fixes #22383 , the bug comes from [Clean up some URL path handling](998197f). [iOS] [Fixed] - Fix image wrong scale factor when load image from file system Pull Request resolved: #23446 Differential Revision: D14099614 Pulled By: cpojer fbshipit-source-id: eb2267b195a05eb70cdc4671536a4c1d47fb03e2
Summary
Regression, fix image load from
~/Library
not respect scale factor.Fixes #22383 , the bug comes from Clean up some URL path handling.
Changelog
[iOS] [Fixed] - Fix image wrong scale factor when load image from file system
Test Plan
If we have picture
panda
, and has@1x/@2x/@3x
photo, we can load the correct image based on screen scale factor.<Image source={{uri: '~/Library/panda.jpg', width: 300, height: 300}} />