diff --git a/src/expat/escape_json.cc b/src/expat/escape_json.cc index 27a183b71..9d3201bca 100644 --- a/src/expat/escape_json.cc +++ b/src/expat/escape_json.cc @@ -44,3 +44,16 @@ std::string escape_cstr(const std::string& s) } return result; } + + +std::ostream& operator<<(std::ostream& out, const Json_Escaped& e) +{ + // escape_cstr changes exactly the characters '"', '\\' and those below 32. + for (std::string::size_type i = 0; i < e.s.size(); ++i) + { + unsigned char c = e.s[i]; + if (c == '\"' || c == '\\' || c < 32) + return out< #include std::string escape_cstr(const std::string& s); +/* Writes escape_cstr(s) to a stream. Most strings need no escaping; those are written + directly, without building an escaped copy. Use as out<' and those below 32. + for (std::string::size_type i = 0; i < e.s.size(); ++i) + { + unsigned char c = e.s[i]; + if (c == '&' || c == '\"' || c == '<' || c == '>' || c < 32) + return out< #include std::string escape_xml(const std::string& s); +/* Writes escape_xml(s) to a stream. Most strings need no escaping; those are written + directly, without building an escaped copy. Use as out<::const_iterator rit = roles.find(entry.role); - result<second : "???"); + result<second : "???"); } else if (raw_template.substr(new_pos, 8) == "{{first:") ; diff --git a/src/overpass_api/output_formats/output_json.cc b/src/overpass_api/output_formats/output_json.cc index 64a1afa35..cfac0e609 100644 --- a/src/overpass_api/output_formats/output_json.cc +++ b/src/overpass_api/output_formats/output_json.cc @@ -86,7 +86,7 @@ void print_meta_json(const OSM_Element_Metadata_Skeleton< Id_Type >& meta, ",\n \"changeset\": "<::const_iterator it = users.find(meta.user_id); if (it != users.end()) - std::cout<<",\n \"user\": \""<second)<<"\""; + std::cout<<",\n \"user\": \""<second)<<"\""; std::cout<<",\n \"uid\": "< >* tags { std::vector< std::pair< std::string, std::string > >::const_iterator it = tags->begin(); std::cout<<",\n \"tags\": {" - "\n \""<first)<<"\": \""<second)<<"\""; + "\n \""<first)<<"\": \""<second)<<"\""; for (++it; it != tags->end(); ++it) - std::cout<<",\n \""<first)<<"\": \""<second)<<"\""; + std::cout<<",\n \""<first)<<"\": \""<second)<<"\""; std::cout<<"\n }"; } } @@ -242,7 +242,7 @@ void Output_JSON::print_item(const Relation_Skeleton& skel, std::cout <<"\n {" "\n \"type\": \""<end() ? rit->second : "???") << "\""; + ",\n \"role\": \""<end() ? rit->second : "???") << "\""; if (skel.members[i].type == Relation_Entry::NODE && geometry.has_faithful_relation_geometry() && geometry.relation_pos_is_valid(i)) diff --git a/src/overpass_api/output_formats/output_xml.cc b/src/overpass_api/output_formats/output_xml.cc index 6b8784ccc..49ee548ce 100644 --- a/src/overpass_api/output_formats/output_xml.cc +++ b/src/overpass_api/output_formats/output_xml.cc @@ -81,7 +81,7 @@ void print_meta_xml(const OSM_Element_Metadata_Skeleton< Id_Type >& meta, <<"\" changeset=\""<::const_iterator it = users.find(meta.user_id); if (it != users.end()) - std::cout<<" user=\""<second)<<"\""; + std::cout<<" user=\""<second)<<"\""; } @@ -152,7 +152,7 @@ void print_tags(const std::vector< std::pair< std::string, std::string > >* tags } for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags->begin(); it != tags->end(); ++it) - std::cout<<" first)<<"\" v=\""<second)<<"\"/>\n"; + std::cout<<" first)<<"\" v=\""<second)<<"\"/>\n"; } } @@ -322,7 +322,7 @@ void print_members(const Relation_Skeleton& skel, const Opaque_Geometry& geometr std::map< uint32, std::string >::const_iterator it = roles.find(skel.members[i].role); std::cout<<" second : "???")<<"\""; + <<"\" role=\""<second : "???")<<"\""; if (skel.members[i].type == Relation_Entry::NODE) {