]> git.mjollnir.org Git - s9y.git/commitdiff
Strip dots of category/author permalinks, they cause trouble.
authorgarvinhicking <garvinhicking>
Thu, 10 Nov 2005 13:46:12 +0000 (13:46 +0000)
committergarvinhicking <garvinhicking>
Thu, 10 Nov 2005 13:46:12 +0000 (13:46 +0000)
docs/NEWS
include/functions_permalinks.inc.php

index 0a9573ae02695a3975a2494acbf24d5084de631b..e4c7a18be20fa40190039bbaaebe52fcb82d28f4 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 1.0 ()
 ------------------------------------------------------------------------
 
+   * Fix wrong URL permalink detection when categories contain "." or "_"
+     characters (garvinhicking)
+
    * Spamblock plugin can block comments when they only contain the
      entry title (garvinhicking)
 
index d408ee4273f13ea82bfec9d8510aa31c4edf499b..328789d48c6724cea0639ebd56223e0df08bfc19 100644 (file)
@@ -2,7 +2,7 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
-function serendipity_makeFilename($str) {
+function serendipity_makeFilename($str, $stripDots = false) {
     static $from = array(
                      ' ',
 
@@ -107,6 +107,11 @@ function serendipity_makeFilename($str) {
     // Nuke chars not allowed in our URI
     $str = preg_replace('#[^' . PAT_FILENAME . ']#i', '', $str);
 
+    // Check if dots are allowed
+    if ($stripDots) {
+        $str = str_replace('.', '', $str);
+    }
+
     // Remove consecutive separators
     $str = preg_replace('#'. $to[0] .'{2,}#s', $to[0], $str);
 
@@ -411,9 +416,9 @@ function serendipity_makePermalink($format, $data, $type = 'entry') {
             $replacements =
                 array(
                     (int)$data['authorid'],
-                    serendipity_makeFilename($data['username']),
-                    serendipity_makeFilename($data['realname']),
-                    serendipity_makeFilename($data['email'])
+                    serendipity_makeFilename($data['username'], true),
+                    serendipity_makeFilename($data['realname'], true),
+                    serendipity_makeFilename($data['email'], true)
                 );
             return str_replace($authorKeys, $replacements, $format);
             break;
@@ -422,8 +427,8 @@ function serendipity_makePermalink($format, $data, $type = 'entry') {
             $replacements =
                 array(
                     (int)$data['categoryid'],
-                    serendipity_makeFilename($data['category_name']),
-                    serendipity_makeFilename($data['category_description'])
+                    serendipity_makeFilename($data['category_name'], true),
+                    serendipity_makeFilename($data['category_description'], true)
                 );
             return str_replace($categoryKeys, $replacements, $format);
             break;
@@ -545,7 +550,7 @@ function serendipity_getUriArguments($uri, $wildcard = false) {
 global $serendipity;
 
     /* Explode the path into sections, to later be able to check for arguments and add our own */
-    preg_match('/^'. preg_quote($serendipity['serendipityHTTPPath'], '/') . '(' . preg_quote($serendipity['indexFile'], '/') . '\?\/)?(' . ($wildcard ? '.+' : '[;a-z0-9\-*\/%\+]+') . ')/i', $uri, $_res);
+    preg_match('/^'. preg_quote($serendipity['serendipityHTTPPath'], '/') . '(' . preg_quote($serendipity['indexFile'], '/') . '\?\/)?(' . ($wildcard ? '.+' : '[;,_a-z0-9\-*\/%\+]+') . ')/i', $uri, $_res);
     if (strlen($_res[2]) != 0) {
         $args = explode('/', $_res[2]);
         if ($args[0] == 'index') {