This is an automated email from the ASF dual-hosted git repository.

lprimak pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shiro.git


The following commit(s) were added to refs/heads/main by this push:
     new 650258198 Jakarta ee update (#2474)
650258198 is described below

commit 650258198489fae90a1dae86ffc0c3bfb851b597
Author: Lenny Primak <[email protected]>
AuthorDate: Fri Jan 23 22:49:57 2026 -0600

    Jakarta ee update (#2474)
    
    * wip
    
    * fixed Jakarta EE ITs
---
 .../jakarta-ee/src/main/webapp/WEB-INF/web.xml      |  4 ++++
 .../jakarta-ee/src/test/resources/arquillian.xml    |  2 ++
 .../shiro/ee/filters/FormResubmitSupport.java       | 21 +++++++++++++++++----
 .../apache/shiro/ee/filters/FormSupportTest.java    |  3 +--
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/integration-tests/jakarta-ee/src/main/webapp/WEB-INF/web.xml 
b/integration-tests/jakarta-ee/src/main/webapp/WEB-INF/web.xml
index 0e1c1ab45..6f4c37b00 100644
--- a/integration-tests/jakarta-ee/src/main/webapp/WEB-INF/web.xml
+++ b/integration-tests/jakarta-ee/src/main/webapp/WEB-INF/web.xml
@@ -66,6 +66,10 @@
         <param-name>org.apache.shiro.ee.disabled</param-name>
         <param-value>false</param-value>
     </context-param>
+    <context-param>
+        <param-name>org.apache.shiro.form-resubmit.secure-cookies</param-name>
+        <param-value>false</param-value>
+    </context-param>
 
     <!-- Apache Shiro Security -->
     <context-param>
diff --git a/integration-tests/jakarta-ee/src/test/resources/arquillian.xml 
b/integration-tests/jakarta-ee/src/test/resources/arquillian.xml
index 6604ce3c4..36a212dbf 100644
--- a/integration-tests/jakarta-ee/src/test/resources/arquillian.xml
+++ b/integration-tests/jakarta-ee/src/test/resources/arquillian.xml
@@ -22,6 +22,8 @@
         <property name="firefoxArguments">-headless</property>
         <property name="chromeBinary">${webdriver.chrome.binary}</property>
         <property name="chromeArguments">--ignore-certificate-errors</property>
+        <property name="enableBidi">true</property>
+        <property name="unhandledPromptBehaviour">ignore</property>
         <property name="githubUsername">${gh_user}</property>
         <property name="githubToken">${gh_token}</property>
     </extension>
diff --git 
a/support/jakarta-ee/src/main/java/org/apache/shiro/ee/filters/FormResubmitSupport.java
 
b/support/jakarta-ee/src/main/java/org/apache/shiro/ee/filters/FormResubmitSupport.java
index 27808182b..3835e13b6 100644
--- 
a/support/jakarta-ee/src/main/java/org/apache/shiro/ee/filters/FormResubmitSupport.java
+++ 
b/support/jakarta-ee/src/main/java/org/apache/shiro/ee/filters/FormResubmitSupport.java
@@ -95,9 +95,13 @@ public class FormResubmitSupport {
     private static final String FACES_VIEW_STATE_EQUALS = FACES_VIEW_STATE + 
"=";
     private static final Pattern VIEW_STATE_PATTERN
             = 
Pattern.compile(String.format("(.*)(%s[-]?[\\d]+:[-]?[\\d]+)(.*)", 
FACES_VIEW_STATE_EQUALS));
-    private static final String PARTIAL_VIEW = 
jakartify("javax.faces.partial");
+    private static final String FACES_SOURCE = jakartify("javax.faces.source");
+    private static final String FACES_SOURCE_EQUALS = FACES_SOURCE + "=";
+    static final Pattern FACES_SOURCE_PATTERN
+            = Pattern.compile(String.format("[\\&]?%s([\\w\\s:%%\\d]*)(.*)", 
FACES_SOURCE_EQUALS));
     private static final Pattern PARTIAL_REQUEST_PATTERN
-            = Pattern.compile(String.format("[\\&]?%s.\\w+=[\\w\\s:%%\\d]*", 
PARTIAL_VIEW));
+            = 
Pattern.compile(String.format("[\\&]?(%s.\\w+|%s.\\w+|%s)=[\\w\\s:%%\\d]*",
+            jakartify("javax.faces.partial"), 
jakartify("javax.faces.behavior"), FACES_SOURCE));
     private static final Pattern INITIAL_AMPERSAND = Pattern.compile("^\\&");
     private static final String FORM_DATA_CACHE = 
"org.apache.shiro.form-data-cache";
     private static final String FORM_RESUBMIT_HOST = 
"org.apache.shiro.form-resubmit-host";
@@ -573,8 +577,17 @@ public class FormResubmitSupport {
     static PartialAjaxResult noJSFAjaxRequests(String savedFormData, boolean 
isStateless) {
         var partialMatcher = PARTIAL_REQUEST_PATTERN.matcher(savedFormData);
         boolean hasPartialAjax = partialMatcher.find();
-        return new PartialAjaxResult(isStateless ? savedFormData : 
INITIAL_AMPERSAND.matcher(partialMatcher
-                .replaceAll("")).replaceFirst(""), hasPartialAjax, 
isStateless);
+        String appendFacesSourceString = "";
+        if (hasPartialAjax) {
+            var facesSourceMatcher = 
FACES_SOURCE_PATTERN.matcher(savedFormData);
+            if (facesSourceMatcher.find()) {
+                appendFacesSourceString = String.format("&%s=", 
facesSourceMatcher.group(1));
+            }
+        }
+
+        return new PartialAjaxResult((isStateless ? savedFormData : 
INITIAL_AMPERSAND.matcher(partialMatcher
+                .replaceAll("")).replaceFirst(""))
+                + appendFacesSourceString, hasPartialAjax, isStateless);
     }
 
     static boolean isJSFStatefulForm(@NonNull String savedFormData) {
diff --git 
a/support/jakarta-ee/src/test/java/org/apache/shiro/ee/filters/FormSupportTest.java
 
b/support/jakarta-ee/src/test/java/org/apache/shiro/ee/filters/FormSupportTest.java
index 874eeed83..f1535753d 100644
--- 
a/support/jakarta-ee/src/test/java/org/apache/shiro/ee/filters/FormSupportTest.java
+++ 
b/support/jakarta-ee/src/test/java/org/apache/shiro/ee/filters/FormSupportTest.java
@@ -138,8 +138,7 @@ public class FormSupportTest {
                         + 
jakartify("&javax.faces.partial.ajax=true&hello=bye"), false));
         assertEquals(new 
PartialAjaxResult("j_idt12=j_idt12&j_idt12:j_idt14=asdf&j_idt12:j_idt16=asdf"
                         + 
jakartify("&javax.faces.ViewState=7709788254588873136:-8052771455757429917")
-                        + jakartify("&javax.faces.source=j_idt12:j_idt18")
-                        + jakartify("&javax.faces.behavior.event=action"), 
true, false),
+                        + "&j_idt12:j_idt18=", true, false),
                 
noJSFAjaxRequests("j_idt12=j_idt12&j_idt12:j_idt14=asdf&j_idt12:j_idt16=asdf"
                         + 
jakartify("&javax.faces.ViewState=7709788254588873136:-8052771455757429917")
                         + jakartify("&javax.faces.source=j_idt12:j_idt18")

Reply via email to