diff --git a/inc/common.php b/inc/common.php
index 8ad55efff871ad4e03a9873d200c587b77bb7378..c943ffa3cf55a1e034e1e74dd68bc94ab2a3e45b 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -101,7 +101,7 @@ function buildURLparams($params){
     if($amp) $url .= '&';
 
     $url .= $key.'=';
-    $url .= urlencode($val);
+    $url .= rawurlencode($val);
     $amp = true;
   }
   return $url;
@@ -232,7 +232,7 @@ function idfilter($id,$ue=true){
     $id = strtr($id,':',';');
   }
   if($ue){
-    $id = urlencode($id);
+    $id = rawurlencode($id);
     $id = str_replace('%3A',':',$id); //keep as colon
     $id = str_replace('%2F','/',$id); //keep as slash
   }
@@ -296,9 +296,9 @@ function ml($id='',$more='',$direct=true){
     $xlink .= 'lib/exe/fetch.php';
     if($more){
       $xlink .= '?'.$more;
-      $xlink .= '&media='.urlencode($id);
+      $xlink .= '&media='.rawurlencode($id);
     }else{
-      $xlink .= '?media='.urlencode($id);
+      $xlink .= '?media='.rawurlencode($id);
     }
     return $xlink;
   } 
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index d039395422f7db82c91b56758798507d447effa1..9fd31f3b2eb471427541be8d7fbcd61744fcbf89 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -510,7 +510,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
         //add search string
         if($search){
             ($conf['userewrite']) ? $link['url'].='?s=' : $link['url'].='&s=';
-            $link['url'] .= urlencode($search);
+            $link['url'] .= rawurlencode($search);
         }
 
         //keep hash
@@ -594,7 +594,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
         //replace placeholder
         if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#',$url)){
             //use placeholders
-            $url = str_replace('{URL}',urlencode($wikiUri),$url);
+            $url = str_replace('{URL}',rawurlencode($wikiUri),$url);
             $url = str_replace('{NAME}',$wikiUri,$url);
             $parsed = parse_url($wikiUri);
             if(!$parsed['port']) $parsed['port'] = 80;
@@ -606,9 +606,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
             $link['url'] = $url;
         }else{
             //default
-            $link['url'] = $url.urlencode($wikiUri);
+            $link['url'] = $url.rawurlencode($wikiUri);
         }
-        if($hash) $link['url'] .= '#'.urlencode($hash);
+        if($hash) $link['url'] .= '#'.rawurlencode($hash);
 
         $link['title'] = htmlspecialchars($link['url']);
 
diff --git a/inc/template.php b/inc/template.php
index 315373e214da4654a2bcb14c004068ab806bb37a..7fc824bd514ceab55c83b9d650d1cdcd24bf7d80 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -688,7 +688,7 @@ function tpl_mediafilelist(){
       $ask  = $lang['del_confirm'].'\\n';
       $ask .= $item['id'];
 
-      $del = '<a href="'.DOKU_BASE.'lib/exe/media.php?delete='.urlencode($item['id']).'" '.
+      $del = '<a href="'.DOKU_BASE.'lib/exe/media.php?delete='.rawurlencode($item['id']).'" '.
              'onclick="return confirm(\''.$ask.'\')" onkeypress="return confirm(\''.$ask.'\')">'.
              '<img src="'.DOKU_BASE.'lib/images/del.png" alt="'.$lang['btn_delete'].'" '.
              'title="'.$lang['btn_delete'].'" /></a>';
@@ -739,7 +739,7 @@ function tpl_mediafilelist(){
 
       //add edit button
       if($AUTH >= AUTH_UPLOAD && $item['meta']->getField('File.Mime') == 'image/jpeg'){
-        print '<a href="'.DOKU_BASE.'lib/exe/media.php?edit='.urlencode($item['id']).'">';
+        print '<a href="'.DOKU_BASE.'lib/exe/media.php?edit='.rawurlencode($item['id']).'">';
         print '<img src="'.DOKU_BASE.'lib/images/edit.gif" alt="'.$lang['metaedit'].'" title="'.$lang['metaedit'].'" />';
         print '</a>';
       }
@@ -927,7 +927,7 @@ function tpl_indexerWebBug(){
   if(isHiddenPage($ID)) return; //no need to index hidden pages
 
   $p = array();
-  $p['src']    = DOKU_BASE.'lib/exe/indexer.php?id='.urlencode($ID).
+  $p['src']    = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID).
                  '&'.time();
   $p['width']  = 1;
   $p['height'] = 1;