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

Regression: CameraRoll.getPhotos causes StringIndexOutOfBoundsException when filename contains a # #24468

Closed
nohorjo opened this issue Apr 16, 2019 · 0 comments · Fixed by react-native-cameraroll/react-native-cameraroll#54
Labels
API: CameraRoll Bug Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. Resolution: Locked This issue was locked by the bot.

Comments

@nohorjo
Copy link

nohorjo commented Apr 16, 2019

💥 Regression Report

Android only

When an image on the device has a # in its name, CameraRoll.getPhotos crashes.
It was introduced by this commit 54534e7
By using URLConnection.guessContentTypeFromName it expects any hashes to be after the extension, which then causes a StringOutOfBoundsException here

According to this commit d9711e2 this issue is known but there is no fix/workaround for it.

57009123_642344259557455_3266118424387911680_n

Last working version

Worked up to version:
0.58.6

Stopped working in version:
0.59.0-rc.0
0.59.0

To Reproduce

  1. Ensure there's an image on the device with a # in the name eg. Internal Storage/DCIM/Camera/bad#image.jpg
  2. In your js call CameraRoll.getPhotos({first: N, assetType: 'Photos'}) with N large enough to load the bad image

Expected Behavior

The promise resolves with the image meta-data

Code Example

import {
    CameraRoll
} from 'react-native';

(async () => {
    const N = 100;
    let after;

    while (true) {
        const {
            page_info: {
                has_next_page,
                end_cursor,
            }
        } = await CameraRoll.getPhotos({
            first: N,
            assetType: 'Photos',
            after,
        });
        if (!has_next_page) {
            break;
        }
        after = end_cursor;
    }
    // Will crash before getting to here
})();

Environment

info
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 707.79 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.2 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 22, 23, 24, 25, 26, 27, 28
Build Tools: 22.0.1, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.0, 28.0.2, 28.0.3
System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5014246
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.4 => 0.59.3
npmGlobalPackages:
react-native-cli: 1.3.0
react-native-git-upgrade: 0.2.7

@nohorjo nohorjo added Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. Type: Bug Report labels Apr 16, 2019
facebook-github-bot pushed a commit that referenced this issue May 10, 2019
Summary:
Fixes this issue:
#24468
It was incorrectly closed by a fix on react-native-community CameraRoll implementation. CameraRoll in react-native still crashes when finding a file with # sign

[Android] [Fix] - Fix Android Camera Roll crash on mime type guessing
Pull Request resolved: #24780

Reviewed By: mdvacca

Differential Revision: D15281062

Pulled By: lunaleaps

fbshipit-source-id: ca3364c8478d9bfc9a0a6657b531ffb384145d8c
@facebook facebook locked as resolved and limited conversation to collaborators May 7, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API: CameraRoll Bug Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. Resolution: Locked This issue was locked by the bot.
Projects
None yet
3 participants