File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ def request_path
101101 # The original request path as decoded application components.
102102 # @returns [Utopia::Path] The normalized original request path.
103103 def original_path
104- path = Protocol ::URL ::Path [ self . request_path ] . normalize
104+ path = Protocol ::URL ::Path [ self . request_path ] . normalize . simplify
105105 return Path . new ( path . components ( Protocol ::URL ::Encoding ::System ) )
106106 end
107107
Original file line number Diff line number Diff line change 2222 expect ( document . request_path ) . to be == Utopia ::Path [ "/index" ]
2323 end
2424
25+ it "uses the normalized original request path" do
26+ request = Utopia ::Request [ "GET" , "/nested/../%69ndex" ]
27+ document = subject . new ( request , { } )
28+
29+ request . path = "/rewritten"
30+
31+ expect ( document . request_path ) . to be == Utopia ::Path [ "/index" ]
32+ end
33+
2534 it "should generate valid self-closing markup" do
2635 node = proc do |document , state |
2736 document . tag ( "img" , src : "cats.jpg" )
Original file line number Diff line number Diff line change 3838 expect ( request . request_path ) . to be == "/search"
3939 end
4040
41+ it "normalizes and simplifies the original request path" do
42+ request = Utopia ::Request [ "GET" , "/nested/../%69ndex?key=value" ]
43+ request . path = "/rewritten"
44+
45+ expect ( request . original_path ) . to be == Utopia ::Path [ "/index" ]
46+ end
47+
4148 it "identifies POST requests" do
4249 expect ( request . post? ) . to be == true
4350
You can’t perform that action at this time.
0 commit comments