Skip to content

Commit 0effce0

Browse files
committed
Fixed: IndexOutOfBoundsException on Entity Import (OFBIZ-12273)
I get an IndexOutOfBoundsException when using the EntityImport. The problem occurs while having a resemblance of an url in the data. For example screenPath="component://... is interpreted as url because of '://' but doesn't match a valid url pattern. jleroux: I decided to keep it simple and to take the "component://" and the "https://localhost" cases apart. I see no reasons to fear "https://localhost" there. It should be only used in a safe dev env. Thanks: Sebastian Berg and Nicolas Malin for report
1 parent 7120cf7 commit 0effce0

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • framework/base/src/main/java/org/apache/ofbiz/base/util

framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public static Map<String, Object> canonicalizeParameterMap(Map<String, Object> p
415415
params = params + s + " ";
416416
} else if (UtilValidate.isUrl(s) && !s.isEmpty()) {
417417
// if the string contains not only an URL => concatenate possible canonicalized before and after, w/o changing the URL
418-
String url = extractUrls(s).get(0); // THere should be only 1 URL in a block, makes no sense else
418+
String url = extractUrls(s).get(0); // There should be only 1 URL in a block, makes no sense else
419419
int start = s.indexOf(url);
420420
String after = (String) s.subSequence(start + url.length(), s.length());
421421
params = params + canonicalizeParameter((String) s.subSequence(0, start)) + url + canonicalizeParameter(after) + " ";
@@ -1736,9 +1736,15 @@ public static List<String> extractUrls(String input) {
17361736
+ "([-\\w~!$+|.,*:=]|%[a-f\\d]{2})*)*)*"
17371737
+ "(#([-\\w~!$+|.,*:=]|%[a-f\\d]{2})*)?\\b");
17381738

1739-
Matcher matcher = pattern.matcher(input);
1740-
while (matcher.find()) {
1741-
result.add(matcher.group());
1739+
if (input.contains("component://")
1740+
|| input.contains("https://localhost") // We consider localhost a safe dev env
1741+
|| input.contains("https://127.0.0.1")) {
1742+
result.add(input);
1743+
} else {
1744+
Matcher matcher = pattern.matcher(input);
1745+
while (matcher.find()) {
1746+
result.add(matcher.group());
1747+
}
17421748
}
17431749

17441750
return result;

0 commit comments

Comments
 (0)