Skip to content

Commit

Permalink
Fix accepting invalid numbers containing ':'.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Aug 21, 2014
1 parent d1dd6c9 commit 1ce8cd3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions source/vibe/data/json.d
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ Json parseJson(R)(ref R range, int* line = null)
range.popFrontN(4);
ret = true;
break;
case '0': .. case '9'+1:
case '0': .. case '9':
case '-':
bool is_float;
auto num = skipNumber(range, is_float);
Expand Down Expand Up @@ -1061,7 +1061,7 @@ T deserializeJson(T, R)(R input)
/// private
T deserializeJsonOld(T)(Json src)
{
static if( is(T == struct) || isSomeString!T || isIntegral!T || isFloatingPoint!T )
static if( is(T == struct) || isSomeString!T || isIntegral!T || isFloatingPoint!T )
if( src.type == Json.Type.null_ ) return T.init;
static if (is(T == Json)) return src;
else static if (is(T == typeof(null))) { return null; }
Expand All @@ -1086,7 +1086,7 @@ T deserializeJsonOld(T)(Json src)
foreach (string key, value; src) {
static if (is(TK == string)) {
dst[key] = deserializeJson!(Unqual!TV)(value);
} else static if (is(TK == enum)) {
} else static if (is(TK == enum)) {
dst[to!(TK)(key)] = deserializeJson!(Unqual!TV)(value);
} else static if (isStringSerializable!TK) {
auto dsk = TK.fromString(key);
Expand Down Expand Up @@ -1271,7 +1271,7 @@ unittest {
*/
struct JsonSerializer {
template isJsonBasicType(T) { enum isJsonBasicType = isNumeric!T || isBoolean!T || is(T == string) || is(T == typeof(null)) || isJsonSerializable!T; }

template isSupportedValueType(T) { enum isSupportedValueType = isJsonBasicType!T || is(T == Json); }

private {
Expand Down Expand Up @@ -1356,7 +1356,7 @@ struct JsonStringSerializer(R, bool pretty = false)
}

template isJsonBasicType(T) { enum isJsonBasicType = is(T : long) || is(T : real) || is(T == string) || is(T == typeof(null)) || isJsonSerializable!T; }

template isSupportedValueType(T) { enum isSupportedValueType = isJsonBasicType!T || is(T == Json); }

this(R range)
Expand Down Expand Up @@ -1698,7 +1698,7 @@ private void jsonEscape(R)(ref R dst, string s)
immutable(char) ch = s[pos];

switch(ch){
default:
default:
if (ch < 0x80)
{
dst.put(ch);
Expand All @@ -1719,11 +1719,11 @@ private void jsonEscape(R)(ref R dst, string s)
else
{
int first, last;

codepoint -= 0x10000;
first = 0xD800 | ((codepoint & 0xffc00) >> 10);
last = 0xDC00 | (codepoint & 0x003ff);

sprintf(&buf[0], "\\u%04X\\u%04X", first, last);
len = 12;
}
Expand Down Expand Up @@ -1894,4 +1894,4 @@ private void enforceJson(string file = __FILE__, size_t line = __LINE__)(bool co
{
static if (__VERSION__ >= 2065) enforceEx!JSONException(cond, message, file, line);
else if (!cond) throw new JSONException(message);
}
}

0 comments on commit 1ce8cd3

Please sign in to comment.