Skip to content

Commit 28814ab

Browse files
authored
Merge pull request #14 from int2001/db_cfg_sanit
Escape escape-char, too. rmvd warning (since \ should be possible now)
2 parents c65cc18 + 9d3550b commit 28814ab

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

install/includes/core_class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ function write_config($data)
118118
$database_file = file_get_contents($template_path);
119119

120120
// Sanitize DB Password from single quotes
121-
$sanitized_db_pwd = preg_replace("/\'/i",'\\\'',$data['db_password']);
121+
$sanitized_db_pwd = preg_replace("/\\\\/i",'\\\\\\\\',$data['db_password']); // Escape the Escape char ( '\' becomes '\\' )
122+
$sanitized_db_pwd = preg_replace("/\'/i",'\\\\\'',$sanitized_db_pwd); // Escape the ' ( ' becomes \' )
122123

123124
$new = str_replace("%HOSTNAME%", $data['db_hostname'], $database_file);
124125
$new = str_replace("%USERNAME%", $data['db_username'], $new);

install/index.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,12 +1108,6 @@ function db_connection_test() {
11081108
return;
11091109
}
11101110

1111-
if (db_hostname.includes('\\') || db_username.includes('\\') || db_password.includes('\\') || db_name.includes('\\')) {
1112-
$('#db_connection_testresult').addClass('alert-danger');
1113-
$('#db_connection_testresult').html('Error: Input cannot contain a backslash (\\).');
1114-
return;
1115-
}
1116-
11171111
var originalButtonText = $('#db_connection_test_button').html();
11181112
$('#db_connection_test_button').html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Connecting...').prop('disabled', true);
11191113

@@ -1468,4 +1462,4 @@ function prevTab() {
14681462

14691463
<?php endif; ?>
14701464

1471-
</html>
1465+
</html>

0 commit comments

Comments
 (0)