Changeset 197:000463188f40
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r172
|
r197
|
|
| 159 | 159 | } |
| 160 | 160 | |
| | 161 | bool 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 | |
| | 171 | bool isServerValid(const QString& server) { |
| | 172 | QRegExp exp("[A-Za-z0-9\\-_\\.]+\\.[A-Za-z0-9\\-_\\.]+"); |
| | 173 | return exp.exactMatch(server); |
| | 174 | } |
-
|
r49
|
r197
|
|
| 10 | 10 | QString removeHtml(const QString&); |
| 11 | 11 | |
| | 12 | bool isBareJidValid(const QString& jid); |
| | 13 | bool isServerValid(const QString& server); |
| | 14 | |
| 12 | 15 | #endif |
-
|
r192
|
r197
|
|
| 451 | 451 | return true; |
| 452 | 452 | } |
| | 453 | |
| | 454 | if (!isBareJidValid(jid) && !isServerValid(jid)) |
| | 455 | { |
| | 456 | reply(s,"JID is not valid"); |
| | 457 | return true; |
| | 458 | } |
| | 459 | |
| 453 | 460 | QString reason=parser.nextToken(); |
| 454 | 461 | QString affiliation=affiliationByCommand(cmd); |