r25742 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25741‎ | r25742 | r25743 >
Date:21:01, 10 September 2007
Author:brion
Status:old
Tags:
Comment:
* (bug 11158) Fix escaping in API HTML-formatted JSON
Modified paths:
  • /trunk/extensions/BotQuery/query.php (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiFormatBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiFormatBase.php
@@ -158,8 +158,11 @@
159159 * This method also replaces any '<' with &lt;
160160 */
161161 protected function formatHTML($text) {
162 - // encode all tags as safe blue strings
163 - $text = ereg_replace('\<([^>]+)\>', '<span style="color:blue;">&lt;\1&gt;</span>', $text);
 162+ // Escape everything first for full coverage
 163+ $text = htmlspecialchars($text);
 164+
 165+ // encode all comments or tags as safe blue strings
 166+ $text = preg_replace('/\&lt;(!--.*?--|.*?)\&gt;/', '<span style="color:blue;">&lt;\1&gt;</span>', $text);
164167 // identify URLs
165168 $protos = "http|https|ftp|gopher";
166169 $text = ereg_replace("($protos)://[^ \\'\"()<\n]+", '<a href="\\0">\\0</a>', $text);
Index: trunk/phase3/RELEASE-NOTES
@@ -44,6 +44,7 @@
4545 editinterface to a new permission key editusercssjs.
4646 * (bug 11266) Set fallback language for Fulfulde (ff) to French
4747 * (bug 11179) Include image version deletion comment in public log
 48+* (bug 11158) Fix escaping in API HTML-formatted JSON
4849
4950
5051 === API changes in 1.12 ===
Index: trunk/extensions/BotQuery/query.php
@@ -2607,8 +2607,11 @@
26082608 */
26092609 function htmlPrinter( $text )
26102610 {
2611 - // encode all tags as safe blue strings
2612 - $text = ereg_replace( '\<([^>]+)\>', '<font color=blue>&lt;\1&gt;</font>', $text );
 2611+ // Escape everything first for full coverage
 2612+ $text = htmlspecialchars($text);
 2613+
 2614+ // encode all comments or tags as safe blue strings
 2615+ $text = preg_replace('/\&lt;(!--.*?--|.*?)\&gt;/', '<span style="color:blue;">&lt;\1&gt;</span>', $text);
26132616 // identify URLs
26142617 $text = ereg_replace("[a-zA-Z]+://[^ '()<\n]+", '<a href="\\0">\\0</a>', $text);
26152618 // identify requests to query.php

Follow-up revisions

RevisionCommit summaryAuthorDate
r25754Merged revisions 25607-25751 via svnmerge from...david23:02, 10 September 2007
r25802(API) Partial revert of r25742. Escaping all html special characters in the o...amidaniel22:47, 11 September 2007
r25804Merged revisions 25752-25803 via svnmerge from...david02:25, 12 September 2007

Status & tagging log