From: Adrian Lang Date: Mon, 26 Jan 2009 14:03:38 +0000 (+0100) Subject: Fix canonical tags in notice and in URLs X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a80a536e4104bf1b621a86b72d35c7f637d7afd5;p=quix0rs-gnu-social.git Fix canonical tags in notice and in URLs --- diff --git a/actions/tag.php b/actions/tag.php index 039cd9660b..803026e624 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -24,13 +24,18 @@ class TagAction extends Action function prepare($args) { parent::prepare($args); - $this->tag = $this->trimmed('tag'); + $taginput = $this->trimmed('tag'); + $this->tag = common_canonical_tag($taginput); if (!$this->tag) { common_redirect(common_local_url('publictagcloud'), 301); return false; } + if ($this->tag != $taginput) { + common_redirect(common_local_url('tag', array('tag' => $this->tag))); + } + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; return true; } diff --git a/classes/Notice.php b/classes/Notice.php index c597137fee..2cdf80f1c0 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -91,11 +91,11 @@ class Notice extends Memcached_DataObject return true; } - /* elide characters we don't want in the tag */ - $match[1] = str_replace(array('-', '_', '.'), '', $match[1]); - /* Add them to the database */ foreach(array_unique($match[1]) as $hashtag) { + /* elide characters we don't want in the tag */ + $hashtag = common_canonical_tag($hashtag); + $tag = DB_DataObject::factory('Notice_tag'); $tag->notice_id = $this->id; $tag->tag = $hashtag;