Index: main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js
===================================================================
--- main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 32773)
+++ main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 32774)
@@ -43,23 +43,9 @@
 /* URL encode RESERVED characters in a non-URL context of a URL, such as the inline template (ilt) parameter value of a URL */
 function makeSafeForURL(url_part, encode_percentages) {
-    // https://stackoverflow.com/questions/7368407/javascript-replace-a-set-of-characters-with-another-one
-    var reserved_mappings = {
-	';': '%3B',
-	'/': '%2F',
-	'?': '%3F',
-	':': '%3A',
-	'@': '%40',
-	'=': '%3D',
-	'&': '%26'
-    };
     // https://stackoverflow.com/questions/12797118/how-can-i-declare-optional-function-parameters-in-javascript
     encode_percentages = encode_percentages || 1; // this method forces the URL-encoding of any % in url_part, e.g. do this for inline-templates that haven't ever been encoded
-    url_part = makeURLSafe(url_part, encode_percentages);
-
-    var url_encoded = url_part.replace(/[\;\/\?\:\@\=\&]/g, function(s) {
-	return reserved_mappings[s];
-    });
     
-    //var url_encoded = url_part.replace(/;/g, "%3B").replace(/\//g, "%2F").replace(/\?/g, "%3F").replace(/\:/g, "%3A").replace(/\@/g, "%40").replace(/=/g, "%3D").replace(/\&/g,"%26");
+    var url_encoded = makeURLSafe(url_part, encode_percentages);
+    url_encoded = url_encoded.replace(/;/g, "%3B").replace(/\//g, "%2F").replace(/\?/g, "%3F").replace(/\:/g, "%3A").replace(/\@/g, "%40").replace(/=/g, "%3D").replace(/\&/g,"%26");
     return url_encoded;
 }
@@ -69,42 +55,12 @@
    Set encode_percentages to 1 (true) if the url isn't already partly URL encoded
 */
-function makeURLSafe(url, encode_percentages) {
-    // https://stackoverflow.com/questions/12797118/how-can-i-declare-optional-function-parameters-in-javascript
-    encode_percentages = encode_percentages || 0;
-    
-    var unsafe_mappings = {
-	' ': '%20',
-	'"': '%22',
-	'<': '%3C',
-	'>': '%3E',
-	'#': '%23',
-	'{': '%7B',
-	'}': '%7D',
-	'|': '%7C',
-	'\\': '%5C',
-	'^': '%5E',
-	//'~': '~', // unreserved char (but is it then unsafe?), as per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
-	'[': '%5B',
-	']': '%5D',
-	'`': '%60'
-    };    
+function makeURLSafe(url, encode_percentages) {    
+    encode_percentages = encode_percentages || 0; // https://stackoverflow.com/questions/12797118/how-can-i-declare-optional-function-parameters-in-javascript
 
     var url_encoded = url;
-    if(encode_percentages) {
-	// https://stackoverflow.com/questions/1168807/how-can-i-add-a-key-value-pair-to-a-javascript-object
-	//unsafe_mappings["%"] = "%25";
-	url_encoded = url_encoded.replace(/\%/g,"%25"); // encode % first
-
-    }
-    url_encoded = url_encoded.replace(/[\ \"\<\>\#\{\}\|\\\^\[\]\`]/g, function(s) {
-	return unsafe_mappings[s];
-    });
-    
-
-    //var url_encoded = url;
-    ///if(encode_percentages) {	url_encoded = url_encoded.replace(/\%/g,"%25"); } // encode % first
-    //url_encoded = url_encoded.replace(/ /g, "%20").replace(/\"/g,"%22").replace(/\</g,"%3C").replace(/\>/g,"%3E").replace(/\#/g,"%23").replace(/\{/g,"%7B").replace(/\}/g,"%7D");
-    //url_encoded = url_encoded.replace(/\|/g,"%7C").replace(/\\/g,"%5C").replace(/\^/g,"%5E").replace(/\[/g,"%5B").replace(/\]/g,"%5D").replace(/\`/g,"%60");
-    
+    if(encode_percentages) { url_encoded = url_encoded.replace(/\%/g,"%25"); } // encode % first
+    url_encoded = url_encoded.replace(/ /g, "%20").replace(/\"/g,"%22").replace(/\</g,"%3C").replace(/\>/g,"%3E").replace(/\#/g,"%23").replace(/\{/g,"%7B").replace(/\}/g,"%7D");
+    url_encoded = url_encoded.replace(/\|/g,"%7C").replace(/\\/g,"%5C").replace(/\^/g,"%5E").replace(/\[/g,"%5B").replace(/\]/g,"%5D").replace(/\`/g,"%60");
+    // Should we handle ~, but then what is its URL encoded value? Because https://meyerweb.com/eric/tools/dencoder/ URLencodes ~ to ~.
     return url_encoded;
 }
