Text and number rules for what a receiver sends (everything from the network is untrusted): control characters are removed, long text is cut by code points, numbers are made finite and clamped, and a body nested too deep is refused before the JSON parser sees it (a recursive parser can overflow its stack on 16000 open brackets, which fit into a packet).
More...
|
| static String | clean (String text, int maxCodePoints) |
| |
| static double | clamp (double value, double min, double max) |
| |
| static boolean | isAcceptableJson (String body) |
| | Is this body safe to hand to the platform's JSON parser? Android's org.json tokener is far more lenient than JSON (single-quoted strings, //, /* */ and # comments, ; and = as separators) and recurses without a limit, so a scan that only understands double-quoted strings can be fooled into counting too little nesting (a ' or a comment hides a ") and the parser then overflows its stack.
|
| |
| static boolean | isNestedTooDeep (String body) |
| |
|
|
static final int | MAX_NAME = 60 |
| | Names of receivers and apps.
|
| |
|
static final int | MAX_ERROR = 200 |
| | Error texts of a receiver.
|
| |
|
static final int | MAX_URL = 2048 |
| | URLs and MIME types from a receiver (shown, never fetched).
|
| |
|
static final int | MAX_DEPTH = 16 |
| | The deepest nesting of arrays and objects in a body that is parsed (a message of protocol v3 has 3).
|
| |
Text and number rules for what a receiver sends (everything from the network is untrusted): control characters are removed, long text is cut by code points, numbers are made finite and clamped, and a body nested too deep is refused before the JSON parser sees it (a recursive parser can overflow its stack on 16000 open brackets, which fit into a packet).
Pure.
◆ clamp()
| static double de.yaacc.fcast.protocol.FCastText.clamp |
( |
double | value, |
|
|
double | min, |
|
|
double | max ) |
|
static |
◆ clean()
| static String de.yaacc.fcast.protocol.FCastText.clean |
( |
String | text, |
|
|
int | maxCodePoints ) |
|
static |
◆ isAcceptableJson()
| static boolean de.yaacc.fcast.protocol.FCastText.isAcceptableJson |
( |
String | body | ) |
|
|
static |
Is this body safe to hand to the platform's JSON parser? Android's org.json tokener is far more lenient than JSON (single-quoted strings, //, /* */ and # comments, ; and = as separators) and recurses without a limit, so a scan that only understands double-quoted strings can be fooled into counting too little nesting (a ' or a comment hides a ") and the parser then overflows its stack.
So this scan is strict: outside double-quoted strings only whitespace, the structure characters { } [ ] , : and the characters of numbers and of true, false, null are allowed; and the nesting is limited to MAX_DEPTH.
◆ isNestedTooDeep()
| static boolean de.yaacc.fcast.protocol.FCastText.isNestedTooDeep |
( |
String | body | ) |
|
|
static |
- Returns
- true if the body has more than
MAX_DEPTH levels of arrays and objects (brackets in strings do not count)
The documentation for this class was generated from the following file:
- /github/workspace/yaacc/src/main/java/de/yaacc/fcast/protocol/FCastText.java