diff --git a/core/imageboard/event.php b/core/imageboard/event.php index 13883e67..27a00f96 100644 --- a/core/imageboard/event.php +++ b/core/imageboard/event.php @@ -114,7 +114,8 @@ class ThumbnailGenerationEvent extends Event /* * ParseLinkTemplateEvent: - * $link -- the formatted link + * $link -- the formatted text (with each element URL Escape'd) + * $text -- the formatted text (not escaped) * $original -- the formatting string, for reference * $image -- the image who's link is being parsed */ @@ -123,6 +124,8 @@ class ParseLinkTemplateEvent extends Event /** @var string */ public $link; /** @var string */ + public $text; + /** @var string */ public $original; /** @var Image */ public $image; @@ -131,6 +134,7 @@ class ParseLinkTemplateEvent extends Event { parent::__construct(); $this->link = $link; + $this->text = $link; $this->original = $link; $this->image = $image; } @@ -138,7 +142,8 @@ class ParseLinkTemplateEvent extends Event public function replace(string $needle, ?string $replace): void { if (!is_null($replace)) { - $this->link = str_replace($needle, $replace, $this->link); + $this->link = str_replace($needle, url_escape($replace), $this->link); + $this->text = str_replace($needle, $replace, $this->text); } } } diff --git a/core/imageboard/image.php b/core/imageboard/image.php index 300e2978..513ddbc1 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -492,7 +492,9 @@ class Image */ public function get_nice_image_name(): string { - return $this->parse_link_template('$id - $tags.$ext'); + $plte = new ParseLinkTemplateEvent('$id - $tags.$ext', $this); + send_event($plte); + return $plte->text; } /** @@ -534,7 +536,9 @@ class Image public function get_tooltip(): string { global $config; - return $this->parse_link_template($config->get_string(ImageConfig::TIP)); + $plte = new ParseLinkTemplateEvent($config->get_string(ImageConfig::TIP), $this); + send_event($plte); + return $plte->text; } /** diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index d4a99940..df87e9a2 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -273,7 +273,7 @@ class TagEdit extends Extension $tags = $event->image->get_tag_list(); $tags = str_replace("/", "", $tags); $tags = preg_replace("/^\.+/", "", $tags); - $event->replace('$tags', url_escape($tags)); + $event->replace('$tags', $tags); } private function mass_tag_edit(string $search, string $replace)