From ff8d5988d234399571917fd61fd583fb1469efd7 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 11 Sep 2013 10:54:22 -0700 Subject: [PATCH] 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 --- RELEASE-NOTES-1.22 | 2 ++ includes/api/ApiEditPage.php | 4 ++++ 2 files changed, 6 insertions(+) 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'] = ''; -- 2.20.1