isRenameAllowedForType(): Handle empty autoRenameFiles.fileTypes

Previously, an empty value for the pref would be treated as matching
*every* MIME type, because s.startsWith('') is true for any string. That
meant that unchecking all the file type checkboxes would actually enable
renaming for all files.
This commit is contained in:
Abe Jellinek 2024-07-31 16:30:48 -04:00
parent 61d6ef8d3d
commit aab90527ec

View file

@ -2479,8 +2479,9 @@ Zotero.Attachments = new function () {
this.isRenameAllowedForType = function (contentType) {
let typePrefixes;
try {
typePrefixes = (Zotero.Prefs.get('autoRenameFiles.fileTypes') || '')
.split(',');
let prefValue = Zotero.Prefs.get('autoRenameFiles.fileTypes');
if (!prefValue) return false;
typePrefixes = prefValue.split(',');
}
catch (e) {
typePrefixes = [];