From 5bf0f0bca6a4a0ef2ab1c6fcff8615430d4a27e1 Mon Sep 17 00:00:00 2001 From: Arnaud Bienner Date: Fri, 17 Jul 2015 01:20:01 +0200 Subject: [PATCH] Bug 1155154 - Part 3 - Ignore file extension filters with characters that can be interpreted by the file picker. r=smaug --HG-- extra : rebase_source : 3dfeafb7628689931ac54f00792c683670524d1f --- dom/html/HTMLInputElement.cpp | 4 ++++ dom/html/test/forms/test_input_file_picker.html | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index d770015bf511..51b115984fca 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -7212,6 +7212,10 @@ HTMLInputElement::SetFilePickerFiltersFromAccept(nsIFilePicker* filePicker) filterBundle->GetStringFromName(MOZ_UTF16("videoFilter"), getter_Copies(extensionListStr)); } else if (token.First() == '.') { + if (token.FindChar(';') >= 0 || token.FindChar('*') >= 0) { + // Ignore this filter as it contains reserved characters + continue; + } extensionListStr = NS_LITERAL_STRING("*") + token; filterName = extensionListStr; atLeastOneFileExtensionFilter = true; diff --git a/dom/html/test/forms/test_input_file_picker.html b/dom/html/test/forms/test_input_file_picker.html index fb568f194cfc..6d3a98631877 100644 --- a/dom/html/test/forms/test_input_file_picker.html +++ b/dom/html/test/forms/test_input_file_picker.html @@ -40,6 +40,7 @@ + @@ -104,10 +105,11 @@ var testData = [["a", 1, MockFilePicker.filterImages, 1], ["t", 4, "*.mp3; *.wav; *.flac", 1], ["u", 3, "*.xls; *.xlsx", 1], ["v", 3, "*.xlsx; *.xls", 1], - ["w", 1, "*.xlsx; .xls", 1], + ["w", 0, undefined, 0], ["x", 3, "*.xls; *.xlsx", 1], ["y", 3, "*.xlsx; *.xls", 1], ["z", 0, undefined, 0], + ["A", 1, "*.xlsx", 1], // Note: mix and mix-ref tests extension lists are checked differently: see SimpleTest.executeSoon below ["mix-ref", undefined, undefined, undefined], ["mix", 1, undefined, 1],