Bug 1155154 - Part 1 - Fix the check for duplicate filters when one filter is a subtring of another one. r=smaug

This commit is contained in:
Arnaud Bienner
2015-07-20 23:07:59 +02:00
parent 3e2dc2e186
commit 398a86e511
2 changed files with 24 additions and 1 deletions

View File

@@ -7291,7 +7291,14 @@ HTMLInputElement::SetFilePickerFiltersFromAccept(nsIFilePicker* filePicker)
if (i == j) {
continue;
}
if (FindInReadable(filterToCheck.mFilter, filtersCopy[j].mFilter)) {
// Check if this filter's extension list is a substring of the other one.
// e.g. if filters are "*.jpeg" and "*.jpeg; *.jpg" the first one should
// be removed.
// Add an extra "; " to be sure the check will work and avoid cases like
// "*.xls" being a subtring of "*.xslx" while those are two differents
// filters and none should be removed.
if (FindInReadable(filterToCheck.mFilter + NS_LITERAL_STRING(";"),
filtersCopy[j].mFilter + NS_LITERAL_STRING(";"))) {
// We already have a similar, less restrictive filter (i.e.
// filterToCheck extensionList is just a subset of another filter
// extension list): remove this one