Changeset 197:000463188f40

Show
Ignore:
Timestamp:
04/20/2008 07:48:16 PM (4 years ago)
Author:
Dmitry Nezhevenko <dion@…>
Branch:
default
Message:

JID validation for !muc banjid and !muc unban commands

Location:
src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • src/base/common.cpp

    r172 r197  
    159159} 
    160160 
     161bool isBareJidValid(const QString& jid) 
     162{ 
     163        QString user=jid.section('@',0,-2); 
     164        QString server=jid.section('@',-1,-1); 
     165        qDebug() << "user: " << user << "; server: " << server;  
     166        if (!isServerValid(server)) 
     167                return false; 
     168        return (user.indexOf(' ')<0); 
     169} 
     170 
     171bool isServerValid(const QString& server) { 
     172        QRegExp exp("[A-Za-z0-9\\-_\\.]+\\.[A-Za-z0-9\\-_\\.]+"); 
     173        return exp.exactMatch(server); 
     174} 
  • src/base/common.h

    r49 r197  
    1010QString removeHtml(const QString&); 
    1111 
     12bool isBareJidValid(const QString& jid); 
     13bool isServerValid(const QString& server); 
     14 
    1215#endif 
  • src/plugins/muc/mucplugin.cpp

    r192 r197  
    451451                        return true; 
    452452                } 
     453                 
     454                if (!isBareJidValid(jid) && !isServerValid(jid)) 
     455                { 
     456                        reply(s,"JID is not valid"); 
     457                        return true; 
     458                } 
     459                 
    453460                QString reason=parser.nextToken(); 
    454461                QString affiliation=affiliationByCommand(cmd);