|
|
| version 1.22, 2012/05/29 21:57:01 | version 1.24, 2012/06/21 14:22:09 |
|---|---|
| Line 44 struct Json { | Line 44 struct Json { |
| Request* request; | Request* request; |
| Charset *charset; | Charset *charset; |
| String::Language taint; | |
| bool handle_double; | bool handle_double; |
| enum Distinct { D_EXCEPTION, D_FIRST, D_LAST, D_ALL } distinct; | enum Distinct { D_EXCEPTION, D_FIRST, D_LAST, D_ALL } distinct; |
| Json(Charset* acharset): stack(), key_stack(), key(NULL), result(NULL), hook_object(NULL), hook_array(NULL), request(NULL), charset(acharset), handle_double(true), distinct(D_EXCEPTION){} | Json(Charset* acharset): stack(), key_stack(), key(NULL), result(NULL), hook_object(NULL), hook_array(NULL), |
| request(NULL), charset(acharset), taint(String::L_TAINTED), handle_double(true), distinct(D_EXCEPTION){} | |
| bool set_distinct(const String &value){ | bool set_distinct(const String &value){ |
| if (value == "first") distinct = D_FIRST; | if (value == "first") distinct = D_FIRST; |
| Line 90 static void set_json_value(Json *json, V | Line 93 static void set_json_value(Json *json, V |
| String* json_string(Json *json, const JSON_value* value){ | String* json_string(Json *json, const JSON_value* value){ |
| String::C result = json->charset !=NULL ? | String::C result = json->charset !=NULL ? |
| Charset::transcode(String::C(value->vu.str.value, value->vu.str.length), UTF8_charset, *json->charset) : | Charset::transcode(String::C(value->vu.str.value, value->vu.str.length), UTF8_charset, *json->charset) : |
| String::C(pa_strdup(value->vu.str.value, value->vu.str.length), value->vu.str.length); | String::C(pa_strdup(value->vu.str.value, value->vu.str.length), value->vu.str.length); |
| return new String(result.str, String::L_TAINTED, result.length); | return new String(result.str, json->taint, result.length); |
| } | } |
| static Value *json_hook(Request &r, Junction *hook, String* key, Value* value){ | static Value *json_hook(Request &r, Junction *hook, String* key, Value* value){ |
| Line 202 static const char* json_error_message(in | Line 205 static const char* json_error_message(in |
| return error_messages[error_code]; | return error_messages[error_code]; |
| } | } |
| extern String::Language get_untaint_lang(const String& lang_name); | |
| static void _parse(Request& r, MethodParams& params) { | static void _parse(Request& r, MethodParams& params) { |
| const String& json_string=params.as_string(0, "json must be string"); | const String& json_string=params.as_string(0, "json must be string"); |
| Line 233 static void _parse(Request& r, MethodPar | Line 238 static void _parse(Request& r, MethodPar |
| throw Exception(PARSER_RUNTIME, &sdistinct, "must be 'first', 'last' or 'all'"); | throw Exception(PARSER_RUNTIME, &sdistinct, "must be 'first', 'last' or 'all'"); |
| valid_options++; | valid_options++; |
| } | } |
| if(Value* value=options->get("taint")) { | |
| json.taint=get_untaint_lang(value->as_string()); | |
| valid_options++; | |
| } | |
| if(Value* value=options->get("object")) { | if(Value* value=options->get("object")) { |
| json.hook_object=value->get_junction(); | json.hook_object=value->get_junction(); |
| json.request=&r; | json.request=&r; |
| Line 386 static void _string(Request& r, MethodPa | Line 395 static void _string(Request& r, MethodPa |
| valid_options++; | valid_options++; |
| #ifdef XML | #ifdef XML |
| } else if(key == "xdoc" && (vvalue = value->get_hash())){ | } else if(key == "xdoc" && (vvalue = value->get_hash())){ |
| json.xdoc_options=new XDocOutputOptions(r, vvalue); | json.xdoc_options=new XDocOutputOptions(); |
| json.xdoc_options->append(r, vvalue); | |
| valid_options++; | valid_options++; |
| #endif | #endif |
| } else if(Junction* junction=value->get_junction()){ | } else if(Junction* junction=value->get_junction()){ |