Skip to content

Commit

Permalink
Improved: Normalize contextPath in hasBasePermission (OFBIZ-12887)
Browse files Browse the repository at this point in the history
Better have a normalized contextPath in LoginWorker::hasBasePermission
  • Loading branch information
JacquesLeRoux committed Feb 4, 2024
1 parent c81a7ad commit 0d9ac6e
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import static org.apache.ofbiz.base.util.UtilGenerics.checkMap;

import java.math.BigInteger;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.cert.X509Certificate;
import java.sql.Timestamp;
import java.util.ArrayList;
Expand Down Expand Up @@ -1372,6 +1374,13 @@ public static boolean hasBasePermission(GenericValue userLogin, HttpServletReque
if (UtilValidate.isEmpty(contextPath)) {
contextPath = "/";
}

try {
contextPath = new URI(contextPath).normalize().toString();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}

ComponentConfig.WebappInfo info = ComponentConfig.getWebAppInfo(serverId, contextPath);
if (info != null) {
return hasApplicationPermission(info, security, userLogin);
Expand Down

0 comments on commit 0d9ac6e

Please sign in to comment.