-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle unicode characters in filters #707
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,10 +23,6 @@ | |
import java.util.Deque; | ||
import java.util.Locale; | ||
|
||
import org.apache.commons.lang3.StringEscapeUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import org.apache.directory.scim.spec.filter.FilterParser.AttributeCompareExpressionContext; | ||
import org.apache.directory.scim.spec.filter.FilterParser.AttributeGroupExpressionContext; | ||
import org.apache.directory.scim.spec.filter.FilterParser.AttributeLogicExpressionContext; | ||
|
@@ -41,8 +37,6 @@ | |
|
||
public class ExpressionBuildingListener extends FilterBaseListener { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(ExpressionBuildingListener.class); | ||
|
||
protected Deque<FilterExpression> expressionStack = new ArrayDeque<>(); | ||
|
||
@Override | ||
|
@@ -160,14 +154,8 @@ public FilterExpression getFilterExpression() { | |
|
||
private static Object parseJsonType(String jsonValue) { | ||
if (jsonValue.startsWith("\"")) { | ||
String doubleEscaped = jsonValue.substring(1, jsonValue.length() - 1) | ||
// StringEscapeUtils follows the outdated JSON spec requiring "/" to be escaped, this could subtly break things | ||
.replaceAll("\\\\/", "\\\\\\\\/") | ||
// Just in case someone needs a single-quote with a backslash in front of it, this will be unnecessary with escapeJson() | ||
.replaceAll("\\\\'", "\\\\\\\\'"); | ||
|
||
// TODO change this to escapeJson() when dependencies get upgraded | ||
return StringEscapeUtils.unescapeEcmaScript(doubleEscaped); | ||
Comment on lines
-163
to
-170
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bdemers Can we note for posterity, even if just in this PR convo, where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hoping @chrisharm would chime in 🤞
Unless I'm missing something i think it would always be problematic to handle escaping outside of the context where it's used. |
||
// remove leading and trailing slash | ||
return jsonValue.substring(1, jsonValue.length() - 1); | ||
} else if ("null".equals(jsonValue)) { | ||
return null; | ||
} else if ("true".equals(jsonValue)) { | ||
|
@@ -182,11 +170,9 @@ private static Object parseJsonType(String jsonValue) { | |
return Integer.parseInt(jsonValue); | ||
} | ||
} catch (NumberFormatException e) { | ||
LOG.warn("Unable to parse a json number: " + jsonValue); | ||
throw new IllegalStateException("Unable to parse JSON number: " + jsonValue, e); | ||
} | ||
} | ||
|
||
throw new IllegalStateException("Unable to parse JSON Value"); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just now giving this a quick look, @bdemers. Can we note for posterity, even if just in this PR convo, where
escapeJson()
is now being used?