From ae8d8033b9363d2acf46904be059a29c24fed9e9 Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 14 Feb 2023 01:19:28 +0000 Subject: [PATCH] safer cache keys --- ext/autocomplete/main.php | 2 +- ext/tag_list/main.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/autocomplete/main.php b/ext/autocomplete/main.php index 5c222a1e..006dddf0 100644 --- a/ext/autocomplete/main.php +++ b/ext/autocomplete/main.php @@ -51,7 +51,7 @@ class AutoComplete extends Extension } # memcache keys can't contain spaces - $cache_key = str_replace(' ', '+', "autocomplete-$search"); + $cache_key = "autocomplete:" . md5($search); $limitSQL = ""; $search = str_replace('_', '\_', $search); $search = str_replace('%', '\%', $search); diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index c5a44e41..7ccb5c33 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -555,8 +555,8 @@ class TagList extends Extension $wild_tags = $search; - $str_search = str_replace(" ", "+", Tag::implode($search)); - $related_tags = $cache->get("related_tags:$str_search"); + $cache_key = "related_tags:" . md5(Tag::implode($search)); + $related_tags = $cache->get($cache_key); if (is_null($related_tags)) { // $search_tags = array(); @@ -610,7 +610,7 @@ class TagList extends Extension } else { $related_tags = []; } - $cache->set("related_tags:$str_search", $related_tags, 60 * 60); + $cache->set($cache_key, $related_tags, 60 * 60); } return $related_tags; }