]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fix canonical tags in notice and in URLs
authorAdrian Lang <mail@adrianlang.de>
Mon, 26 Jan 2009 14:03:38 +0000 (15:03 +0100)
committerEvan Prodromou <evan@controlyourself.ca>
Mon, 26 Jan 2009 14:03:38 +0000 (15:03 +0100)
actions/tag.php
classes/Notice.php

index 039cd9660b71a0a0ad1fb0cbe7b9d927feeea889..803026e624d574df2d2ebb9ebf3cbc8f921dd639 100644 (file)
@@ -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;
     }
index c597137feed8b61b494e514a82d2cb3fc92d21ec..2cdf80f1c0b7cacf90336a4430e93048648097bf 100644 (file)
@@ -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;