kohabug 2026 - HTML-escape comments
authorGalen Charlton <galen.charlton@liblime.com>
Wed, 30 Apr 2008 22:09:14 +0000 (17:09 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Thu, 1 May 2008 02:59:01 +0000 (21:59 -0500)
This is a partial, perhaps temporary fix.  "<", ">",
and "&" characters in patron comments (AKA reviews)
are converted to "&lt;", "&gt;", and "&amp;" to avoid
certain attacks, e.g., a user entering a <script> tag
in a comment.

A more permanent fix should scrub all (or perhaps just
unsafe) tags from submitted comments entirely.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
koha-tmpl/intranet-tmpl/prog/en/modules/reviews/reviewswaiting.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-review.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-showreviews.tmpl

index 0350135..8fbcd88 100644 (file)
@@ -58,7 +58,7 @@ $.tablesorter.addParser({
             <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="bibliotitle" --></a>
         </td>
         <td>
-            <!-- TMPL_VAR NAME="review" -->
+            <!-- TMPL_VAR NAME="review" ESCAPE="HTML" -->
         </td>
         <td>
             <a href="/cgi-bin/koha/reviews/reviewswaiting.pl?op=approve&amp;reviewid=<!-- TMPL_VAR NAME="reviewid" -->">Approve</a> |
index 1e36185..f892b4a 100644 (file)
                 <!--TMPL_VAR NAME="datereviewed"-->
             </small>
         <p>
-          <!--TMPL_VAR NAME="review"-->
+          <!--TMPL_VAR NAME="review" ESCAPE="HTML"-->
         </p>
         <!--/TMPL_LOOP-->
     <!-- TMPL_ELSE  -->
 </div>
        <!-- TMPL_IF NAME="OpacNav" --><div class="yui-b"><!--TMPL_INCLUDE NAME="navigation.inc" --></div><!-- /TMPL_IF -->
 </div>
-<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
\ No newline at end of file
+<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
index e3e0ed5..6afef41 100755 (executable)
                        </h5>
                        <small><!-- TMPL_VAR NAME="datereviewed" --></small>
         <p>
-          <!-- TMPL_VAR NAME="review" -->
+          <!-- TMPL_VAR NAME="review" ESCAPE="HTML" -->
                  <a href="#" onclick="Dopop('/cgi-bin/koha/opac-review.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber"-->&amp;reviewid=<!-- TMPL_VAR NAME="reviewid" -->');">Edit</a>
         </p></div>
                        <!-- TMPL_ELSE -->
             </h5>
                        <small><!-- TMPL_VAR NAME="datereviewed" --></small>
         <p>
-          <!-- TMPL_VAR NAME="review" -->
+          <!-- TMPL_VAR NAME="review" ESCAPE="HTML" -->
         </p></div>
                        <!-- /TMPL_IF -->
         <!-- /TMPL_LOOP -->
index 146d60b..4528d71 100644 (file)
                $('#reviewf').submit( function() {
                        <!-- TMPL_IF NAME="reviewid" -->
                        parent.opener.$('#c<!-- TMPL_VAR NAME="reviewid" --> p').prev("small").prev("h5").html("Your Edited Comment (preview, pending approval)");
-                       parent.opener.$('#c<!-- TMPL_VAR NAME="reviewid" --> p').html($("#review").val());
+                       parent.opener.$('#c<!-- TMPL_VAR NAME="reviewid" --> p').html($("#review").val().replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'));
                        parent.opener.$('#c<!-- TMPL_VAR NAME="reviewid" --> p').append(" <a href=\"#comment\" onclick=\"Dopop(\'/cgi-bin/koha/opac-review.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber"-->&amp;reviewid=<!-- TMPL_VAR NAME="reviewid" -->\');\">Edit</a>");
                        window.close();
                        <!-- TMPL_ELSE -->
                        parent.opener.$('#newcomment').attr("class","yours");
                        parent.opener.$('#newcomment').html("<h5>Your Comment (preview, pending approval)</h5>");
-                       parent.opener.$('#newcomment').append("<p>"+$("#review").val());
+                       parent.opener.$('#newcomment').append("<p>"+$("#review").val().replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'));
                        parent.opener.$('#newcomment p').append(" <a href=\"#comment\" onclick=\"Dopop(\'/cgi-bin/koha/opac-review.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber"-->&amp;reviewid=<!-- TMPL_VAR NAME="reviewid" -->\');\">Edit</a></p>");
                        parent.opener.$("#addcomment").prev("p").remove();
                        parent.opener.$("#addcomment").remove();
index 7e44348..4d3bf18 100644 (file)
@@ -19,7 +19,7 @@
     </tr>
     <tr>
         <td>
-            <!--TMPL_VAR NAME="review"-->
+            <!--TMPL_VAR NAME="review" ESCAPE="HTML"-->
             <p><!--TMPL_VAR NAME="datereviewed"--></p>
         </td>
     </tr>