From 6ab0768af7985091cb41f0695219875390728098 Mon Sep 17 00:00:00 2001 From: Edward Hades Date: Tue, 20 Jan 2009 20:15:48 +0300 Subject: [PATCH] Modified automatic branch mask generation for IP addresses. Now instead for ident Nick!~Login@123.45.67.89 it sets mask to *!~Login@123.45.67.* instead of *!~Login@*.67.89. --- src/core/userinputhandler.cpp | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/src/core/userinputhandler.cpp b/src/core/userinputhandler.cpp index ae504a9..722c3fc 100644 --- a/src/core/userinputhandler.cpp +++ b/src/core/userinputhandler.cpp @@ -104,7 +104,11 @@ void UserInputHandler::banOrUnban(const BufferInfo &bufferInfo, const QString &m return; } - if(generalizedHost.lastIndexOf(".") != -1 && generalizedHost.lastIndexOf(".", generalizedHost.lastIndexOf(".")-1) != -1) { + static QRegExp ipAddress("\\d+\\.\\d+\\.\\d+\\.\\d+"); + if(ipAddress.exactMatch(generalizedHost)) { + int lastDotPos = generalizedHost.lastIndexOf('.') + 1; + generalizedHost.replace(lastDotPos, generalizedHost.length() - lastDotPos, '*'); + } else if(generalizedHost.lastIndexOf(".") != -1 && generalizedHost.lastIndexOf(".", generalizedHost.lastIndexOf(".")-1) != -1) { int secondLastPeriodPosition = generalizedHost.lastIndexOf(".", generalizedHost.lastIndexOf(".")-1); generalizedHost.replace(0, secondLastPeriodPosition, "*"); } -- 1.6.1