Skip to content

Commit

Permalink
Fixed incorporation of invalid characters in LIKE query
Browse files Browse the repository at this point in the history
  • Loading branch information
luciensadi committed Jul 15, 2024
1 parent 83d6f4e commit fd8bcb6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/act.informative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5538,7 +5538,10 @@ ACMD(do_index)
}

void display_help(char *help, int help_len, const char *arg, struct char_data *ch) {
char query[MAX_STRING_LENGTH], prepared_standard[MAX_STRING_LENGTH], prepared_for_like[MAX_STRING_LENGTH];
char query[MAX_STRING_LENGTH] = { 0 };
char prepared_standard[MAX_STRING_LENGTH] = { 0 };
char prepared_for_like[MAX_STRING_LENGTH] = { 0 };

MYSQL_RES *res;
MYSQL_ROW row;
*help = '\0';
Expand Down
7 changes: 5 additions & 2 deletions src/newdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,11 @@ char *prepare_quotes(char *dest, const char *str, size_t size_of_dest, bool incl
*temp++ = '\\';
}
// Special case handling: % has special meaning in LIKE statements.
if (is_like && *str == '%') {
*temp++ = '\\';
if (is_like) {
if (*str == '%' || *str == '?' || *str == '.' || *str == '*' || *str == '+' || *str == '(' || *str == ')' || *str == '[' || *str == ']') {
*temp++ = '\\';
*temp++ = '\\';
}
}
*temp++ = *str++;
}
Expand Down
1 change: 1 addition & 0 deletions src/spec_assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,7 @@ void assign_rooms(void)
ASSIGNROOM(15600, troll_barrier);
ASSIGNROOM(8901, car_dealer);
ASSIGNROOM(8903, car_dealer);
ASSIGNROOM(100203, car_dealer);

// Cairo's room
ASSIGNROOM(RM_CAIROS_APARTMENT, floor_has_glass_shards);
Expand Down

0 comments on commit fd8bcb6

Please sign in to comment.