summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk/fpicker
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2018-05-30 20:37:20 +0200
committerMatteo Casalin <matteo.casalin@yahoo.com>2018-06-03 12:17:45 +0200
commit3c78a19ed66b44ebb2db7b160fa92a010a3c42aa (patch)
tree84ccdacaab213d032c48fa68f29d549ba9ca6019 /vcl/unx/gtk/fpicker
parent85613aa81a885488f99ed038f2254ddb0c8a1037 (diff)
Try harder to find a matching file extension
Potential regression from 2a39163aef4211c9d19cb1faee7f55d3718355b6 Change-Id: I67f1f11bd52a1dbf0f77a35df7ad556437ccd39b
Diffstat (limited to 'vcl/unx/gtk/fpicker')
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx33
1 files changed, 21 insertions, 12 deletions
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index a222d603270c..e4f5ac395b8d 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -705,23 +705,32 @@ namespace
bool lcl_matchFilter( const rtl::OUString& rFilter, const rtl::OUString& rExt )
{
- const sal_Int32 nBegin = rFilter.indexOf(rExt);
+ const sal_Unicode cSep {';'};
+ sal_Int32 nIdx {0};
- if (nBegin<0) // not found
- return false;
+ for (;;)
+ {
+ const sal_Int32 nBegin = rFilter.indexOf(rExt, nIdx);
- const sal_Unicode cSep{';'};
+ if (nBegin<0) // not found
+ break;
- // Check if the found occurrence is an exact match: left side
- if (nBegin>0 && rFilter[nBegin-1]!=cSep)
- return false;
+ // Let nIdx point to end of matched string, useful in order to
+ // check string boundaries and also for a possible next iteration
+ nIdx = nBegin + rExt.getLength();
- // Check if the found occurrence is an exact match: right side
- const sal_Int32 nEnd = nBegin + rExt.getLength();
- if (nEnd<rFilter.getLength() && rFilter[nEnd]!=cSep)
- return false;
+ // Check if the found occurrence is an exact match: right side
+ if (nIdx<rFilter.getLength() && rFilter[nIdx]!=cSep)
+ continue;
- return true;
+ // Check if the found occurrence is an exact match: left side
+ if (nBegin>0 && rFilter[nBegin-1]!=cSep)
+ continue;
+
+ return true;
+ }
+
+ return false;
}
}