Skip to content

Commit

Permalink
Hotfix: Escape XML
Browse files Browse the repository at this point in the history
  • Loading branch information
drolbr committed Feb 1, 2011
1 parent 8aa5598 commit 9fcf979
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 14 deletions.
7 changes: 7 additions & 0 deletions konzeptheft.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ Priorisierung
3. der Server soll alle Abfragen der gespiegelten Daten beantworten können, mit Aufwandsvorhersage
4. der Server soll Regeln bearbeiten können
5. der Server soll alle Abfragen der gespiegelten und abgeleiteten Daten beantworten können, mit Aufwandsvorhersage
7. Optimierung, z.B. area_query
8. Beschleunigung durch Bündelung
9. Refaktorisierung
10. Download-Suchmaschine
11. PBF anbinden
12. Refaktorisierung Linienanzeige
13. Liniennetz-Generator

*Projektstrukturplan

Expand Down
18 changes: 9 additions & 9 deletions src/dispatch/resource_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ uint64 eval_set(const Set& set_)
for (map< Uint32_Index, vector< Node_Skeleton > >::const_iterator
it(set_.nodes.begin()); it != set_.nodes.end(); ++it)
size += it->second.size()*8 + 64;
cerr<<size<<'\t';
//cerr<<size<<'\t';
for (map< Uint31_Index, vector< Way_Skeleton > >::const_iterator
it(set_.ways.begin()); it != set_.ways.end(); ++it)
size += it->second.size()*128 + 64;
cerr<<size<<'\t';
//cerr<<size<<'\t';
for (map< Uint31_Index, vector< Relation_Skeleton > >::const_iterator
it(set_.relations.begin()); it != set_.relations.end(); ++it)
size += it->second.size()*192 + 64;
cerr<<size<<'\t';
//cerr<<size<<'\t';
for (map< Uint31_Index, vector< Area_Skeleton > >::const_iterator
it(set_.areas.begin()); it != set_.areas.end(); ++it)
size += it->second.size()*128 + 64;
cerr<<size<<'\t';
//cerr<<size<<'\t';

return size;
}
Expand All @@ -43,23 +43,23 @@ void Resource_Manager::health_check(const Statement& stmt)
if (de_osm3s_file_ids::max_allowed_time > 0)
elapsed_time = time(NULL) - start_time;

cerr<<stmt.get_name()<<'\t';
cerr<<elapsed_time<<'\t'<<de_osm3s_file_ids::max_allowed_time<<'\t';
//cerr<<stmt.get_name()<<'\t';
//cerr<<elapsed_time<<'\t'<<de_osm3s_file_ids::max_allowed_time<<'\t';

uint64 size(0);
for (map< string, Set >::const_iterator it(sets_.begin()); it != sets_.end();
++it)
{
cerr<<it->first<<'\t';
//cerr<<it->first<<'\t';
size += eval_set(it->second);
}
for (vector< const Set* >::const_iterator it(set_stack.begin());
it != set_stack.end(); ++it)
{
cerr<<"[Stack]\t";
//cerr<<"[Stack]\t";
size += eval_set(**it);
}
cerr<<'\n';
//cerr<<'\n';

if (elapsed_time > de_osm3s_file_ids::max_allowed_time)
{
Expand Down
21 changes: 21 additions & 0 deletions src/frontend/user_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,24 @@ string get_xml_raw(Error_Output* error_output, uint32 max_input_size)

return input;
}

string escape_xml(const string& s)
{
string result;
for (int i(0); i < s.length(); ++i)
{
if (s[i] == '&')
result += "&amp;";
else if (s[i] == '\"')
result += "&quot;";
else if (s[i] == '<')
result += "&lt;";
else if (s[i] == '>')
result += "&gt;";
else if (s[i] < 32)
result += '?';
else
result += s[i];
}
return result;
}
2 changes: 2 additions & 0 deletions src/frontend/user_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ using namespace std;

string get_xml_raw(Error_Output* error_output, uint32 max_input_size = 1048576);

string escape_xml(const string& s);

#endif
13 changes: 9 additions & 4 deletions src/statements/print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../backend/block_backend.h"
#include "../backend/random_file.h"
#include "../core/settings.h"
#include "../frontend/user_interface.h"
#include "print.h"

using namespace std;
Expand Down Expand Up @@ -179,7 +180,8 @@ void print_item(uint32 ll_upper, const Node_Skeleton& skel, uint32 mode,
cout<<">\n";
for (vector< pair< string, string > >::const_iterator it(tags->begin());
it != tags->end(); ++it)
cout<<" <tag k=\""<<it->first<<"\" v=\""<<it->second<<"\"/>\n";
cout<<" <tag k=\""<<escape_xml(it->first)
<<"\" v=\""<<escape_xml(it->second)<<"\"/>\n";
cout<<" </node>\n";
}
}
Expand All @@ -204,7 +206,8 @@ void print_item(uint32 ll_upper, const Way_Skeleton& skel, uint32 mode,
{
for (vector< pair< string, string > >::const_iterator it(tags->begin());
it != tags->end(); ++it)
cout<<" <tag k=\""<<it->first<<"\" v=\""<<it->second<<"\"/>\n";
cout<<" <tag k=\""<<escape_xml(it->first)
<<"\" v=\""<<escape_xml(it->second)<<"\"/>\n";
}
cout<<" </way>\n";
}
Expand Down Expand Up @@ -243,7 +246,8 @@ void print_item(uint32 ll_upper, const Relation_Skeleton& skel, uint32 mode,
{
for (vector< pair< string, string > >::const_iterator it(tags->begin());
it != tags->end(); ++it)
cout<<" <tag k=\""<<it->first<<"\" v=\""<<it->second<<"\"/>\n";
cout<<" <tag k=\""<<escape_xml(it->first)
<<"\" v=\""<<escape_xml(it->second)<<"\"/>\n";
}
cout<<" </relation>\n";
}
Expand All @@ -262,7 +266,8 @@ void print_item(uint32 ll_upper, const Area_Skeleton& skel, uint32 mode,
cout<<">\n";
for (vector< pair< string, string > >::const_iterator it(tags->begin());
it != tags->end(); ++it)
cout<<" <tag k=\""<<it->first<<"\" v=\""<<it->second<<"\"/>\n";
cout<<" <tag k=\""<<escape_xml(it->first)
<<"\" v=\""<<escape_xml(it->second)<<"\"/>\n";
cout<<" </area>\n";
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test-bin/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dist_testbin_SCRIPTS = apply_osc.test.sh

statements_cc = ../statements/statement.cc ../statements/area_query.cc ../statements/bbox_query.cc ../statements/coord_query.cc ../statements/foreach.cc ../statements/id_query.cc ../statements/item.cc ../statements/make_area.cc ../statements/osm_script.cc ../statements/print.cc ../statements/query.cc ../statements/recurse.cc ../statements/union.cc

testenv_cc = ../osm-backend/stopwatch.cc ../dispatch/resource_manager.cc ../core/settings.cc ../frontend/console_output.cc
testenv_cc = ../osm-backend/stopwatch.cc ../dispatch/resource_manager.cc ../core/settings.cc ../frontend/console_output.cc ../frontend/user_interface.cc ../frontend/cgi-helper.cc

file_blocks_SOURCES = ../backend/file_blocks.test.cc
block_backend_SOURCES = ../backend/block_backend.test.cc
Expand Down

0 comments on commit 9fcf979

Please sign in to comment.