From 72fbbcd6794facea2cf06d9742359d190257b00f Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 6 Oct 2020 17:30:18 +0200 Subject: Security: fix multiple XSS vulnerabilities + fix search tags with special chars XSS vulnerabilities fixed in editlink, linklist, tag.cloud and tag.list. Also fixed tag search with special characters: urlencode function needs to be applied on raw data, before espaping, otherwise the rendered URL is wrong. --- application/formatter/BookmarkFormatter.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'application/formatter/BookmarkFormatter.php') diff --git a/application/formatter/BookmarkFormatter.php b/application/formatter/BookmarkFormatter.php index 22ba7aae..0042dafe 100644 --- a/application/formatter/BookmarkFormatter.php +++ b/application/formatter/BookmarkFormatter.php @@ -58,7 +58,9 @@ abstract class BookmarkFormatter $out['title'] = $this->formatTitle($bookmark); $out['description'] = $this->formatDescription($bookmark); $out['thumbnail'] = $this->formatThumbnail($bookmark); + $out['urlencoded_taglist'] = $this->formatUrlEncodedTagList($bookmark); $out['taglist'] = $this->formatTagList($bookmark); + $out['urlencoded_tags'] = $this->formatUrlEncodedTagString($bookmark); $out['tags'] = $this->formatTagString($bookmark); $out['sticky'] = $bookmark->isSticky(); $out['private'] = $bookmark->isPrivate(); @@ -181,6 +183,18 @@ abstract class BookmarkFormatter return $this->filterTagList($bookmark->getTags()); } + /** + * Format Url Encoded Tags + * + * @param Bookmark $bookmark instance + * + * @return array formatted Tags + */ + protected function formatUrlEncodedTagList($bookmark) + { + return array_map('urlencode', $this->filterTagList($bookmark->getTags())); + } + /** * Format TagString * @@ -193,6 +207,18 @@ abstract class BookmarkFormatter return implode(' ', $this->formatTagList($bookmark)); } + /** + * Format TagString + * + * @param Bookmark $bookmark instance + * + * @return string formatted TagString + */ + protected function formatUrlEncodedTagString($bookmark) + { + return implode(' ', $this->formatUrlEncodedTagList($bookmark)); + } + /** * Format Class * Used to add specific CSS class for a link -- cgit v1.2.3