File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -148,11 +148,15 @@ class LDP {
148
148
// prepare slug
149
149
if ( slug ) {
150
150
if ( this . isAuxResource ( slug , extension ) ) throw error ( 403 , 'POST is not allowed for auxiliary resources' )
151
+ if ( this . _containsInvalidSuffixes ( slug ) ) {
152
+ throw error ( 400 , `${ slug } is an invalid file path` )
153
+ }
151
154
slug = decodeURIComponent ( slug )
152
155
if ( slug . match ( / \/ | \| | : / ) ) {
153
156
throw error ( 400 , 'The name of new file POSTed may not contain : | or /' )
154
157
}
155
158
}
159
+
156
160
// Containers should not receive an extension
157
161
if ( container ) {
158
162
extension = ''
Original file line number Diff line number Diff line change @@ -891,6 +891,13 @@ describe('HTTP APIs', function () {
891
891
. set ( 'content-type' , 'text/turtle' )
892
892
. expect ( 403 , done )
893
893
} )
894
+ it ( 'should error with 400 if slug contains invalid suffix' , function ( done ) {
895
+ server . post ( '/post-tests/' )
896
+ . set ( 'slug' , 'put-resource.acl.ttl' )
897
+ . send ( postRequest1Body )
898
+ . set ( 'content-type' , 'text-turtle' )
899
+ . expect ( 400 , done )
900
+ } )
894
901
it ( 'should error with 400 if the body is empty and no content type is provided' , function ( done ) {
895
902
server . post ( '/post-tests/' )
896
903
. set ( 'slug' , 'post-resource-empty-fail' )
You can’t perform that action at this time.
0 commit comments