[PATCH] Fix regular expressions for git repositories

Miika Turkia miika.turkia at gmail.com
Mon Aug 10 08:01:46 PDT 2015


On Mon, Aug 10, 2015 at 10:01 AM, Dirk Hohndel <dirk at hohndel.org> wrote:
> I would like to see some testing of this. IIRC you do NOT want to escale
> the next character after a '^' as first character in a character class.

I totally agree that it should be tested, but I just have no idea how
to do that, I don't even know what environment adds the ssrf extension
automatically.

I cannot find anything regarding this on Qt online documentation.
However, it sounds plausible that the first char does not need
escaping after '^'.

> I'm reasonably certain that I tested the existing code and that it works -
> I'm ok being proven wrong, but I'd like to make sure that this is at least
> tested and not submitted as "I didn't test it but the original code looked
> wrong" :-)

What strikes me odd is that the first angle bracket ([) is escaped but
the closing one (]) is not. The original code escaped them both
(overwritten by commit 152eeb45d64db1398145ef7a935a132707b75e43), but
the improved code lost the escaping from the closing angle bracket.

> So right now the patch is NAK. Feel free to resubmit with a commit message
> that includes a truthful statement "I tested this and the old one breaks
> on THIS input and that works after applying this patch"...

The intention was to open discussion, as the code did not look like it
should work. But if it does, all the better...

miika

>
> On Fri, Aug 07, 2015 at 07:22:27PM +0300, Miika Turkia wrote:
>> Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
>> ---
>> This is something I have not tested at all, but it caught my eye when I
>> was looking at the patch breaking the file opening dialog (#913). The
>> original code just screams it needs more escaping of the angle brackets.
>> ---
>>  qt-ui/mainwindow.cpp | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
>> index db1d8c8..dedd2ce 100644
>> --- a/qt-ui/mainwindow.cpp
>> +++ b/qt-ui/mainwindow.cpp
>> @@ -319,7 +319,7 @@ void MainWindow::on_actionOpen_triggered()
>>       // so we would get dir[branch].ssrf when trying to select dir[branch].
>>       // let's detect that and remove the incorrect extension
>>       QStringList cleanFilenames;
>> -     QRegularExpression reg(".*\\[[^]]+]\\.ssrf", QRegularExpression::CaseInsensitiveOption);
>> +     QRegularExpression reg(".*\\[[^\\]]+\\]\\.ssrf", QRegularExpression::CaseInsensitiveOption);
>>
>>       Q_FOREACH (QString filename, filenames) {
>>               if (reg.match(filename).hasMatch())
>> @@ -1369,7 +1369,7 @@ int MainWindow::file_save_as(void)
>>       /* now for reasons I don't understand we appear to add a .ssrf to
>>        * git style filenames <path>/directory[branch]
>>        * so let's remove that */
>> -     QRegularExpression reg(".*\\[[^]]+]\\.ssrf", QRegularExpression::CaseInsensitiveOption);
>> +     QRegularExpression reg(".*\\[[^\\]]+\\]\\.ssrf", QRegularExpression::CaseInsensitiveOption);
>>       if (reg.match(filename).hasMatch())
>>               filename.remove(QRegularExpression("\\.ssrf$", QRegularExpression::CaseInsensitiveOption));
>>       if (filename.isNull() || filename.isEmpty())
>> --
>> 2.1.4
>>
>> _______________________________________________
>> subsurface mailing list
>> subsurface at subsurface-divelog.org
>> http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


More information about the subsurface mailing list