mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-02-09 13:24:29 +00:00
use utf8 for text json strings. only a few characters need to be
escaped per json rfc spec. escaping everything was causing problem with browsers.
This commit is contained in:
parent
bc990abfff
commit
40cd54e0ec
@ -993,9 +993,9 @@ void ServiceConnection(AcceptedConnection *conn)
|
||||
std::vector<char> file_data;
|
||||
if( load_file( fname.c_str(), file_data) == 0 ) {
|
||||
std::string str(file_data.data(), file_data.size());
|
||||
const char *contentType = "text/html";
|
||||
const char *contentType = "text/html; charset=utf-8";
|
||||
if( strURI.find(".js") != std::string::npos )
|
||||
contentType = "text/javascript";
|
||||
contentType = "text/javascript; charset=utf-8";
|
||||
if( strURI.find(".css") != std::string::npos )
|
||||
contentType = "text/css";
|
||||
if( strURI.find(".png") != std::string::npos )
|
||||
|
@ -75,6 +75,7 @@ namespace json_spirit
|
||||
|
||||
if( add_esc_char( c, result ) ) continue;
|
||||
|
||||
/*
|
||||
const wint_t unsigned_c( ( c >= 0 ) ? c : 256 + c );
|
||||
|
||||
if( iswprint( unsigned_c ) )
|
||||
@ -85,6 +86,14 @@ namespace json_spirit
|
||||
{
|
||||
result += non_printable_to_string< String_type >( unsigned_c );
|
||||
}
|
||||
*/
|
||||
// [MF] twister uses utf8 strings (and not any sort of wide char).
|
||||
// only control characters need to be escaped, per JSON RFC spec.
|
||||
if( c >=0 && c <= 0x1f ) {
|
||||
result += non_printable_to_string< String_type >( c );
|
||||
} else {
|
||||
result += c;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user