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 )
7575{
7676 str path;
7777 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+
7895 std::string cfile = sptr_->get_content_dir ();
7996 if ( cfile.empty () ) {
8097 cfile += " ." ;
8198 }
82- cfile += std::string ( path. str_ , path. len_ ) ;
83- if ( path == str ( " /" ) ) {
99+ cfile += relpath ;
100+ if ( relpath == " /" ) {
84101 cfile += " index.html" ;
85102 }
86103 mem_map mf;
87104 mf.set_file ( cfile );
88- http_response msg;
89105 if ( mf.init () ) {
90106 msg.init ( " 200" , " OK" );
91107 msg.add_hdr ( " Content-Type" , get_content_type ( cfile ) );
You can’t perform that action at this time.
0 commit comments