| 1 | /* |
| 2 | localdomainfilter.cpp |
| 3 | |
| 4 | This file is part of the KDE project |
| 5 | SPDX-FileCopyrightText: 2002 Lubos Lunak <[email protected]> |
| 6 | SPDX-FileCopyrightText: 2010 Dawit Alemayehu <[email protected]> |
| 7 | |
| 8 | SPDX-License-Identifier: GPL-2.0-or-later |
| 9 | */ |
| 10 | |
| 11 | #include "localdomainurifilter.h"cxx . . $ `<file>/src/urifilters/localdomain/localdomainurifilter.h`/ |
| 12 | |
| 13 | #include <KPluginFactory> |
| 14 | #include <KProtocolInfo>cxx . . $ `<file>/build/src/core/KProtocolInfo`/ |
| 15 | |
| 16 | #include <QHostInfo> |
| 17 | #include <QLoggingCategory> |
| 18 | |
| 19 | namespacecxx . . $ `$anonymous_namespace_src/urifilters/localdomain/localdomainurifilter.cpp`/ |
| 20 | { |
| 21 | Q_LOGGING_CATEGORYcxx . . $ `<external>/2792800077858828889/qloggingcategory.h:147:9`!(category, "kf.kio.urifilters.localdomain", QtWarningMsg) |
| 22 | } |
| 23 | |
| 24 | bool LocalDomainUriFiltercxx . . $ LocalDomainUriFilter#::filterUricxx . . $ LocalDomainUriFilter#filterUri(a0d278f17144b2bc).(KUriFilterDatacxx . . $ KUriFilterData# &data) const |
| 25 | { |
| 26 | const QUrlcxx . . $ QUrl# url = data.uricxx . . $ KUriFilterData#uri(36d9834fe7321282).(); |
| 27 | const QStringcxx . . $ QString# protocol = url.schemecxx . . $ QUrl#scheme(6ef7b6c27b00b43d).(); |
| 28 | |
| 29 | // When checking for local domain just validate it is indeed a local domain, |
| 30 | // but do not modify the hostname! See bug# |
| 31 | if ((protocol.isEmptycxx . . $ QString#isEmpty(3482b152b9333168).() || !KProtocolInfocxx . . $ KProtocolInfo#::isKnownProtocolcxx . . $ KProtocolInfo#isKnownProtocol(7bc58614ad8ebda3).(protocol)) && m_hostPortPatterncxx . . $ LocalDomainUriFilter#m_hostPortPattern..matchcxx . . $ QRegularExpression#match(d076266091fa4922).(data.typedStringcxx . . $ KUriFilterData#typedString(6ef7b6c27b00b43d).()).hasMatchcxx . . $ QRegularExpressionMatch#hasMatch(50ce9a9e25b4a850).()) { |
| 32 | QStringcxx . . $ QString# host(data.typedStringcxx . . $ KUriFilterData#typedString(6ef7b6c27b00b43d).().leftcxx . . $ QString#left(769e6be952b825b0).(data.typedStringcxx . . $ KUriFilterData#typedString(6ef7b6c27b00b43d).().indexOfcxx . . $ QString#indexOf(7f9dda0319baab1e).(QLatin1Charcxx . . $ QChar#QChar(93d577a3e9528307).('/')))); |
| 33 | const int pos = host.indexOfcxx . . $ QString#indexOf(7f9dda0319baab1e).(QLatin1Charcxx . . $ QChar#QChar(93d577a3e9528307).(':')); |
| 34 | if (pos > -1) { |
| 35 | host.truncatecxx . . $ QString#truncate(35cb52607f6af42f).(pos); // Remove port number |
| 36 | } |
| 37 | if (existscxx . . $ LocalDomainUriFilter#exists(f3b39adf77d9c36c).(host)) { |
| 38 | qCDebugcxx . . $ `<external>/2792800077858828889/qloggingcategory.h:162:9`!(category) <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "QHostInfo found a host called" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). host; |
| 39 | QStringcxx . . $ QString# scheme(data.defaultUrlSchemecxx . . $ KUriFilterData#defaultUrlScheme(6ef7b6c27b00b43d).()); |
| 40 | if (scheme.isEmptycxx . . $ QString#isEmpty(3482b152b9333168).()) { |
| 41 | scheme =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!("http://"); |
| 42 | } |
| 43 | setFilteredUricxx . . $ KUriFilterPlugin#setFilteredUri(b94c148c402f32ba).(data, QUrlcxx . . $ QUrl#QUrl(ea1f3831e370f1cb).(scheme +cxx . . $ operator+(adfbdceb504720ce). data.typedStringcxx . . $ KUriFilterData#typedString(6ef7b6c27b00b43d).())); |
| 44 | setUriTypecxx . . $ KUriFilterPlugin#setUriType(32ce7115762e009d).(data, KUriFilterDatacxx . . $ KUriFilterData#::NetProtocolcxx . . $ KUriFilterData#NetProtocol.); |
| 45 | return true; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | bool LocalDomainUriFiltercxx . . $ LocalDomainUriFilter#::existscxx . . $ LocalDomainUriFilter#exists(f3b39adf77d9c36c).(const QStringcxx . . $ QString# &host) const |
| 53 | { |
| 54 | qCDebugcxx . . $ `<external>/2792800077858828889/qloggingcategory.h:162:9`!(category) <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Checking if a host called" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). host <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "exists"; |
| 55 | QHostInfocxx . . $ QHostInfo# hostInfo = resolveNamecxx . . $ KUriFilterPlugin#resolveName(987e64ffa4c854f1).(host, 1500); |
| 56 | return hostInfo.errorcxx . . $ QHostInfo#error(ceb56bb245ac3e5d).() == QHostInfocxx . . $ QHostInfo#::NoErrorcxx . . $ QHostInfo#NoError.; |
| 57 | } |
| 58 | |
| 59 | K_PLUGIN_CLASS_WITH_JSONcxx . . $ `<external>/16527071682168900940/kpluginfactory.h:184:9`!(LocalDomainUriFilter, "localdomainurifilter.json") |
| 60 | |
| 61 | #include "localdomainurifilter.moc"cxx . . $ `<file>/build/src/urifilters/localdomain/localdomainurifilter_autogen/include/localdomainurifilter.moc`/ |
| 62 | #include "moc_localdomainurifilter.cpp"cxx . . $ `<file>/build/src/urifilters/localdomain/localdomainurifilter_autogen/include/moc_localdomainurifilter.cpp`/ |