diff --git a/build.savant b/build.savant index 91ec02b7..08701a10 100644 --- a/build.savant +++ b/build.savant @@ -29,7 +29,7 @@ logbackVersion = "1.5.13" slf4jVersion = "2.0.13" testngVersion = "7.8.0" -project(group: "org.primeframework", name: "prime-mvc", version: "5.3.0", licenses: ["ApacheV2_0"]) { +project(group: "org.primeframework", name: "prime-mvc", version: "5.3.1", licenses: ["ApacheV2_0"]) { workflow { fetch { // Dependency resolution order: diff --git a/pom.xml b/pom.xml index 6f9c9a6e..e34fb1e4 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.primeframework prime-mvc - 5.3.0 + 5.3.1 jar FusionAuth App diff --git a/src/test/java/org/example/action/meta/RefreshAction.java b/src/test/java/org/example/action/meta/RefreshAction.java new file mode 100644 index 00000000..38b4e771 --- /dev/null +++ b/src/test/java/org/example/action/meta/RefreshAction.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025, Inversoft Inc., All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + */ +package org.example.action.meta; + +import org.primeframework.mvc.ErrorException; +import org.primeframework.mvc.action.annotation.Action; +import org.primeframework.mvc.action.result.annotation.Forward; + +/** + * @author Daniel DeGroff + */ +@Action +@Forward.List({ + @Forward(code = "input-lc", page = "/meta/refresh-lc.ftl"), + @Forward(code = "input-uc", page = "/meta/refresh-uc.ftl") +}) +public class RefreshAction { + public String test = "lc"; + + public String get() { + if (test == null || !(test.equals("lc") || test.equals("uc"))) { + throw new ErrorException("error"); + } + + return "input-" + test; + } +} diff --git a/src/test/java/org/example/action/meta/TargetAction.java b/src/test/java/org/example/action/meta/TargetAction.java new file mode 100644 index 00000000..98e85c4e --- /dev/null +++ b/src/test/java/org/example/action/meta/TargetAction.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025, Inversoft Inc., All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + */ +package org.example.action.meta; + +import org.primeframework.mvc.action.annotation.Action; + +/** + * @author Daniel DeGroff + */ +@Action +public class TargetAction { + public String get() { + return "input"; + } +} diff --git a/src/test/java/org/primeframework/mvc/GlobalTest.java b/src/test/java/org/primeframework/mvc/GlobalTest.java index 1034376b..39339911 100644 --- a/src/test/java/org/primeframework/mvc/GlobalTest.java +++ b/src/test/java/org/primeframework/mvc/GlobalTest.java @@ -213,6 +213,30 @@ public void flash_scope_compatibility() throws Exception { ; } + @Test + public void follow_meta_refresh() throws Exception { + // use upper case Refresh and URL, and lower case refresh and url + test.forEach("lc", "uc") + .test(param -> test + .simulate(() -> simulator + .test("/meta/refresh") + .withURLParameter("test", param) + .get() + .assertStatusCode(200) + .assertBodyContains(""" + + """ + .replace("{refresh}", param.equals("uc") ? "Refresh" : "refresh") + .replace("{url}", param.equals("uc") ? "URL" : "url")) + + .followMetaRefresh(result -> result + .assertStatusCode(200) + .assertBody(""" + We made it! + """))) + ); + } + @Test public void get() throws Exception { // Not called yet diff --git a/src/test/java/org/primeframework/mvc/test/RequestResult.java b/src/test/java/org/primeframework/mvc/test/RequestResult.java index bed8f49b..b372f581 100644 --- a/src/test/java/org/primeframework/mvc/test/RequestResult.java +++ b/src/test/java/org/primeframework/mvc/test/RequestResult.java @@ -1892,13 +1892,14 @@ private RequestResult handleFollowMetaRefresh(ThrowingConsumer re if (element.hasAttr("http-equiv")) { String value = element.attr("http-equiv"); // Never null - if (value.equals("refresh")) { + if (value.equalsIgnoreCase("refresh")) { String content = element.attr("content"); // Handle this String[] parts = content.split(";"); for (String part : parts) { - if (part.startsWith("URL=")) { - String uri = part.substring(4); + String trimmedPart = part.trim(); + if (trimmedPart.toLowerCase(Locale.ROOT).startsWith("url=")) { + String uri = trimmedPart.substring(4); if (uri.startsWith("'")) { uri = uri.substring(1, uri.length() - 1); } diff --git a/src/test/web/templates/meta/refresh-lc.ftl b/src/test/web/templates/meta/refresh-lc.ftl new file mode 100644 index 00000000..8d0258f8 --- /dev/null +++ b/src/test/web/templates/meta/refresh-lc.ftl @@ -0,0 +1,8 @@ + +[#-- Note that refresh and URL are intentionally lowercase--] + + + Refresh please + + + diff --git a/src/test/web/templates/meta/refresh-uc.ftl b/src/test/web/templates/meta/refresh-uc.ftl new file mode 100644 index 00000000..8921b105 --- /dev/null +++ b/src/test/web/templates/meta/refresh-uc.ftl @@ -0,0 +1,8 @@ + +[#-- Note that refresh and URL are intentionally lowercase--] + + + Refresh please + + + diff --git a/src/test/web/templates/meta/target.ftl b/src/test/web/templates/meta/target.ftl new file mode 100644 index 00000000..a3a96e33 --- /dev/null +++ b/src/test/web/templates/meta/target.ftl @@ -0,0 +1 @@ +We made it!