r16944 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r16943‎ | r16944 | r16945 >
Date:18:57, 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:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Exception.php (modified) (history)

Diff [purge]

Index: trunk/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: trunk/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: trunk/phase3/RELEASE-NOTES
@@ -33,6 +33,9 @@
3434 * Fix PHP notice and estimates for dumpBackup.php and friends
3535 * Improved register_globals paranoia checks
3636 * (bug 7545) Fix PHP version check on install
 37+* Disable PHP exception backtrace printing unless $wgShowExceptionDetails
 38+ is set. Backtraces may contain sensitive information in function call
 39+ parameters.
3740
3841
3942 == Languages updated ==