mraible commented on code in PR #325:
URL: https://github.com/apache/roller/pull/325#discussion_r4609096888
##########
app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogFeedCache.java:
##########
@@ -193,6 +193,11 @@ public String generateKey(WeblogFeedRequest feedRequest) {
key.append("/excerpts");
}
+ // add page number when past the first page
+ if(feedRequest.getPage() > 0) {
Review Comment:
Both feed caches now URL-encode the search term and each tag name, so a "/"
in them can't be mistaken for the page suffix or another key part.
WeblogFeedCacheKeyTest adds cases such as the term "foo/page=2" against page 2
of "foo", and the tag "java/page=2" against page 2 of "java".
##########
app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.java:
##########
@@ -155,8 +158,27 @@ protected boolean isLocale(String potentialLocale) {
return isLocale;
}
-
-
+
+
+ /**
+ * Parse a page number request parameter. Pagers multiply the page number
+ * by the page length to get an offset, so the result is kept between 0
+ * and MAX_PAGE_NUM; missing or unparsable values mean the first page.
+ */
+ protected static int parsePageNum(String pageParam) {
Review Comment:
WeblogSearchRequest now reads the page with parsePageNum, so a negative
value becomes page 0 and can't produce a negative offset. PageParameterTest
covers negative and huge values on the search path.
##########
app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.java:
##########
@@ -155,8 +158,27 @@ protected boolean isLocale(String potentialLocale) {
return isLocale;
}
-
-
+
+
+ /**
+ * Parse a page number request parameter. Pagers multiply the page number
+ * by the page length to get an offset, so the result is kept between 0
+ * and MAX_PAGE_NUM; missing or unparsable values mean the first page.
+ */
+ protected static int parsePageNum(String pageParam) {
+ if (pageParam == null) {
+ return 0;
+ }
+ try {
+ int pageNum = Integer.parseInt(pageParam);
+ return Math.max(0, Math.min(pageNum, MAX_PAGE_NUM));
Review Comment:
TagDataServlet now returns 400 for page numbers below 0 or above 10000,
before the value is multiplied by MAX, as it already did for non-numeric pages.
TagDataServletPageTest checks -1, 10001 and Integer.MAX_VALUE are rejected and
0 and 10000 are accepted.
##########
app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.java:
##########
@@ -155,8 +158,27 @@ protected boolean isLocale(String potentialLocale) {
return isLocale;
}
-
-
+
+
+ /**
+ * Parse a page number request parameter. Pagers multiply the page number
+ * by the page length to get an offset, so the result is kept between 0
+ * and MAX_PAGE_NUM; missing or unparsable values mean the first page.
+ */
+ protected static int parsePageNum(String pageParam) {
+ if (pageParam == null) {
+ return 0;
+ }
+ try {
+ int pageNum = Integer.parseInt(pageParam);
+ return Math.max(0, Math.min(pageNum, MAX_PAGE_NUM));
Review Comment:
The pagers (AbstractPager, AbstractWeblogEntriesPager, the day and month
pagers, the users and weblogs letter links and SearchResultsPager), the feed
history next link and the tag data XML next link no longer offer Next on page
10000. PagerNextLinkLimitTest checks that 9999 links to 10000 and 10000 has no
Next link, and #313 has the same change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]