Skip to content

Commit

Permalink
Change connection options to case insensitive (#1460)
Browse files Browse the repository at this point in the history
  • Loading branch information
absci committed Aug 31, 2023
1 parent 0bc36bf commit 62beb28
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions source/pdo_sqlsrv/pdo_dbh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ struct pdo_encrypt_set_func
const char TRUE_VALUE_2[] = "1";
const char FALSE_VALUE_1[] = "false";
const char FALSE_VALUE_2[] = "0";
transform(val_str.begin(), val_str.end(), val_str.begin(), ::tolower);

// For backward compatibility, convert true/1 to yes and false/0 to no
std::string attr;
Expand Down
1 change: 1 addition & 0 deletions source/shared/core_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ size_t core_str_zval_is_true(_Inout_ zval* value_z)

const char TRUE_VALUE_1[] = "true";
const char TRUE_VALUE_2[] = "1";
transform(val_str.begin(), val_str.end(), val_str.begin(), ::tolower);
if (!val_str.compare(TRUE_VALUE_1) || !val_str.compare(TRUE_VALUE_2)) {
return 1; // true
}
Expand Down
11 changes: 10 additions & 1 deletion source/sqlsrv/conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,16 @@ struct bool_conn_str_func {
{
char temp_str[MAX_CONN_VALSTRING_LEN];

snprintf(temp_str, MAX_CONN_VALSTRING_LEN, "%s={%s};", option->odbc_name, (zend_is_true(value) ? "yes" : "no"));
if (Z_TYPE_P(value) != IS_STRING) {
convert_to_string(value);
}
const char *value_str = Z_STRVAL_P(value);

snprintf(temp_str,
MAX_CONN_VALSTRING_LEN,
"%s={%s};",
option->odbc_name,
((stricmp(value_str, "true") == 0 || stricmp(value_str, "1") == 0) ? "yes" : "no"));
conn_str += temp_str;
}
};
Expand Down

0 comments on commit 62beb28

Please sign in to comment.