truncate url at '?' when serving htmls

This commit is contained in:
Miguel Freitas 2013-11-02 12:39:56 -02:00
parent 22161a71ed
commit ecd49d2fb2

View File

@ -978,7 +978,12 @@ void ServiceConnection(AcceptedConnection *conn)
if (strURI != "/") { if (strURI != "/") {
std::vector<char> file_data; std::vector<char> file_data;
if( load_file(strURI.c_str(), file_data) == 0 ) { std::string fname = strURI;
size_t qMarkIdx = fname.find('?');
if( qMarkIdx != string::npos ) {
fname.resize(qMarkIdx);
}
if( load_file(fname.c_str(), file_data) == 0 ) {
std::string str(file_data.data(), file_data.size()); std::string str(file_data.data(), file_data.size());
const char *contentType = "text/html"; const char *contentType = "text/html";
if( strURI.find(".js") != std::string::npos ) if( strURI.find(".js") != std::string::npos )