Skip to content

Commit 79d4b38

Browse files
authored
Change connection options to case insensitive (#1460)
1 parent 9debf7d commit 79d4b38

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

source/pdo_sqlsrv/pdo_dbh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ struct pdo_encrypt_set_func
155155
const char TRUE_VALUE_2[] = "1";
156156
const char FALSE_VALUE_1[] = "false";
157157
const char FALSE_VALUE_2[] = "0";
158+
transform(val_str.begin(), val_str.end(), val_str.begin(), ::tolower);
158159

159160
// For backward compatibility, convert true/1 to yes and false/0 to no
160161
std::string attr;

source/shared/core_conn.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ size_t core_str_zval_is_true(_Inout_ zval* value_z)
11491149

11501150
const char TRUE_VALUE_1[] = "true";
11511151
const char TRUE_VALUE_2[] = "1";
1152+
transform(val_str.begin(), val_str.end(), val_str.begin(), ::tolower);
11521153
if (!val_str.compare(TRUE_VALUE_1) || !val_str.compare(TRUE_VALUE_2)) {
11531154
return 1; // true
11541155
}

source/sqlsrv/conn.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,16 @@ struct bool_conn_str_func {
135135
{
136136
char temp_str[MAX_CONN_VALSTRING_LEN];
137137

138-
snprintf(temp_str, MAX_CONN_VALSTRING_LEN, "%s={%s};", option->odbc_name, (zend_is_true(value) ? "yes" : "no"));
138+
if (Z_TYPE_P(value) != IS_STRING) {
139+
convert_to_string(value);
140+
}
141+
const char *value_str = Z_STRVAL_P(value);
142+
143+
snprintf(temp_str,
144+
MAX_CONN_VALSTRING_LEN,
145+
"%s={%s};",
146+
option->odbc_name,
147+
((stricmp(value_str, "true") == 0 || stricmp(value_str, "1") == 0) ? "yes" : "no"));
139148
conn_str += temp_str;
140149
}
141150
};

0 commit comments

Comments
 (0)