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


##########
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:
   **Important:** The search term is appended without escaping, so the new 
`/page=N` suffix can make distinct feed requests share a key. Encode or 
length-prefix free-form key components in both feed caches, and add a test that 
checks the keys stay distinct.



##########
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:
   **Important:** `WeblogSearchRequest` still parses `page` directly; negative 
values can reach Lucene's offset calculation and produce an invalid sublist 
index. `TagDataServlet` also multiplies an unbounded page value by its page 
size. Apply bounded parsing to both paths and add regression cases.



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