From: Brad Jorsch Date: Wed, 11 Sep 2013 17:54:22 +0000 (-0700) Subject: API: Check for nosuchsection in all code paths X-Git-Tag: 1.31.0-rc.0~18690^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=ff8d5988d234399571917fd61fd583fb1469efd7;p=lhc%2Fweb%2Fwiklou.git API: Check for nosuchsection in all code paths nosuchsection is currently checked only in the appendtext/prependtext code path. Add a check for out of range section numbers in the main code path too. Bug: 53884 Change-Id: I5bafe8625122ca66415602c37cbca7d7f4c17742 --- diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index e503e30195..a2a53e0ede 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -347,6 +347,8 @@ production. * (bug 49090) Token-getting functions will fail when using jsonp callbacks. * (bug 52699) action=upload returns normalized file name on warning "exists-normalized" instead of filename to be uploaded to. +* (bug 53884) action=edit will now return an error when the specified section + does not exist in the page. === Languages updated in 1.22=== diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index d14219f9e7..bd61895b30 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -280,6 +280,10 @@ class ApiEditPage extends ApiBase { if ( $section == 0 && $params['section'] != '0' && $params['section'] != 'new' ) { $this->dieUsage( "The section parameter must be set to an integer or 'new'", "invalidsection" ); } + $content = $pageObj->getContent(); + if ( $section !== 0 && ( !$content || !$content->getSection( $section ) ) ) { + $this->dieUsage( "There is no section {$section}.", 'nosuchsection' ); + } $requestArray['wpSection'] = $params['section']; } else { $requestArray['wpSection'] = '';