From 57acbc85b885d44b4218af60cb485262a87a11b0 Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Wed, 28 Jun 2017 11:42:11 +0100
Subject: [PATCH] Add rawurlencode() calls everywhere in the redirect logic to
 fix #139

---
 build/index.php              | 10 +++++-----
 module_index.json            | 12 ++++++------
 modules/feature-redirect.php |  2 +-
 modules/feature-search.php   |  2 +-
 modules/page-view.php        |  6 +++---
 5 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/build/index.php b/build/index.php
index 13cfccd..932581d 100644
--- a/build/index.php
+++ b/build/index.php
@@ -3038,7 +3038,7 @@ function render_recent_change($rchange)
 
 register_module([
 	"name" => "Redirect pages",
-	"version" => "0.3",
+	"version" => "0.3.1",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds support for redirect pages. Uses the same syntax that Mediawiki does.",
 	"id" => "feature-redirect",
@@ -3075,7 +3075,7 @@ register_module([
 
 register_module([
 	"name" => "Search",
-	"version" => "0.5",
+	"version" => "0.5.1",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
 	"id" => "feature-search",
@@ -6349,7 +6349,7 @@ register_module([
 
 register_module([
 	"name" => "Page viewer",
-	"version" => "0.16.5",
+	"version" => "0.16.6",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Allows you to view pages. You really should include this one.",
 	"id" => "page-view",
@@ -6412,7 +6412,7 @@ register_module([
 				{
 					// Todo send an explanatory page along with the redirect
 					http_response_code(307);
-					$redirectUrl = "?action=$env->action&redirected_from=$env->page";
+					$redirectUrl = "?action=$env->action&redirected_from=" . rawurlencode($env->page);
 					
 					$hashCode = "";
 					$newPage = $pageindex->$page->redirect_target;
@@ -6423,7 +6423,7 @@ register_module([
 						// Remove the hash from the new page name
 						$newPage = substr($newPage, 0, strpos($newPage, "#"));
 					}
-					$redirectUrl .= "&page=$newPage";
+					$redirectUrl .= "&page=" . rawurlencode($newPage);
 					if(!empty($pageindex->$newPage->redirect))
 						$redirectUrl .= "&redirect=no";
 					if(strlen($hashCode) > 0)
diff --git a/module_index.json b/module_index.json
index 8f749a5..5cdfa55 100755
--- a/module_index.json
+++ b/module_index.json
@@ -91,20 +91,20 @@
     },
     {
         "name": "Redirect pages",
-        "version": "0.3",
+        "version": "0.3.1",
         "author": "Starbeamrainbowlabs",
         "description": "Adds support for redirect pages. Uses the same syntax that Mediawiki does.",
         "id": "feature-redirect",
-        "lastupdate": 1452949822,
+        "lastupdate": 1498646092,
         "optional": false
     },
     {
         "name": "Search",
-        "version": "0.5",
+        "version": "0.5.1",
         "author": "Starbeamrainbowlabs",
         "description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
         "id": "feature-search",
-        "lastupdate": 1498645080,
+        "lastupdate": 1498646440,
         "optional": false
     },
     {
@@ -235,11 +235,11 @@
     },
     {
         "name": "Page viewer",
-        "version": "0.16.5",
+        "version": "0.16.6",
         "author": "Starbeamrainbowlabs",
         "description": "Allows you to view pages. You really should include this one.",
         "id": "page-view",
-        "lastupdate": 1497797582,
+        "lastupdate": 1498646088,
         "optional": false
     },
     {
diff --git a/modules/feature-redirect.php b/modules/feature-redirect.php
index f7fd2f9..66fd0d8 100644
--- a/modules/feature-redirect.php
+++ b/modules/feature-redirect.php
@@ -1,7 +1,7 @@
 <?php
 register_module([
 	"name" => "Redirect pages",
-	"version" => "0.3",
+	"version" => "0.3.1",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds support for redirect pages. Uses the same syntax that Mediawiki does.",
 	"id" => "feature-redirect",
diff --git a/modules/feature-search.php b/modules/feature-search.php
index aa25223..795e2c0 100755
--- a/modules/feature-search.php
+++ b/modules/feature-search.php
@@ -1,7 +1,7 @@
 <?php
 register_module([
 	"name" => "Search",
-	"version" => "0.5",
+	"version" => "0.5.1",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
 	"id" => "feature-search",
diff --git a/modules/page-view.php b/modules/page-view.php
index 4b5a8ba..ebb817c 100644
--- a/modules/page-view.php
+++ b/modules/page-view.php
@@ -1,7 +1,7 @@
 <?php
 register_module([
 	"name" => "Page viewer",
-	"version" => "0.16.5",
+	"version" => "0.16.6",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Allows you to view pages. You really should include this one.",
 	"id" => "page-view",
@@ -64,7 +64,7 @@ register_module([
 				{
 					// Todo send an explanatory page along with the redirect
 					http_response_code(307);
-					$redirectUrl = "?action=$env->action&redirected_from=$env->page";
+					$redirectUrl = "?action=$env->action&redirected_from=" . rawurlencode($env->page);
 					
 					$hashCode = "";
 					$newPage = $pageindex->$page->redirect_target;
@@ -75,7 +75,7 @@ register_module([
 						// Remove the hash from the new page name
 						$newPage = substr($newPage, 0, strpos($newPage, "#"));
 					}
-					$redirectUrl .= "&page=$newPage";
+					$redirectUrl .= "&page=" . rawurlencode($newPage);
 					if(!empty($pageindex->$newPage->redirect))
 						$redirectUrl .= "&redirect=no";
 					if(strlen($hashCode) > 0)
