[aur-dev] [PATCH 1/5] 404.php: Squelch warning on empty PATH_INFO
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/404.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/html/404.php b/web/html/404.php index 757c485..9f81d11 100644 --- a/web/html/404.php +++ b/web/html/404.php @@ -5,7 +5,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); $path = $_SERVER['PATH_INFO']; $tokens = explode('/', $path); -if (preg_match('/^([a-z0-9][a-z0-9.+_-]*?)(\.git)?$/', $tokens[1], $matches)) { +if (isset($tokens[1]) && preg_match('/^([a-z0-9][a-z0-9.+_-]*?)(\.git)?$/', $tokens[1], $matches)) { $gitpkg = $matches[1]; if (pkg_from_name($gitpkg)) { $gitcmd = 'git clone ' . sprintf(config_get('options', 'git_clone_uri_anon'), htmlspecialchars($gitpkg)); -- 2.12.0
Drop the fragment part of the redirection code which is an artifact of the original code copy-pasted in commit ca954fe (Do not redirect when showing errors during flagging, 2015-10-21). Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/pkgflag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/html/pkgflag.php b/web/html/pkgflag.php index 44849d8..25c8ccb 100644 --- a/web/html/pkgflag.php +++ b/web/html/pkgflag.php @@ -28,7 +28,7 @@ if (check_token()) { } if ($ret) { - header('Location: ' . get_pkgbase_uri($pkgbase_name) . $fragment); + header('Location: ' . get_pkgbase_uri($pkgbase_name)); exit(); } } -- 2.12.0
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/lib/acctfuncs.inc.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index a6eab27..3c8f9ed 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -301,7 +301,9 @@ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C="" } $uid = $dbh->lastInsertId(); - account_set_ssh_keys($uid, $ssh_keys, $ssh_fingerprints); + if (isset($ssh_keys) && count($ssh_keys) > 0) { + account_set_ssh_keys($uid, $ssh_keys, $ssh_fingerprints); + } $message = __("The account, %s%s%s, has been successfully created.", "<strong>", htmlspecialchars($U,ENT_QUOTES), "</strong>"); @@ -364,7 +366,11 @@ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C="" $q.= " WHERE ID = ".intval($UID); $result = $dbh->exec($q); - $ssh_key_result = account_set_ssh_keys($UID, $ssh_keys, $ssh_fingerprints); + if (isset($ssh_keys) && count($ssh_keys) > 0) { + $ssh_key_result = account_set_ssh_keys($UID, $ssh_keys, $ssh_fingerprints); + } else { + $ssh_key_result = true; + } if (isset($_COOKIE["AURTZ"]) && ($_COOKIE["AURTZ"] != $TZ)) { /* set new cookie for timezone */ -- 2.12.0
The SQL query retrieving the time zone from the database may return an empty result set if the session timeout was reached. Handle such cases gracefully by leaving the timezone variable unset. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/lib/timezone.inc.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/lib/timezone.inc.php b/web/lib/timezone.inc.php index 9fb2433..949f846 100644 --- a/web/lib/timezone.inc.php +++ b/web/lib/timezone.inc.php @@ -42,6 +42,9 @@ function set_tz() { if ($result) { $timezone = $result->fetchColumn(0); + if (!$timezone) { + unset($timezone); + } } $update_cookie = true; -- 2.12.0
In commit e171f6f (Migrate all DB code to use PDO, 2012-08-08), PDOStatement::fetchAll() was introduced as a drop-in replacement for mysql_fetch_array(). However, PDOStatement::fetchAll() returns a list of all results while mysql_fetch_array() returns a single result only. Instead of adding the missing indirection, simplify the code by using PDO::fetchColumn(). Also add some safeguards to prevent warnings if the result set returned by the query is empty. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/lib/translator.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/lib/translator.inc.php b/web/lib/translator.inc.php index 58648c4..d10f8e9 100644 --- a/web/lib/translator.inc.php +++ b/web/lib/translator.inc.php @@ -111,14 +111,16 @@ function set_lang() { $result = $dbh->query($q); if ($result) { - $row = $result->fetchAll(); - $LANG = $row[0]; + $LANG = $result->fetchColumn(0); + if (!$LANG) { + unset($LANG); + } } $update_cookie = 1; } # Set $LANG to default if nothing is valid. - if (!array_key_exists($LANG, $SUPPORTED_LANGS)) { + if (!isset($LANG) || !array_key_exists($LANG, $SUPPORTED_LANGS)) { $LANG = config_get('options', 'default_lang'); } -- 2.12.0
participants (1)
-
Lukas Fleischer