diff options
| -rw-r--r-- | nameblocker.sp | 74 |
1 files changed, 72 insertions, 2 deletions
diff --git a/nameblocker.sp b/nameblocker.sp index 8254cd0..9190dd2 100644 --- a/nameblocker.sp +++ b/nameblocker.sp | |||
| @@ -54,7 +54,7 @@ void checkName(int client) { | |||
| 54 | 54 | ||
| 55 | if(m == 0) continue; | 55 | if(m == 0) continue; |
| 56 | if(m < 0) { | 56 | if(m < 0) { |
| 57 | handleFailedRegex(client, reerr, name, sizeof(name)); | 57 | handleFailedRegex(client, reerr); |
| 58 | return; | 58 | return; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| @@ -96,6 +96,76 @@ int handleNameHit(int client) { | |||
| 96 | return -1; // Shouldn't get to this point | 96 | return -1; // Shouldn't get to this point |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | int handleFailedRegex(int client, RegexError reerr, char[] name, int namelen) { | 99 | int handleFailedRegex(int client, RegexError reerr) { |
| 100 | static char regstr[128]; | ||
| 101 | RegexStrError(reerr, regstr, sizeof(regstr)); | ||
| 102 | |||
| 103 | LogError("Ran into regex error when trying to check user %L's name. Reported regex error: %s", client, regstr); | ||
| 104 | return 0; | ||
| 105 | } | ||
| 106 | |||
| 107 | // Note: May or may not be particularly descriptive for any given error | ||
| 108 | int RegexStrError(RegexError err, char[] buf, int buflen) { | ||
| 109 | if(IsNullString(buf)) return -1; | ||
| 110 | |||
| 111 | switch(err) { | ||
| 112 | case REGEX_ERROR_NONE: {Format(buf, buflen, "No error");} /* No error */ | ||
| 113 | |||
| 114 | case REGEX_ERROR_ASSERT: {Format(buf, buflen, "Internal error");} | ||
| 115 | case REGEX_ERROR_BADBR: {Format(buf, buflen, "Invalid repeat counts in {}");} | ||
| 116 | case REGEX_ERROR_BADPAT: {Format(buf, buflen, "Pattern error");} | ||
| 117 | case REGEX_ERROR_BADRPT: {Format(buf, buflen, "? * + invalid");} | ||
| 118 | case REGEX_ERROR_EBRACE: {Format(buf, buflen, "Unbalanced {}");} | ||
| 119 | case REGEX_ERROR_EBRACK: {Format(buf, buflen, "Unbalanced []");} | ||
| 120 | case REGEX_ERROR_ECOLLATE: {Format(buf, buflen, "Collation error - not relevant");} | ||
| 121 | case REGEX_ERROR_ECTYPE: {Format(buf, buflen, "Bad class");} | ||
| 122 | case REGEX_ERROR_EESCAPE: {Format(buf, buflen, "Bad escape sequence");} | ||
| 123 | case REGEX_ERROR_EMPTY: {Format(buf, buflen, "Empty expression");} | ||
| 124 | case REGEX_ERROR_EPAREN: {Format(buf, buflen, "Unbalanced ()");} | ||
| 125 | case REGEX_ERROR_ERANGE: {Format(buf, buflen, "Bad range inside []");} | ||
| 126 | case REGEX_ERROR_ESIZE: {Format(buf, buflen, "Expression too big");} | ||
| 127 | case REGEX_ERROR_ESPACE: {Format(buf, buflen, "Failed to get memory");} | ||
| 128 | case REGEX_ERROR_ESUBREG: {Format(buf, buflen, "Bad back reference");} | ||
| 129 | case REGEX_ERROR_INVARG: {Format(buf, buflen, "Bad argument");} | ||
| 130 | |||
| 131 | case REGEX_ERROR_NOMATCH: {Format(buf, buflen, "No match was found");} | ||
| 132 | case REGEX_ERROR_NULL: {Format(buf, buflen, "Null");} | ||
| 133 | case REGEX_ERROR_BADOPTION: {Format(buf, buflen, "Bad Option");} | ||
| 134 | case REGEX_ERROR_BADMAGIC: {Format(buf, buflen, "Bad Magic");} | ||
| 135 | case REGEX_ERROR_UNKNOWN_OPCODE: {Format(buf, buflen, "Unknown OpCode");} | ||
| 136 | case REGEX_ERROR_NOMEMORY: {Format(buf, buflen, "No Memory");} | ||
| 137 | case REGEX_ERROR_NOSUBSTRING: {Format(buf, buflen, "No substring");} | ||
| 138 | case REGEX_ERROR_MATCHLIMIT: {Format(buf, buflen, "Match limit");} | ||
| 139 | case REGEX_ERROR_CALLOUT: {Format(buf, buflen, "Callout");} // Never used by PCRE itself | ||
| 140 | case REGEX_ERROR_BADUTF8: {Format(buf, buflen, "Bad UTF8");} | ||
| 141 | case REGEX_ERROR_BADUTF8_OFFSET: {Format(buf, buflen, "Bad UTF8 offset");} | ||
| 142 | case REGEX_ERROR_PARTIAL: {Format(buf, buflen, "Partial");} | ||
| 143 | case REGEX_ERROR_BADPARTIAL: {Format(buf, buflen, "Bad Partial");} | ||
| 144 | case REGEX_ERROR_INTERNAL: {Format(buf, buflen, "Internal error");} | ||
| 145 | case REGEX_ERROR_BADCOUNT: {Format(buf, buflen, "Bad count");} | ||
| 146 | case REGEX_ERROR_DFA_UITEM: {Format(buf, buflen, "DFA UItem");} | ||
| 147 | case REGEX_ERROR_DFA_UCOND: {Format(buf, buflen, "DFA UCOND");} | ||
| 148 | case REGEX_ERROR_DFA_UMLIMIT: {Format(buf, buflen, "DFA UMLIMIT");} | ||
| 149 | case REGEX_ERROR_DFA_WSSIZE: {Format(buf, buflen, "DFA WSSIZE");} | ||
| 150 | case REGEX_ERROR_DFA_RECURSE: {Format(buf, buflen, "DFA recurse");} | ||
| 151 | case REGEX_ERROR_RECURSIONLIMIT: {Format(buf, buflen, "Recursion Limit");} | ||
| 152 | case REGEX_ERROR_NULLWSLIMIT: {Format(buf, buflen, "NULL WSLIMIT");} /* No longer actually used */ | ||
| 153 | case REGEX_ERROR_BADNEWLINE: {Format(buf, buflen, "Bad newline");} | ||
| 154 | case REGEX_ERROR_BADOFFSET: {Format(buf, buflen, "Bad offset");} | ||
| 155 | case REGEX_ERROR_SHORTUTF8: {Format(buf, buflen, "Short UFT8");} | ||
| 156 | case REGEX_ERROR_RECURSELOOP: {Format(buf, buflen, "Recurse loop");} | ||
| 157 | case REGEX_ERROR_JIT_STACKLIMIT: {Format(buf, buflen, "JIT Stacklimit");} | ||
| 158 | case REGEX_ERROR_BADMODE: {Format(buf, buflen, "Bad mode");} | ||
| 159 | case REGEX_ERROR_BADENDIANNESS: {Format(buf, buflen, "Bad endianness");} | ||
| 160 | case REGEX_ERROR_DFA_BADRESTART: {Format(buf, buflen, "DFA Bad Restart");} | ||
| 161 | case REGEX_ERROR_JIT_BADOPTION: {Format(buf, buflen, "JIT bad option");} | ||
| 162 | case REGEX_ERROR_BADLENGTH: {Format(buf, buflen, "Bad length");} | ||
| 163 | |||
| 164 | default: {Format(buf, buflen, "Unknown Error");} | ||
| 165 | } | ||
| 166 | |||
| 167 | // Yeah I know this is terrible, and it's entirely because I'm not certain how string assignments work. If this were C I would | ||
| 168 | // make a normal char* string and make it point to different text depending on the case | ||
| 169 | |||
| 100 | return 0; | 170 | return 0; |
| 101 | } \ No newline at end of file | 171 | } \ No newline at end of file |
