r16945 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r16944‎ | r16945 | r16946 >
Date:19:00, 11 October 2006
Author:brion
Status:old
Tags:
Comment:
* Disable PHP exception backtrace printing unless $wgShowExceptionDetails
is set. Backtraces may contain sensitive information in function call
parameters.
Modified paths:
  • /branches/REL1_8/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_8/phase3/includes/DefaultSettings.php (modified) (history)
  • /branches/REL1_8/phase3/includes/Exception.php (modified) (history)

Diff [purge]

Index: branches/REL1_8/phase3/includes/DefaultSettings.php
@@ -790,6 +790,14 @@
791791 $wgColorErrors = true;
792792
793793 /**
 794+ * If set to true, uncaught exceptions will print a complete stack trace
 795+ * to output. This should only be used for debugging, as it may reveal
 796+ * private information in function parameters due to PHP's backtrace
 797+ * formatting.
 798+ */
 799+$wgShowExceptionDetails = false;
 800+
 801+/**
794802 * disable experimental dmoz-like category browsing. Output things like:
795803 * Encyclopedia > Music > Style of Music > Jazz
796804 */
Index: branches/REL1_8/phase3/includes/Exception.php
@@ -20,16 +20,28 @@
2121 return wfMsgReplaceArgs( $fallback, $args );
2222 }
2323 }
24 -
 24+
2525 function getHTML() {
26 - return '<p>' . htmlspecialchars( $this->getMessage() ) .
27 - '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
28 - "</p>\n";
 26+ global $wgShowExceptionDetails;
 27+ if( $wgShowExceptionDetails ) {
 28+ return '<p>' . htmlspecialchars( $this->getMessage() ) .
 29+ '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
 30+ "</p>\n";
 31+ } else {
 32+ return "<p>Set <b><tt>\$wgShowExceptionDetails = true;</tt></b> " .
 33+ "in LocalSettings.php to show detailed debugging information.</p>";
 34+ }
2935 }
3036
3137 function getText() {
32 - return $this->getMessage() .
33 - "\nBacktrace:\n" . $this->getTraceAsString() . "\n";
 38+ global $wgShowExceptionDetails;
 39+ if( $wgShowExceptionDetails ) {
 40+ return $this->getMessage() .
 41+ "\nBacktrace:\n" . $this->getTraceAsString() . "\n";
 42+ } else {
 43+ return "<p>Set <tt>\$wgShowExceptionDetails = true;</tt> " .
 44+ "in LocalSettings.php to show detailed debugging information.</p>";
 45+ }
3446 }
3547
3648 function getPageTitle() {
Index: branches/REL1_8/phase3/RELEASE-NOTES
@@ -9,6 +9,9 @@
1010 * Improved register_globals paranoia checks
1111 * (bug 7545) Fix PHP version check on install
1212 * Experimental web API disabled by default
 13+* Disable PHP exception backtrace printing unless $wgShowExceptionDetails
 14+ is set. Backtraces may contain sensitive information in function call
 15+ parameters.
1316
1417
1518 == MediaWiki 1.8.0 ==