@@ -25,14 +25,14 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
2525 }
2626 }()
2727
28- // check url structure
28+ // check url structure(/secret/calc.class)
2929 sections := strings .SplitN (r .RequestURI , "/" , 3 )
3030 if len (sections ) < 3 {
3131 h .logger .Println ("[error]" , "invalid request url structure:" , r .RequestURI )
3232 return
3333 }
3434
35- // compare secret
35+ // skip first section and compare secret
3636 if sections [0 ] != "" || sections [1 ] != h .secret {
3737 h .logger .Println ("[warning]" , "invalid secret:" , sections [1 ])
3838 return
@@ -44,19 +44,7 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
4444 h .logger .Println ("[warning]" , "found slash in url:" , r .RequestURI )
4545 return
4646 }
47-
48- // convert "/secret/calc.class/Main.class" to "/secret/calc.class"
49- // "/secret/Main.class/other.class" to "/secret/other.class"
50- // path = strings.Replace(path, "Main.class", "", 1)
51- // fmt.Println("path:", path)
52- // path = filepath.Join(h.payloadDir, path)
53-
54- idx := strings .LastIndex (path , "/" )
55- if idx == - 1 {
56- h .logger .Println ("[error]" , "invalid request url structure:" , r .RequestURI )
57- return
58- }
59- path = filepath .Join (h .payloadDir , path [:idx ])
47+ path = filepath .Join (h .payloadDir , path )
6048
6149 // read file and send to client
6250 class , err := os .ReadFile (path )
0 commit comments