mraible commented on code in PR #313:
URL: https://github.com/apache/roller/pull/313#discussion_r4609096449


##########
app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogFeedCache.java:
##########
@@ -194,6 +194,11 @@ public String generateKey(WeblogFeedRequest feedRequest) {
             key.append("/excerpts");
         }
         
+        // add page number when past the first page
+        if(feedRequest.getPage() > 0) {
+            key.append("/page=").append(feedRequest.getPage());

Review Comment:
   Both feed caches now URL-encode the search term and each tag name, like the 
category already was, so a "/" in them can't look like the page number or 
another key part. WeblogFeedCacheKeyTest checks that terms such as 
"foo/page=2", "java/page=3", "foo/excerpts" and "foo/tags/x", and tags such as 
"java/page=2" and "a+b", get keys of their own.



##########
app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.java:
##########
@@ -156,8 +159,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:
   WeblogSearchRequest now uses parsePageNum, so search pages stay between 0 
and 10000, and TagDataServlet returns 400 for page numbers below 0 or above 
10000. PageParameterTest covers negative and huge search pages, and the new 
TagDataServletPageTest covers -1, 10001 and Integer.MAX_VALUE against 0 and 
10000.



-- 
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]

Reply via email to