Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/kurlcompletion.cpp
Show All 24 Lines | |||||
25 | #include "kurlcompletion.h" | 25 | #include "kurlcompletion.h" | ||
26 | #include "../pathhelpers_p.h" | 26 | #include "../pathhelpers_p.h" | ||
27 | 27 | | |||
28 | #include <stdlib.h> | 28 | #include <stdlib.h> | ||
29 | #include <assert.h> | 29 | #include <assert.h> | ||
30 | #include <limits.h> | 30 | #include <limits.h> | ||
31 | 31 | | |||
32 | #include <QMutex> | 32 | #include <QMutex> | ||
33 | #include <QRegExp> | 33 | #include <QRegularExpression> | ||
34 | #include <QDir> | 34 | #include <QDir> | ||
35 | #include <QDirIterator> | 35 | #include <QDirIterator> | ||
36 | #include <QFile> | 36 | #include <QFile> | ||
37 | #include <QThread> | 37 | #include <QThread> | ||
38 | #include <QUrl> | 38 | #include <QUrl> | ||
39 | #include <QDebug> | 39 | #include <QDebug> | ||
40 | #include <QMimeDatabase> | 40 | #include <QMimeDatabase> | ||
41 | #include <QProcessEnvironment> | 41 | #include <QProcessEnvironment> | ||
▲ Show 20 Lines • Show All 449 Lines • ▼ Show 20 Line(s) | 490 | if (url_copy.startsWith(QLatin1Char('#'))) { | |||
491 | if (url_copy.length() > 1 && url_copy.at(1) == QLatin1Char('#')) { | 491 | if (url_copy.length() > 1 && url_copy.at(1) == QLatin1Char('#')) { | ||
492 | url_copy.replace(0, 2, QStringLiteral("info:")); | 492 | url_copy.replace(0, 2, QStringLiteral("info:")); | ||
493 | } else { | 493 | } else { | ||
494 | url_copy.replace(0, 1, QStringLiteral("man:")); | 494 | url_copy.replace(0, 1, QStringLiteral("man:")); | ||
495 | } | 495 | } | ||
496 | } | 496 | } | ||
497 | 497 | | |||
498 | // Look for a protocol in 'url' | 498 | // Look for a protocol in 'url' | ||
499 | QRegExp protocol_regex = QRegExp(QStringLiteral("^(?![A-Za-z]:)[^/\\s\\\\]*:")); | 499 | const QRegularExpression protocol_regex(QStringLiteral("^(?![A-Za-z]:)[^/\\s\\\\]*:")); | ||
500 | 500 | | |||
501 | // Assume "file:" or whatever is given by 'cwd' if there is | 501 | // Assume "file:" or whatever is given by 'cwd' if there is | ||
502 | // no protocol. (QUrl does this only for absolute paths) | 502 | // no protocol. (QUrl does this only for absolute paths) | ||
503 | if (protocol_regex.indexIn(url_copy) == 0) { | 503 | if (protocol_regex.match(url_copy).hasMatch()) { | ||
ahmadsamir: hasMatch() is enough here because the pattern will only match at the beginning of the subject… | |||||
504 | m_kurl = QUrl(url_copy); | 504 | m_kurl = QUrl(url_copy); | ||
505 | m_isURL = true; | 505 | m_isURL = true; | ||
506 | } else { // relative path or ~ or $something | 506 | } else { // relative path or ~ or $something | ||
507 | m_isURL = false; | 507 | m_isURL = false; | ||
508 | if (!QDir::isRelativePath(url_copy) || | 508 | if (!QDir::isRelativePath(url_copy) || | ||
509 | url_copy.startsWith(QLatin1Char('~')) || | 509 | url_copy.startsWith(QLatin1Char('~')) || | ||
510 | url_copy.startsWith(QLatin1Char('$'))) { | 510 | url_copy.startsWith(QLatin1Char('$'))) { | ||
511 | m_kurl = QUrl::fromLocalFile(url_copy); | 511 | m_kurl = QUrl::fromLocalFile(url_copy); | ||
▲ Show 20 Lines • Show All 1061 Lines • Show Last 20 Lines |
hasMatch() is enough here because the pattern will only match at the beginning of the subject string because of ^ anchor.