summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/gallery_installer.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2013-03-12 17:00:55 -0700
committerBharat Mediratta <bharat@menalto.com>2013-03-12 17:00:55 -0700
commite2ee3499ca1d7980dd84c7c649d69ce11f381915 (patch)
tree8df518a597c5967755816c9f6b8e4f08381f6e03 /modules/gallery/helpers/gallery_installer.php
parent94ac5521521309d81cafeb44b3ed5d8ff3527cc8 (diff)
parented20798b99c0c6ab90e4d141ff74d7c2ca606ae7 (diff)
Merge pull request #209 from shadlaws/fix_2057
#2057 - Revise item name and slug validation - backslashes, refactor, error messages.
Diffstat (limited to 'modules/gallery/helpers/gallery_installer.php')
-rw-r--r--modules/gallery/helpers/gallery_installer.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index d49be83f..f1604150 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -809,6 +809,26 @@ class gallery_installer {
->execute();
module::set_version("gallery", $version = 57);
}
+
+ if ($version == 57) {
+ // In v58 we changed the Item_Model validation code to disallow files or directories with
+ // backslashes in them, and we need to fix any existing items that have them. This is
+ // pretty unlikely, as having backslashes would have probably already caused other issues for
+ // users, but we should check anyway. This might be slow, but if it times out it can just
+ // pick up where it left off.
+ foreach (db::build()
+ ->from("items")
+ ->select("id")
+ ->where(db::expr("`name` REGEXP '\\\\\\\\'"), "=", 1) // one \, 3x escaped
+ ->order_by("id", "asc")
+ ->execute() as $row) {
+ set_time_limit(30);
+ $item = ORM::factory("item", $row->id);
+ $item->name = str_replace("\\", "_", $item->name);
+ $item->save();
+ }
+ module::set_version("gallery", $version = 58);
+ }
}
static function uninstall() {