You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "John Andrunas (Jira)" <ji...@apache.org> on 2019/09/18 15:51:00 UTC
[jira] [Issue Comment Deleted] (CAMEL-13962) OgnlHelper.splitOgnl
not able to handle Regex properly
[ https://issues.apache.org/jira/browse/CAMEL-13962?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Andrunas updated CAMEL-13962:
----------------------------------
Comment: was deleted
(was: Met rechtelijke machtiging in Dimence ik wil daar van af en weer naar huis)
> OgnlHelper.splitOgnl not able to handle Regex properly
> ------------------------------------------------------
>
> Key: CAMEL-13962
> URL: https://issues.apache.org/jira/browse/CAMEL-13962
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 2.24.1, 3.0.0.RC1
> Reporter: Michael Pätzold
> Assignee: Andrea Cosentino
> Priority: Minor
> Fix For: 3.0.0, 3.0.0.RC2
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> The splitOgnl method cannot properly handle an expression if it contains numerous paranthesis brackets and dots what is very likely in case you want to use regular expressions.
> The following examples tries to extract a specific cookie value from the cookie string that's contained within the headers:
> {code:java}
> @Test
> public void splitOgnlWithRegexInMethod() {
> String ognl = "header.cookie.replaceFirst(\".*;?iwanttoknow=([^;]+);?.*\", \"$1\")";
> assertFalse(OgnlHelper.isInvalidValidOgnlExpression(ognl));
> assertTrue(OgnlHelper.isValidOgnlExpression(ognl));
> List<String> strings = OgnlHelper.splitOgnl(ognl);
> assertEquals(3, strings.size());
> assertEquals("header", strings.get(0));
> assertEquals(".cookie", strings.get(1));
> assertEquals(".replaceFirst(\".*;?iwanttoknow=([^;]+);?.*\", \"$1\")", strings.get(2));
> }
> {code}
> The test fails using the current code base since the regular expression itself is split at the first dot after the first closing paranthesis bracket.
> If you'll agree that this is a bug I can come up with a possible solution that takes the amount of opening/closing brackets into account via PR.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)