mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
add nocommits for Booleans parsing leniency
This commit is contained in:
parent
4d27d751fb
commit
dfd7122a53
@ -24,10 +24,9 @@ package org.elasticsearch.common;
|
|||||||
*/
|
*/
|
||||||
public class Booleans {
|
public class Booleans {
|
||||||
|
|
||||||
|
// nocommit remove this lenient one and cutover to parseBooleanExact
|
||||||
/**
|
/**
|
||||||
* Returns <code>true</code> iff the sequence is neither of the following:
|
* Returns <code>false</code> if text is in <tt>false</tt>, <tt>0</tt>, <tt>off</tt>, <tt>no</tt>; else, true
|
||||||
* <tt>false</tt>, <tt>0</tt>, <tt>off</tt>, <tt>no</tt>,
|
|
||||||
* otherwise <code>false</code>
|
|
||||||
*/
|
*/
|
||||||
public static boolean parseBoolean(char[] text, int offset, int length, boolean defaultValue) {
|
public static boolean parseBoolean(char[] text, int offset, int length, boolean defaultValue) {
|
||||||
if (text == null || length == 0) {
|
if (text == null || length == 0) {
|
||||||
@ -45,6 +44,7 @@ public class Booleans {
|
|||||||
if (length == 5) {
|
if (length == 5) {
|
||||||
return !(text[offset] == 'f' && text[offset + 1] == 'a' && text[offset + 2] == 'l' && text[offset + 3] == 's' && text[offset + 4] == 'e');
|
return !(text[offset] == 'f' && text[offset + 1] == 'a' && text[offset + 2] == 'l' && text[offset + 3] == 's' && text[offset + 4] == 'e');
|
||||||
}
|
}
|
||||||
|
// nocommit check for known "true" values and throw exc if it's not recognized
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user