aboutsummaryrefslogtreecommitdiffstats
path: root/lib/setup.php
diff options
context:
space:
mode:
authorBrice Maron <brice@bmaron.net>2012-05-04 22:54:55 +0000
committerBrice Maron <brice@bmaron.net>2012-05-04 22:54:55 +0000
commit4a89eb77c1732a49075d4f3f6a46ddaad10eef70 (patch)
tree12b589967cd808246617867fc24d2d3a82525ff7 /lib/setup.php
parent2c264f836c382f3c3555918484c749d0633a8308 (diff)
downloadnextcloud-server-4a89eb77c1732a49075d4f3f6a46ddaad10eef70.tar.gz
nextcloud-server-4a89eb77c1732a49075d4f3f6a46ddaad10eef70.zip
Escape strings for DB and User creation at setup. Fix oc-124
Diffstat (limited to 'lib/setup.php')
-rw-r--r--lib/setup.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/setup.php b/lib/setup.php
index 3dca3c50918..24d05592377 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -271,19 +271,23 @@ class OC_Setup {
public static function pg_createDatabase($name,$user,$connection) {
//we cant use OC_BD functions here because we need to connect as the administrative user.
- $query = "CREATE DATABASE $name OWNER $user";
+ $e_name = pg_escape_string($name);
+ $e_user = pg_escape_string($user);
+ $query = "CREATE DATABASE \"$e_name\" OWNER \"$e_user\"";
$result = pg_query($connection, $query);
if(!$result) {
$entry='DB Error: "'.pg_last_error($connection).'"<br />';
$entry.='Offending command was: '.$query.'<br />';
echo($entry);
}
- $query = "REVOKE ALL PRIVILEGES ON DATABASE $name FROM PUBLIC";
+ $query = "REVOKE ALL PRIVILEGES ON DATABASE \"$e_name\" FROM PUBLIC";
$result = pg_query($connection, $query);
}
private static function pg_createDBUser($name,$password,$connection) {
- $query = "CREATE USER $name CREATEDB PASSWORD '$password';";
+ $e_name = pg_escape_string($name);
+ $e_password = pg_escape_string($password);
+ $query = "CREATE USER \"$e_name\" CREATEDB PASSWORD '$e_password';";
$result = pg_query($connection, $query);
if(!$result) {
$entry='DB Error: "'.pg_last_error($connection).'"<br />';