Skip to content

Commit

Permalink
Added json error handling for invalid UTF character
Browse files Browse the repository at this point in the history
  • Loading branch information
Etienne Cimon committed Jul 16, 2014
1 parent 8e8ab0f commit 2c8ab7d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions source/vibe/data/json.d
Original file line number Diff line number Diff line change
Expand Up @@ -1703,14 +1703,16 @@ private string jsonUnescape(R)(ref R range)
else if( dc >= 'A' && dc <= 'F' ) uch += dc - 'A' + 10;
else enforceJson(false, "Unicode sequence must be '\\uXXXX'.");
}
import std.utf;
try
{
ret.put(uch);
}
catch(Throwable e)
{
ret.put("");
catch(UTFException e)
{ // Avoiding a server 500 error with e.msg = "Invalid UTF sequence: d83c - Encoding a surrogate code point in UTF-8"
ret.put("0");
}

break;
}
break;
Expand Down

0 comments on commit 2c8ab7d

Please sign in to comment.