r100637 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100636‎ | r100637 | r100638 >
Date:19:18, 24 October 2011
Author:awjrichards
Status:ok
Tags:fundraising 
Comment:
Cleaned up new rapid html form whitelist checking in set_html_file_path(); Changed param name to set_html_file_path() to '' rather than '' like it used to be since form_key is now more accurately descriptive. The param maps to the key in form whitelist (wheras before we were relying on the actual file name)
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_forms/RapidHtml.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_forms/RapidHtml.php
@@ -250,11 +250,11 @@
251251 }
252252
253253 /**
254 - * Validate and set the path to the HTML file
 254+ * Set the path to the HTML file for a requested rapid html form.
255255 *
256 - * @param string $file_name
 256+ * @param string $form_key The array key defining the whitelisted form path to fetch from $wg<gateway>AllowedHtmlForms
257257 */
258 - public function set_html_file_path( $file_name ) {
 258+ public function set_html_file_path( $form_key ) {
259259 //This ONE TIME, this is okay, because we actually want to compare to the default HTML form dir as well.
260260 global $wgDonationInterfaceHtmlFormDir;
261261
@@ -262,14 +262,12 @@
263263 $gatewayFormDir = $g::getGlobal( 'HtmlFormDir' );
264264 $allowedForms = $g::getGlobal( 'AllowedHtmlForms' );
265265
266 - if ( !array_key_exists( $file_name, $allowedForms ) ||
267 - ((strpos( $allowedForms[$file_name], $gatewayFormDir ) === false) && (strpos( $allowedForms[$file_name], $wgDonationInterfaceHtmlFormDir ) === false)) ||
268 - (!file_exists( $allowedForms[$file_name] )) ) {
269 -
 266+ // Make sure that the requested form is whitelisted
 267+ if ( !array_key_exists( $form_key, $allowedForms ) || ( !file_exists( $allowedForms[$form_key] )) ) {
270268 throw new MWException( 'Requested an unavailable or non-existent form.' );
271269 }
272270
273 - $this->html_file_path = $allowedForms[$file_name];
 271+ $this->html_file_path = $allowedForms[ $form_key ];
274272 }
275273
276274 /**

Status & tagging log