[PATCH] Fix regular expressions for git repositories

Miika Turkia miika.turkia at gmail.com
Fri Aug 7 09:22:27 PDT 2015


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



More information about the subsurface mailing list