[Pkg-owncloud-commits] [owncloud] 34/223: Fixes based on suggestions
David Prévot
taffit at moszumanska.debian.org
Sun Jun 22 01:54:03 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 1b02991a1dfd3d8cb8a7992609e0235bb97876ea
Author: josh4trunks <joshruehlig at gmail.com>
Date: Wed Jun 11 21:47:45 2014 -0700
Fixes based on suggestions
I use the term socket for any extension, either unix socket, or internet socket (port).
I check if the socket is all digits
* only integers 0 and larger would pass this test.
I then check if the string is less than or equal to the maximum port number.
By using "if($socket)" I make sure socket isn't false, empty, or the string '0'.
I don't believe I need to initialize $port because $port will always be set if $socket is true. Please show me if I am wrong here. Thanks
---
lib/private/db.php | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/lib/private/db.php b/lib/private/db.php
index f5fd9fb..eec2b92 100644
--- a/lib/private/db.php
+++ b/lib/private/db.php
@@ -64,14 +64,10 @@ class OC_DB {
$pass = OC_Config::getValue( "dbpassword", "" );
$type = OC_Config::getValue( "dbtype", "sqlite" );
if(strpos($host, ':')) {
- list($host, $port)=explode(':', $host, 2);
- if(!is_int($port)||$port<1||$port>65535) {
- $socket=true;
- } else {
- $socket=false;
- }
+ list($host, $socket)=explode(':', $host, 2);
+ $port = ctype_digit($socket) && $socket<=65535;
} else {
- $port=false;
+ $socket=FALSE;
}
$factory = new \OC\DB\ConnectionFactory();
@@ -93,11 +89,11 @@ class OC_DB {
'host' => $host,
'dbname' => $name,
);
- if (!empty($port)) {
- if ($socket) {
- $connectionParams['unix_socket'] = $port;
+ if ($socket) {
+ if ($port) {
+ $connectionParams['port'] = $socket;
} else {
- $connectionParams['port'] = $port;
+ $connectionParams['unix_socket'] = $socket;
}
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list