From: garvinhicking Date: Mon, 21 Aug 2006 14:34:24 +0000 (+0000) Subject: Fix some permalink situations X-Git-Tag: 1.1~112 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=92005e85a90a15910552079fd2b217e782264c97;p=s9y.git Fix some permalink situations --- diff --git a/docs/NEWS b/docs/NEWS index 39e1a06..720e106 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,10 @@ Version 1.1-beta2 () ------------------------------------------------------------------------ + * Change permalinks to allow "%" in URLS. Fix templatedropdown + plugin to remove double "//". Fix bad htmlspecialchars of the + RDF ident link. + * Allow to apply current permissions of a directory to all sub- directories (Matthew Groeninger) diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php index cb7da0d..1eee9c9 100644 --- a/include/functions_entries.inc.php +++ b/include/functions_entries.inc.php @@ -953,9 +953,10 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm $entry['html_title']= $entry['title']; $entry['title'] = htmlspecialchars($entry['title']); - $entry['title_rdf'] = preg_replace('@-{2,}@', '-', $entry['title']); + $entry['title_rdf'] = preg_replace('@-{2,}@', '-', $entry['html_title']); $entry['rdf_ident'] = serendipity_archiveURL($entry['id'], $entry['title_rdf'], 'baseURL', true, array('timestamp' => $entry['timestamp'])); $entry['link_rdf'] = serendipity_rewriteURL(PATH_FEEDS . '/ei_'. $entry['id'] .'.rdf'); + $entry['title_rdf'] = htmlspecialchars($entry['title_rdf']); $entry['link_allow_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=enable&serendipity[entry]=' . $entry['id']; $entry['link_deny_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=disable&serendipity[entry]=' . $entry['id']; diff --git a/include/functions_permalinks.inc.php b/include/functions_permalinks.inc.php index c1939f7..c49e6bd 100644 --- a/include/functions_permalinks.inc.php +++ b/include/functions_permalinks.inc.php @@ -247,10 +247,11 @@ function serendipity_initPermalinks() { * If you add new patterns, remember to add the new rules to the *.tpl files and * function serendipity_installFiles(). */ - @define('PAT_FILENAME', '0-9a-z\.\_!;,\+\-'); - @define('PAT_CSS', '@/(serendipity\.css|serendipity_admin\.css)@'); - @define('PAT_FEED', '@/(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)@'); - @define('PAT_COMMENTSUB', '@/([0-9]+)[_\-][' . PAT_FILENAME . ']*\.html@i'); + @define('PAT_FILENAME', '0-9a-z\.\_!;,\+\-%'); + @define('PAT_FILENAME_MATCH', '[' . PAT_FILENAME . ']+'); + @define('PAT_CSS', '@/(serendipity\.css|serendipity_admin\.css)@'); + @define('PAT_FEED', '@/(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)@'); + @define('PAT_COMMENTSUB', '@/([0-9]+)[_\-][' . PAT_FILENAME . ']*\.html@i'); return true; } @@ -558,13 +559,13 @@ function serendipity_makePermalink($format, $data, $type = 'entry') { */ function serendipity_makePermalinkRegex($format, $type = 'entry') { static $entryKeys = array('%id%', '%title%', '%day%', '%month%', '%year%'); - static $entryRegexValues = array('([0-9]+)', '[0-9a-z\.\_!;,\+\-]+', '[0-9]{1,2}', '[0-9]{1,2}', '[0-9]{4}'); + static $entryRegexValues = array('([0-9]+)', PAT_FILENAME_MATCH, '[0-9]{1,2}', '[0-9]{1,2}', '[0-9]{4}'); static $authorKeys = array('%id%', '%username%', '%realname%', '%email%'); - static $authorRegexValues = array('([0-9]+)', '[0-9a-z\.\_!;,\+\-]+', '[0-9a-z\.\_!;,\+\-]+', '[0-9a-z\.\_!;,\+\-]+'); + static $authorRegexValues = array('([0-9]+)', PAT_FILENAME_MATCH, PAT_FILENAME_MATCH, PAT_FILENAME_MATCH); static $categoryKeys = array('%id%', '%name%', '%description%'); - static $categoryRegexValues = array('([0-9;]+)', '[0-9a-z\.\_!;,\+\-]+', '[0-9a-z\.\_!;,\+\-]+'); + static $categoryRegexValues = array('([0-9;]+)', PAT_FILENAME_MATCH, PAT_FILENAME_MATCH); switch($type) { case 'entry': @@ -692,7 +693,7 @@ function serendipity_archiveDateUrl($range, $summary=false, $key='baseURL') { * @access public * @return string the current URL */ -function serendipity_currentURL() { +function serendipity_currentURL($strict = false) { global $serendipity; // All that URL getting humpty-dumpty is necessary to allow a user to change the template in the @@ -704,7 +705,7 @@ function serendipity_currentURL() { if (!empty($uri['query'])) { $qst = '&' . str_replace('&', '&', $uri['query']); } - $uri['path'] = preg_replace('@^' . preg_quote($serendipity['serendipityHTTPPath']) . '@i', '', $uri['path']); + $uri['path'] = preg_replace('@^' . preg_quote($serendipity['serendipityHTTPPath']) . '@i', ($strict ? '/' : ''), $uri['path']); $uri['path'] = preg_replace('@^(&)?' . preg_quote($serendipity['indexFile']) . '(&)@i', '', $uri['path']); $url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?' . $uri['path'] . $qst; $url = str_replace( @@ -727,6 +728,10 @@ function serendipity_currentURL() { $url); // Kill possible looped repitions and bad characters which could occur + if ($strict) { + $url = preg_replace('@(//+), '/', $url); + } + return $url; } diff --git a/plugins/serendipity_plugin_templatedropdown/serendipity_plugin_templatedropdown.php b/plugins/serendipity_plugin_templatedropdown/serendipity_plugin_templatedropdown.php index 21d043c..866bdeb 100644 --- a/plugins/serendipity_plugin_templatedropdown/serendipity_plugin_templatedropdown.php +++ b/plugins/serendipity_plugin_templatedropdown/serendipity_plugin_templatedropdown.php @@ -19,7 +19,7 @@ class serendipity_plugin_templatedropdown extends serendipity_plugin { $propbag->add('description', PLUGIN_TEMPLATEDROPDOWN_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Evan Nemerson'); - $propbag->add('version', '1.0'); + $propbag->add('version', '1.2'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', @@ -62,13 +62,13 @@ class serendipity_plugin_templatedropdown extends serendipity_plugin { $title = $this->get_config('title', $this->title); - $url = serendipity_currentURL(); + $url = serendipity_currentURL(true); echo '
'; echo '';