##// END OF EJS Templates
hgweb: map Abort to 403 error to report inaccessible path for example...
Yuya Nishihara -
r39506:17ca967e default
parent child Browse files
Show More
@@ -439,6 +439,10 b' class hgweb(object):'
439 res.status = '500 Internal Server Error'
439 res.status = '500 Internal Server Error'
440 res.headers['Content-Type'] = ctype
440 res.headers['Content-Type'] = ctype
441 return rctx.sendtemplate('error', error=pycompat.bytestr(e))
441 return rctx.sendtemplate('error', error=pycompat.bytestr(e))
442 except error.Abort as e:
443 res.status = '403 Forbidden'
444 res.headers['Content-Type'] = ctype
445 return rctx.sendtemplate('error', error=pycompat.bytestr(e))
442 except ErrorResponse as e:
446 except ErrorResponse as e:
443 for k, v in e.headers:
447 for k, v in e.headers:
444 res.headers[k] = v
448 res.headers[k] = v
@@ -66,6 +66,20 b' create a subdirectory containing reposit'
66 > EOF
66 > EOF
67 $ cd ..
67 $ cd ..
68
68
69 add file under the directory which could be shadowed by another repository
70
71 $ mkdir notrepo/f/f3
72 $ echo f3/file > notrepo/f/f3/file
73 $ hg -R notrepo/f ci -Am 'f3/file'
74 adding f3/file
75 $ hg -R notrepo/f update null
76 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
77 $ hg init notrepo/f/f3
78 $ cat <<'EOF' > notrepo/f/f3/.hg/hgrc
79 > [web]
80 > hidden = true
81 > EOF
82
69 create repository without .hg/store
83 create repository without .hg/store
70
84
71 $ hg init nostore
85 $ hg init nostore
@@ -1217,6 +1231,38 b' Test subrepositories inside intermediate'
1217
1231
1218 f2
1232 f2
1219
1233
1234 Test accessing file that is shadowed by another repository
1235
1236 $ get-with-headers.py localhost:$HGPORT1 'rcoll/notrepo/f/file/tip/f3/file?style=raw'
1237 403 Forbidden
1238
1239
1240 error: path 'f3/file' is inside nested repo 'f3'
1241 [1]
1242
1243 $ get-with-headers.py localhost:$HGPORT1 'rcoll/notrepo/f/file/ffffffffffff/f3/file?style=raw'
1244 403 Forbidden
1245
1246
1247 error: path 'f3/file' is inside nested repo 'f3'
1248 [1]
1249
1250 Test accessing invalid paths:
1251
1252 $ get-with-headers.py localhost:$HGPORT1 'rcoll/notrepo/f/file/tip/..?style=raw'
1253 403 Forbidden
1254
1255
1256 error: .. not under root '$TESTTMP/dir/webdir/notrepo/f'
1257 [1]
1258
1259 $ get-with-headers.py localhost:$HGPORT1 'rcoll/notrepo/f/file/tip/.hg/hgrc?style=raw'
1260 403 Forbidden
1261
1262
1263 error: path contains illegal component: .hg/hgrc
1264 [1]
1265
1220 Test descend = False
1266 Test descend = False
1221
1267
1222 $ killdaemons.py
1268 $ killdaemons.py
General Comments 0
You need to be logged in to leave comments. Login now