File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -75,17 +75,33 @@ void user::parse_content( const char *, size_t )
75
75
{
76
76
str path;
77
77
hsvr_.get_path ( path );
78
+
79
+ http_response msg;
80
+
81
+ // whitelist
82
+ std::string const relpath{ path.str_ , path.len_ };
83
+ if (
84
+ relpath != " /"
85
+ && relpath != " /dashboard.js"
86
+ && relpath != " /index.html"
87
+ && relpath != " /style.css"
88
+ ) {
89
+ msg.init ( " 404" , " Not Found" );
90
+ msg.commit ();
91
+ add_send ( msg );
92
+ return ;
93
+ }
94
+
78
95
std::string cfile = sptr_->get_content_dir ();
79
96
if ( cfile.empty () ) {
80
97
cfile += " ." ;
81
98
}
82
- cfile += std::string ( path. str_ , path. len_ ) ;
83
- if ( path == str ( " /" ) ) {
99
+ cfile += relpath ;
100
+ if ( relpath == " /" ) {
84
101
cfile += " index.html" ;
85
102
}
86
103
mem_map mf;
87
104
mf.set_file ( cfile );
88
- http_response msg;
89
105
if ( mf.init () ) {
90
106
msg.init ( " 200" , " OK" );
91
107
msg.add_hdr ( " Content-Type" , get_content_type ( cfile ) );
You can’t perform that action at this time.
0 commit comments