Tpt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/235455
Change subject: Improves the range checking of <page> tag
......................................................................
Improves the range checking of <page> tag
More readable code
Bug: T111035
Change-Id: I84d746b74635e3aea85da33a268cec3c6342d64c
---
M includes/Parser/PagesTagParser.php
M tests/parser/proofreadpage_pages.txt
2 files changed, 24 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage
refs/changes/55/235455/1
diff --git a/includes/Parser/PagesTagParser.php
b/includes/Parser/PagesTagParser.php
index 1f5fd18..4fe4620 100644
--- a/includes/Parser/PagesTagParser.php
+++ b/includes/Parser/PagesTagParser.php
@@ -109,7 +109,7 @@
return $this->formatError(
'proofreadpage_number_expected' );
}
- if( ($from > $to) || ($from < 1) ||
($to < 1 ) || ($to > $count) ) {
+ if( !( 1 <= $from && $from <= $to &&
$to <= $count ) ) {
return $this->formatError(
'proofreadpage_invalid_interval' );
}
@@ -132,7 +132,7 @@
}
ksort( $pagenums ); //we must sort the array
even if the numerical keys are in a good order.
- if( reset( $pagenums ) > $count ) {
+ if( end( $pagenums ) > $count ) {
return $this->formatError(
'proofreadpage_invalid_interval' );
}
diff --git a/tests/parser/proofreadpage_pages.txt
b/tests/parser/proofreadpage_pages.txt
index 2c2fcd8..0640e3e 100644
--- a/tests/parser/proofreadpage_pages.txt
+++ b/tests/parser/proofreadpage_pages.txt
@@ -262,6 +262,28 @@
!! end
!! test
+pages: with file: Invalid range
+!! options
+djvu
+!! wikitext
+<pages index="LoremIpsum.djvu" from="4" to="3" />
+!! html
+<p><strong class="error">Error: Invalid interval</strong>
+</p>
+!! end
+
+!! test
+pages: with file: Invalid include
+!! options
+djvu
+!! wikitext
+<pages index="LoremIpsum.djvu" include="42" />
+!! html
+<p><strong class="error">Error: Invalid interval</strong>
+</p>
+!! end
+
+!! test
pages: with file: Simple transclusion without to
!! options
djvu
--
To view, visit https://gerrit.wikimedia.org/r/235455
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I84d746b74635e3aea85da33a268cec3c6342d64c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Tpt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits