Skip to content

Commit 8aa93b7

Browse files
committed
Revert "Fix #62479: Some chars not parsed in passwords"
This reverts commit e6bb90c.
1 parent e6bb90c commit 8aa93b7

File tree

3 files changed

+2
-88
lines changed

3 files changed

+2
-88
lines changed

NEWS

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 201?, PHP 5.3.29
44

5-
- PDO_pgsql:
6-
. Fixed bug #62479 (PDO-psql cannot connect if password contains spaces)
7-
85
12 Dec 2013, PHP 5.3.28
96

107
- Openssl:

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,6 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
10291029
pdo_pgsql_db_handle *H;
10301030
int ret = 0;
10311031
char *conn_str, *p, *e;
1032-
char *tmp_pass;
10331032
long connect_timeout = 30;
10341033

10351034
H = pecalloc(1, sizeof(pdo_pgsql_db_handle), dbh->is_persistent);
@@ -1051,44 +1050,18 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
10511050
connect_timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
10521051
}
10531052

1054-
if (dbh->password) {
1055-
if (dbh->password[0] != '\'' && dbh->password[strlen(dbh->password) - 1] != '\'') {
1056-
char *pwd = dbh->password;
1057-
int pos = 1;
1058-
1059-
tmp_pass = safe_emalloc(2, strlen(dbh->password), 3);
1060-
tmp_pass[0] = '\'';
1061-
1062-
while (*pwd != '\0') {
1063-
if (*pwd == '\\' || *pwd == '\'') {
1064-
tmp_pass[pos++] = '\\';
1065-
}
1066-
1067-
tmp_pass[pos++] = *pwd++;
1068-
}
1069-
1070-
tmp_pass[pos++] = '\'';
1071-
tmp_pass[pos] = '\0';
1072-
} else {
1073-
tmp_pass = dbh->password;
1074-
}
1075-
}
1076-
10771053
/* support both full connection string & connection string + login and/or password */
10781054
if (dbh->username && dbh->password) {
1079-
spprintf(&conn_str, 0, "%s user=%s password=%s connect_timeout=%ld", dbh->data_source, dbh->username, tmp_pass, connect_timeout);
1055+
spprintf(&conn_str, 0, "%s user=%s password=%s connect_timeout=%ld", dbh->data_source, dbh->username, dbh->password, connect_timeout);
10801056
} else if (dbh->username) {
10811057
spprintf(&conn_str, 0, "%s user=%s connect_timeout=%ld", dbh->data_source, dbh->username, connect_timeout);
10821058
} else if (dbh->password) {
1083-
spprintf(&conn_str, 0, "%s password=%s connect_timeout=%ld", dbh->data_source, tmp_pass, connect_timeout);
1059+
spprintf(&conn_str, 0, "%s password=%s connect_timeout=%ld", dbh->data_source, dbh->password, connect_timeout);
10841060
} else {
10851061
spprintf(&conn_str, 0, "%s connect_timeout=%ld", (char *) dbh->data_source, connect_timeout);
10861062
}
10871063

10881064
H->server = PQconnectdb(conn_str);
1089-
if (dbh->password && tmp_pass != dbh->password) {
1090-
efree(tmp_pass);
1091-
}
10921065

10931066
efree(conn_str);
10941067

ext/pdo_pgsql/tests/bug62479.phpt

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)