From 4790d26a6448ced1e646bd8a4a22d05acf1dfa0d Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Thu, 10 Nov 2005 13:46:12 +0000 Subject: [PATCH] Strip dots of category/author permalinks, they cause trouble. --- docs/NEWS | 3 +++ include/functions_permalinks.inc.php | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 0a9573a..e4c7a18 100644 --- 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) diff --git a/include/functions_permalinks.inc.php b/include/functions_permalinks.inc.php index d408ee4..328789d 100644 --- a/include/functions_permalinks.inc.php +++ b/include/functions_permalinks.inc.php @@ -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') { -- 2.39.5