Browse Source

Fix parsing of eMule .DAT filters. Closes #5281.

adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
e3e7636de8
  1. 25
      src/base/bittorrent/private/filterparserthread.cpp

25
src/base/bittorrent/private/filterparserthread.cpp

@ -401,7 +401,30 @@ void FilterParserThread::processFilterList(libt::session *s, const QStringList & @@ -401,7 +401,30 @@ void FilterParserThread::processFilterList(libt::session *s, const QStringList &
QString FilterParserThread::cleanupIPAddress(QString _ip)
{
QHostAddress ip(_ip.trimmed());
_ip = _ip.trimmed();
// Emule .DAT files contain leading zeroes in IPv4 addresses
// eg 001.009.106.186
// We need to remove them because both QHostAddress and Boost.Asio fail to parse them.
QStringList octets = _ip.split('.', QString::SkipEmptyParts);
if (octets.size() == 4) {
QString octet; // it is faster to not recreate this object in the loop
for (int i = 0; i < 4; i++) {
octet = octets[i];
if ((octet[0] == QChar('0')) && (octet.count() > 1)) {
if ((octet[1] == QChar('0')) && (octet.count() > 2))
octet.remove(0, 2);
else
octet.remove(0, 1);
octets[i] = octet;
}
}
_ip = octets.join(".");
}
QHostAddress ip(_ip);
if (ip.isNull()) return QString();
return ip.toString();

Loading…
Cancel
Save