Index: main/trunk/greenstone2/macros/gti.dm
===================================================================
--- main/trunk/greenstone2/macros/gti.dm	(revision 28912)
+++ main/trunk/greenstone2/macros/gti.dm	(revision 28913)
@@ -98,5 +98,5 @@
 # Content of the GTI "find text fragments" page
 _gtifind_ {
-<h2><a href="_gwcgi_?a=gti&amp;p=lang&amp;e=_compressedoptions_">_gtitargetlanguagename_</a> -- <a href="_gwcgi_?a=gti&amp;p=core&amp;e=_compressedoptions_">_gtitranslationfiledesc_</a></h2>
+<h2><a href="_gwcgi_?a=gti&amp;p=lang&amp;e=_compressedoptions_">_gtitargetlanguagename_</a> -- <a href="_gwcgi_?a=gti&amp;p=core&amp;e=_compressedoptions_">_gtitranslationfiledescHtmlsafe_</a></h2>
 <p>
 _textgtienterquery_:
@@ -111,5 +111,5 @@
 # Content of the GTI "offline" page
 _gtioffline_ {
-<h2><a href="_gwcgi_?a=gti&amp;p=lang&amp;e=_compressedoptions_">_gtitargetlanguagename_</a> -- _gtitranslationfiledesc_</h2>
+<h2><a href="_gwcgi_?a=gti&amp;p=lang&amp;e=_compressedoptions_">_gtitargetlanguagename_</a> -- _gtitranslationfiledescHtmlsafe_</h2>
 <p>
 _textgtiofflinetranslation_
@@ -118,5 +118,5 @@
 # Content of the GTI "core" page (with text areas for entering and updating translations)
 _gticore_ {
-<h2><a href="_gwcgi_?a=gti&amp;p=lang&amp;e=_compressedoptions_">_gtitargetlanguagename_</a> -- _gtitranslationfiledesc_</h2>
+<h2><a href="_gwcgi_?a=gti&amp;p=lang&amp;e=_compressedoptions_">_gtitargetlanguagename_</a> -- _gtitranslationfiledescHtmlsafe_</h2>
 <p>
 <center>
@@ -133,5 +133,5 @@
 # Content of the GTI "done" page, thanking the translator for completing the file
 _gtidone_ {
-<h2><a href="_gwcgi_?a=gti&amp;p=lang&amp;e=_compressedoptions_">_gtitargetlanguagename_</a> -- _gtitranslationfiledesc_</h2>
+<h2><a href="_gwcgi_?a=gti&amp;p=lang&amp;e=_compressedoptions_">_gtitargetlanguagename_</a> -- _gtitranslationfiledescHtmlsafe_</h2>
 <p>
 <center>
@@ -169,5 +169,5 @@
 # --------------------------------------------------------------------------------
 
-# _If_(_gtiglihelpzipfilepath_ ne "", <a href="_httpprefix_/_gtiglihelpzipfilepath_">_textgtiglihelpzipfile_</a>,)<br>
+# _If_(_gtiglihelpzipfilepath_ ne "", <a href="_httpprefix_/_gtiglihelpzipfilepathUrlsafe_">_textgtiglihelpzipfile_</a>,)<br>
 # <a href="_gwcgi_?a=gti&amp;p=glihelp&amp;e=_compressedoptions_">_textgtiglihelpzipfile_</a>
 
@@ -180,8 +180,8 @@
      _If_("_4_" eq "_gtidownloadglihelp_", <a href="_4_">, <a href="_httpprefix_/_4_">)_textgtidownloadtargetfile_</a>
 
-     _If_(_gtiglihelpzipfilepath_, <a href="_httpprefix_/_gtiglihelpzipfilepath_">_textgtiglihelpzipfile_</a>,)<br>
+     _If_(_gtiglihelpzipfilepath_, <a href="_httpprefix_/_gtiglihelpzipfilepathUrlsafe_">_textgtiglihelpzipfile_</a>,)<br>
 
      <a href="_gwcgi_?a=gti&amp;p=offline&amp;e=_compressedoptions_">_textgtitranslatefileoffline_</a><br>
-     _gtiviewtranslationfileinaction_
+     _gtiviewtranslationfileinactionHtmlsafe_
   </td></tr>)
 </table>
Index: main/trunk/greenstone2/macros/users.dm
===================================================================
--- main/trunk/greenstone2/macros/users.dm	(revision 28912)
+++ main/trunk/greenstone2/macros/users.dm	(revision 28913)
@@ -62,8 +62,8 @@
 
 <table border=0>
-<tr><td>_authen:textusername_</td><td><input type="text" name="umun" value="_users:usersargun_" size=15></td>
+<tr><td>_authen:textusername_</td><td><input type="text" name="umun" value="_users:usersargunAttrsafe_" size=15></td>
 <td><font color=gray>_textaboutusername_</font></td>
 </tr>
-<tr><td>_authen:textpassword_</td><td><input type="text" name="umpw" value="_users:usersargpw_" size=9></td>
+<tr><td>_authen:textpassword_</td><td><input type="text" name="umpw" value="_users:usersargpwAttrsafe_" size=9></td>
 <td><font color=gray>_textaboutpassword_
 _If_("_cgiarguma_" eq "edituser",_textoldpass_)
@@ -75,8 +75,8 @@
 </select>
 </td></tr>
-<tr><td>_userslistusers:textgroups_</td><td colspan=2><input type="text" name="umug" value="_users:usersargug_" size=50></td></tr>
+<tr><td>_userslistusers:textgroups_</td><td colspan=2><input type="text" name="umug" value="_users:usersargugAttrsafe_" size=50></td></tr>
 <tr><td></td><td></td>
 <td><font color=gray>_textaboutgroups_</font><br/><font color=gray>_textavailablegroups_</font></td></tr>
-<tr><td>_userslistusers:textcomment_</td><td colspan=2><input type="text" name="umc" value="_users:usersargc_" size=50></td></tr>
+<tr><td>_userslistusers:textcomment_</td><td colspan=2><input type="text" name="umc" value="_users:usersargcAttrsafe_" size=50></td></tr>
 <tr><td></td><td colspan=2><input type="submit" name=beu value="submit">
 <input type="submit" name=uma value="cancel"></td></tr>
Index: main/trunk/greenstone2/runtime-src/src/recpt/dynamicclassifieraction.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/dynamicclassifieraction.cpp	(revision 28912)
+++ main/trunk/greenstone2/runtime-src/src/recpt/dynamicclassifieraction.cpp	(revision 28913)
@@ -102,5 +102,5 @@
     text_t dynamic_classifier_id = (*dynamic_classifier_iterator).first;
     navigation_bar_entries += "_navbarspacer_";
-    navigation_bar_entries += "_navtab_(_gwcgi_?c=" + args["c"] + "&amp;a=dc&amp;dcl=" + dynamic_classifier_id + "," + dynamic_classifier_id;
+    navigation_bar_entries += "_navtab_(_gwcgi_?c=" + encodeForURL(args["c"]) + "&amp;a=dc&amp;dcl=" + dynamic_classifier_id + "," + dynamic_classifier_id;
     if (args["a"] == "dc" && args["dcl"] == dynamic_classifier_id)
     {
Index: main/trunk/greenstone2/runtime-src/src/recpt/extlinkaction.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/extlinkaction.cpp	(revision 28912)
+++ main/trunk/greenstone2/runtime-src/src/recpt/extlinkaction.cpp	(revision 28913)
@@ -124,5 +124,13 @@
   // problem in whist, above line changed.  Perhaps decode_cgi_arg ??
   // see also HTML plugin
-  disp.setmacro("nexturl", "extlink", args["href"]);
+
+  text_t nexturl_macro = args["href"];
+  if(!isValidURLProtocol(nexturl_macro)) {
+    nexturl_macro = encodeForURL(nexturl_macro); // URL has invalid protocol like javascript:, so URL encode it
+  } else {
+    nexturl_macro = encodeForHTMLAttr(nexturl_macro);
+  }
+
+  disp.setmacro("nexturl", "extlink", nexturl_macro); // goes into a full-url context
   disp.setmacro("prevdoc", "extlink", args["d"]);
 }
Index: main/trunk/greenstone2/runtime-src/src/recpt/gtiaction.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/gtiaction.cpp	(revision 28912)
+++ main/trunk/greenstone2/runtime-src/src/recpt/gtiaction.cpp	(revision 28913)
@@ -386,5 +386,6 @@
   languageinfo_tmap loaded_languages = recpt->get_configinfo().languages;
   disp.setmacro("gtitargetlanguagename", "gti", loaded_languages[target_language_code].longname);
-  disp.setmacro("gtitranslationfiledesc", "gti", "_gti:textgti" + encodeForHTML(translation_file_key) + "_");
+  disp.setmacro("gtitranslationfiledesc", "gti", "_gti:textgti" + translation_file_key + "_");
+  disp.setmacro("gtitranslationfiledescHtmlsafe", "gti", "_gti:textgti" + encodeForHTML(translation_file_key) + "_");
 
   if (query_string == "") {
@@ -457,4 +458,5 @@
   disp.setmacro("gtitargetlanguagename", "gti", loaded_languages[target_language_code].longname);
   disp.setmacro("gtitranslationfiledesc", "gti", "_gti:textgti" + translation_file_key + "_");
+  disp.setmacro("gtitranslationfiledescHtmlsafe", "gti", "_gti:textgti" + encodeForHTML(translation_file_key) + "_");
 }
 
@@ -496,6 +498,8 @@
     disp.setmacro("gtitargetfilepath", "gti", gti_response.translation_files_key_to_target_file_path_mapping[translation_file_key]);
   }
-  disp.setmacro("gtitranslationfiledesc", "gti", "_gti:textgti" + encodeForHTML(translation_file_key) + "_");
-  disp.setmacro("gtiviewtranslationfileinaction", "gti", "_gti:gtiview" + encodeForHTML(translation_file_key) + "inaction_");
+  disp.setmacro("gtitranslationfiledesc", "gti", "_gti:textgti" + translation_file_key + "_");
+  disp.setmacro("gtitranslationfiledescHtmlsafe", "gti", "_gti:textgti" + encodeForHTML(translation_file_key) + "_");
+  disp.setmacro("gtiviewtranslationfileinaction", "gti", "_gti:gtiview" + translation_file_key + "inaction_");
+  disp.setmacro("gtiviewtranslationfileinactionHtmlsafe", "gti", "_gti:gtiview" + encodeForHTML(translation_file_key) + "inaction_");
 
   disp.setmacro("gtinumchunkstranslated", "gti", gti_response.translation_files_key_to_num_chunks_translated_mapping[translation_file_key]);
@@ -660,5 +664,6 @@
  do_gti_request(gti_arguments, logout); 
 
- disp.setmacro("gtiglihelpzipfilepath", "gti", encodeForURL(target_language_code) + "_GLIHelp.zip");
+ disp.setmacro("gtiglihelpzipfilepath", "gti", target_language_code + "_GLIHelp.zip");
+ disp.setmacro("gtiglihelpzipfilepathUrlsafe", "gti", encodeForURL(target_language_code) + "_GLIHelp.zip");
 
  return true;
Index: main/trunk/greenstone2/runtime-src/src/recpt/pagedbrowserclass.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/pagedbrowserclass.cpp	(revision 28912)
+++ main/trunk/greenstone2/runtime-src/src/recpt/pagedbrowserclass.cpp	(revision 28913)
@@ -32,4 +32,5 @@
 #include "OIDtools.h"
 #include "gsdltools.h"
+#include "securitytools.h"
 
 pagedbrowserclass::pagedbrowserclass () {
Index: main/trunk/greenstone2/runtime-src/src/recpt/rssaction.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/rssaction.cpp	(revision 28912)
+++ main/trunk/greenstone2/runtime-src/src/recpt/rssaction.cpp	(revision 28913)
@@ -131,5 +131,5 @@
       text_t default_domain = "http://localhost:8282";
       disp.setmacro("httpdomain", "Global", default_domain); // the default used in zextra.dm. (Could perhaps default this to localhost too)
-      disp.setmacro("httpdomain", "Global", encodeForHTML(default_domain));
+      disp.setmacro("httpdomainHtmlsafe", "Global", encodeForHTML(default_domain));
     }
   }
Index: main/trunk/greenstone2/runtime-src/src/recpt/usersaction.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/usersaction.cpp	(revision 28912)
+++ main/trunk/greenstone2/runtime-src/src/recpt/usersaction.cpp	(revision 28913)
@@ -268,4 +268,11 @@
   disp.setmacro ("usersargug", "users", args["umug"]);
   disp.setmacro ("usersargc", "users", args["umc"]);
+
+  disp.setmacro ("usersargunAttrsafe", "users", encodeForHTMLAttr(args["umun"]));
+  disp.setmacro ("usersargpwAttrsafe", "users", encodeForHTMLAttr(args["umpw"]));
+  disp.setmacro ("usersargusAttrsafe", "users", encodeForHTMLAttr(args["umus"])); // unused in users.dm or other macro files, but setting this attrsafe'd macro in parallel with the other usersarg* values here.
+  disp.setmacro ("usersargugAttrsafe", "users", encodeForHTMLAttr(args["umug"]));
+  disp.setmacro ("usersargcAttrsafe", "users", encodeForHTMLAttr(args["umc"]));
+
 }
 
