Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
5d6321b5
Unverified
Commit
5d6321b5
authored
Oct 02, 2020
by
Mouad Debbar
Committed by
GitHub
Oct 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] Respond with 404 to non-found asset or package files (#67088)
parent
385ae402
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
devfs_web.dart
packages/flutter_tools/lib/src/isolated/devfs_web.dart
+5
-0
devfs_web_test.dart
.../flutter_tools/test/general.shard/web/devfs_web_test.dart
+41
-0
No files found.
packages/flutter_tools/lib/src/isolated/devfs_web.dart
View file @
5d6321b5
...
...
@@ -406,6 +406,11 @@ class WebAssetServer implements AssetReader {
}
if
(!
file
.
existsSync
())
{
// Paths starting with these prefixes should've been resolved above.
if
(
requestPath
.
startsWith
(
'assets/'
)
||
requestPath
.
startsWith
(
'packages/'
))
{
return
shelf
.
Response
.
notFound
(
''
);
}
return
_serveIndex
();
}
...
...
packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
View file @
5d6321b5
...
...
@@ -260,6 +260,47 @@ void main() {
expect
(
await
response
.
readAsString
(),
htmlContent
);
}));
test
(
'does not serve outside the base path'
,
()
=>
testbed
.
run
(()
async
{
webAssetServer
.
basePath
=
'base/path'
;
const
String
htmlContent
=
'<html><head></head><body id="test"></body></html>'
;
final
Directory
webDir
=
globals
.
fs
.
currentDirectory
.
childDirectory
(
'web'
)
..
createSync
();
webDir
.
childFile
(
'index.html'
).
writeAsStringSync
(
htmlContent
);
final
Response
response
=
await
webAssetServer
.
handleRequest
(
Request
(
'GET'
,
Uri
.
parse
(
'http://foobar/'
)));
expect
(
response
.
statusCode
,
HttpStatus
.
notFound
);
}));
test
(
'does not serve index.html when path is inside assets or packages'
,
()
=>
testbed
.
run
(()
async
{
const
String
htmlContent
=
'<html><head></head><body id="test"></body></html>'
;
final
Directory
webDir
=
globals
.
fs
.
currentDirectory
.
childDirectory
(
'web'
)
..
createSync
();
webDir
.
childFile
(
'index.html'
).
writeAsStringSync
(
htmlContent
);
Response
response
=
await
webAssetServer
.
handleRequest
(
Request
(
'GET'
,
Uri
.
parse
(
'http://foobar/assets/foo/bar.png'
)));
expect
(
response
.
statusCode
,
HttpStatus
.
notFound
);
response
=
await
webAssetServer
.
handleRequest
(
Request
(
'GET'
,
Uri
.
parse
(
'http://foobar/packages/foo/bar.dart.js'
)));
expect
(
response
.
statusCode
,
HttpStatus
.
notFound
);
webAssetServer
.
basePath
=
'base/path'
;
response
=
await
webAssetServer
.
handleRequest
(
Request
(
'GET'
,
Uri
.
parse
(
'http://foobar/base/path/assets/foo/bar.png'
)));
expect
(
response
.
statusCode
,
HttpStatus
.
notFound
);
response
=
await
webAssetServer
.
handleRequest
(
Request
(
'GET'
,
Uri
.
parse
(
'http://foobar/base/path/packages/foo/bar.dart.js'
)));
expect
(
response
.
statusCode
,
HttpStatus
.
notFound
);
}));
test
(
'serves default index.html'
,
()
=>
testbed
.
run
(()
async
{
final
Response
response
=
await
webAssetServer
.
handleRequest
(
Request
(
'GET'
,
Uri
.
parse
(
'http://foobar/'
)));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment