Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1831)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/download/ChromeDownloadDelegateTest.java

Issue 1717783002: Fix an issue that download filename from content disposition is not sanitized (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pass localized default download file name Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/download/ChromeDownloadDelegateTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/ChromeDownloadDelegateTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/ChromeDownloadDelegateTest.java
index e16201d83c11edb368914eb7c919a9f420b46e48..0c12de91ded72c8b42ae08f93ce00a324400a064 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/ChromeDownloadDelegateTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/download/ChromeDownloadDelegateTest.java
@@ -41,53 +41,6 @@ public class ChromeDownloadDelegateTest extends ChromeActivityTestCaseBase<Chrom
}
/**
- * Test to make sure {@link ChromeDownloadDelegate#fileName} returns the
- * right file for different URLs and MIME types.
- */
- @SmallTest
- @Feature({"Download"})
- public void testFileName() {
- String testUrl = "http://server.com/file.pdf";
- assertEquals("file.pdf", ChromeDownloadDelegate.fileName(testUrl, "application/pdf", ""));
- assertEquals("file.pdf", ChromeDownloadDelegate.fileName(testUrl, "", ""));
-
- // .php is an unknown MIME format extension.
- // This used to generate file.php even when the MIME type was set.
- // http://code.google.com/p/chromium/issues/detail?id=134396
- testUrl = "http://server.com/file.php";
-
- assertEquals("file.pdf", ChromeDownloadDelegate.fileName(testUrl, "application/pdf", ""));
- assertEquals("file.php", ChromeDownloadDelegate.fileName(testUrl, "", ""));
-
- // .xml is a known MIME format extension.
- testUrl = "http://server.com/file.xml";
- assertEquals("file.xml", ChromeDownloadDelegate.fileName(testUrl, "", ""));
-
- assertEquals("file.pdf", ChromeDownloadDelegate.fileName(testUrl, "application/pdf", ""));
-
- // If the file's extension and HTTP header's MIME type are the same, use
- // the former to derive the final extension.
- // https://code.google.com/p/chromium/issues/detail?id=170852
- testUrl = "http://server.com/file.mp3";
- assertEquals("file.mp3", ChromeDownloadDelegate.fileName(testUrl, "audio/mpeg", ""));
-
- testUrl = "http://server.com/";
- assertEquals("downloadfile.bin", ChromeDownloadDelegate.fileName(testUrl, "", ""));
- assertEquals("downloadfile.pdf",
- ChromeDownloadDelegate.fileName(testUrl, "application/pdf", ""));
-
- // Fails to match the filename pattern from header; uses one from url.
- // Note that header itself is a valid one.
- testUrl = "http://server.com/file.pdf";
- assertEquals("file.pdf", ChromeDownloadDelegate.fileName(testUrl, "application/pdf",
- "attachment; name=\"foo\"; filename=\"bar\""));
- assertEquals("file.pdf", ChromeDownloadDelegate.fileName(testUrl, "application/pdf",
- "attachment; filename=\"bar\"; name=\"foo\""));
- assertEquals("file.pdf", ChromeDownloadDelegate.fileName(testUrl, "application/pdf",
- "attachment; filename=\"bar\"; filename*=utf-8''baz"));
- }
-
- /**
* Test to make sure {@link ChromeDownloadDelegate#shouldInterceptContextMenuDownload}
* returns true only for ".dd" or ".dm" extensions with http/https scheme.
*/

Powered by Google App Engine
This is Rietveld 408576698