Ticket #2034: ExpanderRules_Ticket2034.diff

File ExpanderRules_Ticket2034.diff, 741 bytes (added by n3s, 16 years ago)

Problem was ExpanderRules::MatchingRule(..) which can return a false rule if the extension does not match (-1) and the extension-position is calculated as -1, too. Please review!

  • ExpanderRules.cpp

     
    122122{
    123123    int32 count = fList.CountItems();
    124124    int32 length = fileName.Length();
     125
    125126    for (int32 i = 0; i < count; i++) {
    126127        ExpanderRule *rule = (ExpanderRule *)fList.ItemAt(i);
     128
     129        int32 extPosition = fileName.FindLast(rule->FilenameExtension());
     130
    127131        if ((rule->MimeType().IsValid() && rule->MimeType() == filetype)
    128             || (fileName.FindLast(rule->FilenameExtension()) == (length - rule->FilenameExtension().Length())))
     132            || (extPosition!=-1 && extPosition == (length - rule->FilenameExtension().Length())))
    129133            return rule;
    130134    }
     135
    131136    return NULL;
    132137}
    133138