From b4394756f7564ba9b69d21f66cffcf6d70db9bf5 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Tue, 5 Jan 2021 16:48:35 +0100 Subject: Change how redirects are done (any extra string is allowed, and redirect if it doesn't match as expected). --- org/madore/damlengine/WeblogServlet.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'org/madore/damlengine') diff --git a/org/madore/damlengine/WeblogServlet.java b/org/madore/damlengine/WeblogServlet.java index 0f7341c..86f231a 100644 --- a/org/madore/damlengine/WeblogServlet.java +++ b/org/madore/damlengine/WeblogServlet.java @@ -89,8 +89,10 @@ public class WeblogServlet extends HttpServlet { String specialName = selRes.getString(3); if ( id != number ) throw new ServletException("this cannot happen"); - if ( extra != null && ! extra.equals(specialName) ) - return new NoSuchPath(); + if ( ! ( ( extra == null && specialName == null ) + || ( extra != null && specialName != null + && extra.equals(specialName) ) ) ) + return new SingleBlogEntryRedirectPath(date, id, specialName); long lastModified = (long)(mdate*1000); long thisLastModified; try { @@ -108,6 +110,7 @@ public class WeblogServlet extends HttpServlet { throw new ServletException(e); } } + // Legacy support for an old permalink format: if ( inGet && (matcher=Pattern.compile("/d\\.(\\d{4}-\\d{2}-\\d{2})\\.([\\p{Alpha}][\\p{Alnum}\\-]*)\\.html").matcher(pathInfo)).matches() ) { final String date; final String extra; @@ -151,7 +154,7 @@ public class WeblogServlet extends HttpServlet { static final class SingleBlogEntryRedirectPath extends RequestPath { public String date; public int number; - public String extra; + public String extra; // May be null (passed to WeblogLink class) public SingleBlogEntryRedirectPath(String date, int number, String extra) { this.date = date; this.number = number; -- cgit v1.2.3