From: Devops Date: Thu, 25 May 2017 23:03:01 +0000 (+0100) Subject: bug in out format sh, ovh errors X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=01e4066f505a2202f66fbdfa21c24518c0b49d80;p=nb.git bug in out format sh, ovh errors --- diff --git a/bin/ovh-api b/bin/ovh-api index aa177970..95556afa 100755 --- a/bin/ovh-api +++ b/bin/ovh-api @@ -103,8 +103,15 @@ sub _query { my ($url,$method,$body) = @_; exists $ALIASES{$url} and $url = $ALIASES{$url}; - my $response = $Api->rawCall(path=>$url,method=>($method||'GET'),body=>$body); - die "$NAME: ERR: ".$response->error() if $response->isFailure(); + my $response; + eval { + $response = $Api->rawCall(path=>$url,method=>($method||'GET'),body=>$body); + }; + die "$NAME: Connection failed $! $@" unless $response; + if ($response->isFailure()) { + die "$NAME: ERR: Connection failed" if $response->error() =~ /Internal Server Error/; + die "$NAME: ERR: ".$response->error(); + } my $content = $response->content; return unless defined $content; @@ -119,7 +126,12 @@ sub _query { next unless defined $id; $id =~ s,/.*$,,; - $response = $Api->rawCall(path=>$url.'/'.$id,method=>($method||'GET'),body=>{}); + eval { + $response = $Api->rawCall(path=>$url.'/'.$id,method=>($method||'GET'),body=>{}); + }; + + die "$NAME: Query failed $! $@" unless $response; + die "$NAME: ERR: Connection failed" if $response->error() =~ /Internal Server Error/; die "$NAME: ERR: ".$response->error() if $response->isFailure(); diff --git a/lib/php/out.php b/lib/php/out.php index 0f3ce065..19e5d87b 100644 --- a/lib/php/out.php +++ b/lib/php/out.php @@ -88,6 +88,8 @@ Class Out extends Nb { $v = str_replace('"','\\"',$v); $v = str_replace('$','\\$',$v); $v = str_replace('`','\\`',$v); + $v = str_replace("\r",'',$v); + $v = str_replace("\n",'"$\'\\\\n\'"',$v); $line[] = $o['preff']."$k=\"$v\""; } if ($line) echo join(' ',$line).";\n"; diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 74b9f581..2ae1166d 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -13,7 +13,7 @@ class DbQ extends nb { const WRITE = 3; const VIEW = 1; public $perm = self::ADMIN; - public $perms = [ + public $perms = [ # keys in lowercase !!!! 'admin' => self::ADMIN, 'delete' => self::DELETE, 'write' => self::WRITE, @@ -101,9 +101,7 @@ class DbQ extends nb { // Format perm into int value $perm = strtolower($this->perm); - if (isset($this->perms[$perm])) { - $this->perm = $this->perms[$perm]; - } + if (isset($this->perms[$perm])) $this->perm = $this->perms[$perm]; if (!preg_match('/^[0-9]+$/',$perm)) $perm = 0; parent::__construct($opt);