Skip to content

Commit

Permalink
change the getSafParameter handles filenames with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcohn committed Sep 8, 2020
1 parent d5a4457 commit 80d4b9f
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,12 @@ private static String getSafParameter(Context context, Uri uri, String openMode)
}

// workaround for https://issuetracker.google.com/issues/162440528: ANDROID_CREATE_DOCUMENT generating file names like "transcode.mp3 (2)"
if (displayName.lastIndexOf(' ') > displayName.lastIndexOf('.')) {
displayName = displayName.substring(0, displayName.lastIndexOf(' '));
if (displayName.lastIndexOf('.') > 0 && displayName.lastIndexOf(' ') > displayName.lastIndexOf('.')) {
String extension = displayName.substring(displayName.lastIndexOf('.'), displayName.lastIndexOf(' '));
displayName += extension;
}
return "\"saf:" + fd + "/" + displayName + "\"";
// spaces can break argument list parsing, see https://github.com/alexcohn/mobile-ffmpeg/pull/1#issuecomment-688643836
return "saf:" + fd + "/" + displayName.replace(' ', ' ');
}

public static String getSafParameterForRead(Context context, Uri uri) {
Expand Down

0 comments on commit 80d4b9f

Please sign in to comment.