Skip to content

Change connection options to case insensitive #1460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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