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


##########
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:
   **Blocking:** Both feed caches append the new `/page=N` suffix after tag 
names and search terms that can contain `/`. Different tag or search values and 
page numbers can therefore produce the same key. Encode those components or use 
an unambiguous key format in both caches, and add collision tests.



##########
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:
   **Important:** `TagDataServlet` also parses `page` directly, then multiplies 
it by `MAX` for the query offset. Reject or bound negative and oversized values 
before that multiplication, and test the tag-data endpoint at those limits.



##########
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:
   **Important:** `WeblogSearchRequest` still parses `page` directly. A 
negative value reaches `LuceneIndexManager.convertHitsToEntryList()` and 
produces a negative list offset. Route search requests through `parsePageNum()` 
and cover the search path with a negative-page test.



##########
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:
   **Important:** At `MAX_PAGE_NUM`, pagers can still emit a Next link when 
more entries exist. That link requests the next number, which this parser 
clamps back to the current page. Suppress Next at the limit and add a boundary 
test.



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