[art-web] [controllers] check the regular expressions matches before accessing
- From: Thomas Wood <thos src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [art-web] [controllers] check the regular expressions matches before accessing
- Date: Sat, 31 Oct 2009 22:52:25 +0000 (UTC)
commit b154ee622b84b938dbca5857a944d6bf2e32f925
Author: Thomas Wood <thos gnome org>
Date: Sat Oct 31 22:48:42 2009 +0000
[controllers] check the regular expressions matches before accessing
Don't try to access the sub-expression matches unless the match was
successful (i.e. the index exists in the matches array).
controllers/backgrounds.php | 12 ++++++++++--
controllers/themes.php | 11 +++++++++--
2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/controllers/backgrounds.php b/controllers/backgrounds.php
index 8fb8502..580350d 100644
--- a/controllers/backgrounds.php
+++ b/controllers/backgrounds.php
@@ -26,8 +26,16 @@ require ("models/backgrounds.php");
$bg = new BackgroundsModel();
preg_match ('/^\/backgrounds\/(abstract|gnome|nature|other|search)\/?([0-9]+)?$/', $_SERVER['PHP_SELF'], $params);
-$category = $params[1];
-$background_id = $params[2];
+
+if (array_key_exists (1, $params)
+ $category = $params[1];
+else
+ $category = '';
+
+if (array_key_exists (2, $params)
+ $background_id = $params[2];
+else
+ $background_id = 0;
$page = GET ('page');
if (!is_numeric ($page))
diff --git a/controllers/themes.php b/controllers/themes.php
index 0d4442c..456bda3 100644
--- a/controllers/themes.php
+++ b/controllers/themes.php
@@ -27,9 +27,16 @@ $themes = new ThemesModel();
preg_match ('/^\/themes\/(gtk2|metacity|icon|gdm_greeter|splash_screens|gtk_engines|search)\/?([0-9]+)?$/',
$_SERVER['PHP_SELF'], $params);
-$category = $params[1];
-$theme_id = $params[2];
+if (array_key_exists (1, $params)
+ $category = $params[1];
+else
+ $category = '';
+
+if (array_key_exists (2, $params)
+ $theme_id = $params[2];
+else
+ $theme_id = 0;
$page = GET ('page');
if (!is_numeric ($page))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]