kohabug 2026 - HTML-escape comments

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>
This commit is contained in:
Galen Charlton 2008-04-30 17:09:14 -05:00 committed by Joshua Ferraro
parent 438ed23337
commit 60983cfeee
5 changed files with 8 additions and 8 deletions

View 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> |

View File

@ -129,7 +129,7 @@
<!--TMPL_VAR NAME="datereviewed"-->
</small>
<p>
<!--TMPL_VAR NAME="review"-->
<!--TMPL_VAR NAME="review" ESCAPE="HTML"-->
</p>
<!--/TMPL_LOOP-->
<!-- TMPL_ELSE -->
@ -185,4 +185,4 @@
</div>
<!-- TMPL_IF NAME="OpacNav" --><div class="yui-b"><!--TMPL_INCLUDE NAME="navigation.inc" --></div><!-- /TMPL_IF -->
</div>
<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->

View File

@ -419,7 +419,7 @@
</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 -->
@ -432,7 +432,7 @@
</h5>
<small><!-- TMPL_VAR NAME="datereviewed" --></small>
<p>
<!-- TMPL_VAR NAME="review" -->
<!-- TMPL_VAR NAME="review" ESCAPE="HTML" -->
</p></div>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->

View File

@ -24,13 +24,13 @@
$('#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();

View 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>