]> git.mjollnir.org Git - s9y.git/commitdiff
Fix some permalink situations
authorgarvinhicking <garvinhicking>
Mon, 21 Aug 2006 14:34:24 +0000 (14:34 +0000)
committergarvinhicking <garvinhicking>
Mon, 21 Aug 2006 14:34:24 +0000 (14:34 +0000)
docs/NEWS
include/functions_entries.inc.php
include/functions_permalinks.inc.php
plugins/serendipity_plugin_templatedropdown/serendipity_plugin_templatedropdown.php

index 39e1a0659786e5af13bb34adcb85f44073811a81..720e10637692c140b9578391b189f3d27b7d8e70 100644 (file)
--- 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)
 
index cb7da0d975c34b4014eceec7ad3dc869ad70f9d6..1eee9c947203d48d703bc07d9f1b8de5d2b0f5c1 100644 (file)
@@ -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&amp;serendipity[entry]=' . $entry['id'];
             $entry['link_deny_comments']     = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=disable&amp;serendipity[entry]=' . $entry['id'];
index c1939f7f87fc906d44a6c84184eea4ca2f0cfc2b..c49e6bd72150b27d20be168372379dfb03279501 100644 (file)
@@ -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 = '&amp;' . str_replace('&', '&amp;', $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('@^(&amp;)?' . preg_quote($serendipity['indexFile']) . '(&amp;)@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;
 }
 
index 21d043c82012928457ad3cb5dfca8d7d9646b386..866bdeb5a17dda9956231746ef895173fd63fafb 100644 (file)
@@ -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 '<form id="theme_chooser" action="' . $url . '" method="post">';
         echo '<select name="user_template" onchange="document.getElementById(\'theme_chooser\').submit();">';
         foreach (serendipity_fetchTemplates() as $template) {
             $templateInfo = serendipity_fetchTemplateInfo($template);
-            echo '<option value="' . $template . '" ' . (serendipity_get_config_var('template', 'default') == $template ? 'selected="selected"' : '') . '>' . $templateInfo['name'] . '</option>';
+            echo '<option value="' . $template . '" ' . (serendipity_get_config_var('template', 'default') == $template ? 'selected="selected"' : '') . '>' . substr($templateInfo['name'], 0, 25) . '</option>';
         }
         echo '</select>';