Skip to content

Commit

Permalink
Merge 4f7dc78 into e216b36
Browse files Browse the repository at this point in the history
  • Loading branch information
rosolko committed May 10, 2018
2 parents e216b36 + 4f7dc78 commit b340f13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/codeborne/selenide/impl/HttpHelper.java
Expand Up @@ -11,7 +11,7 @@

public class HttpHelper {

private final Pattern pattern = Pattern.compile(".*filename\\*?=\"?((.+)'')?([^\";]*)\"?(;charset=(.*))?.*", CASE_INSENSITIVE);
private final Pattern pattern = Pattern.compile(".*filename\\*?=\"?((.+)'')?([^\";?]*)\"?(;charset=(.*))?.*", CASE_INSENSITIVE);

public Optional<String> getFileNameFromContentDisposition(String headerName, String headerValue) {
if (!"Content-Disposition".equalsIgnoreCase(headerName) || headerValue == null) {
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/com/codeborne/selenide/impl/HttpHelperTest.java
Expand Up @@ -19,6 +19,12 @@ public void extractsFileNameFromHttpHeader() {
assertEquals("selenide-2.6.1.jar", helper.getFileNameFromContentDisposition(
"content-disposition", "attachement; filename=selenide-2.6.1.jar").get());

assertEquals("selenide-4.11.5.md", helper.getFileNameFromContentDisposition(
"Content-Disposition", "attachement; filename=selenide-4.11.5.md?sessioncookie=12345%2323").get());

assertEquals("random_file.txt", helper.getFileNameFromContentDisposition(
"Content-Disposition", "attachement; filename=random_file.txt?auth=5v1kij42xXSsc;charset=CP1251").get());

assertEquals("Prices.csv", helper.getFileNameFromContentDisposition(
"Content-Disposition", "attachment; filename=Prices.csv;charset=UTF-8").get());

Expand Down

0 comments on commit b340f13

Please sign in to comment.