X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2FDownloadFile.java;h=0a1d1dcab81a713c2a0b7f090f85f109453867e6;hp=d8fabdea03de86675a17c1c199901622899850b8;hb=015b8984ce72dc3c4c541d8caab6ef78d4fb6a17;hpb=9a1be859899abe1eb75637c1ea6b817afee723b1 diff --git a/app/src/main/java/com/stoutner/privacybrowser/DownloadFile.java b/app/src/main/java/com/stoutner/privacybrowser/DownloadFile.java index d8fabdea..0a1d1dca 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/DownloadFile.java +++ b/app/src/main/java/com/stoutner/privacybrowser/DownloadFile.java @@ -27,7 +27,6 @@ import android.content.DialogInterface; import android.net.Uri; import android.os.Bundle; // `android.support.v7.app.AlertDialog` uses more of the horizontal screen real estate versus `android.app.AlertDialog's` smaller width. -import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -49,8 +48,8 @@ public class DownloadFile extends DialogFragment { Bundle argumentsBundle = new Bundle(); String fileNameString; - if (!contentDisposition.isEmpty()) { // Extract `fileNameString` from `contentDisposition` using the substring beginning after `filename="` and ending one character before the end of `contentDisposition`. - fileNameString = contentDisposition.substring(contentDisposition.indexOf("filename=\"") + 10, contentDisposition.length() - 1); + if (!contentDisposition.isEmpty()) { // Extract `fileNameString` from `contentDisposition` using the substring beginning after `filename="` and ending with the next `"`. + fileNameString = contentDisposition.substring(contentDisposition.indexOf("filename=\"") + 10, contentDisposition.indexOf("\"", contentDisposition.indexOf("filename=\"") + 10)); } else { // `contentDisposition` is empty, so use the last path segment of the URL as the file name. Uri downloadUri = Uri.parse(urlString); fileNameString = downloadUri.getLastPathSegment();