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
fa44a1cf
Unverified
Commit
fa44a1cf
authored
Feb 11, 2020
by
Jonah Williams
Committed by
GitHub
Feb 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] fix path escaping on in depfile generation (#50538)
parent
c6e45ffa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
4 deletions
+42
-4
depfile.dart
packages/flutter_tools/lib/src/build_system/depfile.dart
+8
-4
depfile_test.dart
...r_tools/test/general.shard/build_system/depfile_test.dart
+34
-0
No files found.
packages/flutter_tools/lib/src/build_system/depfile.dart
View file @
fa44a1cf
...
...
@@ -74,11 +74,15 @@ class Depfile {
void
_writeFilesToBuffer
(
List
<
File
>
files
,
StringBuffer
buffer
)
{
for
(
final
File
outputFile
in
files
)
{
if
(
globals
.
platform
.
isWindows
)
{
// Paths in a depfile have to be escaped on windows.
final
String
escapedPath
=
outputFile
.
path
.
replaceAll
(
r'\'
,
r'\\'
);
buffer
.
write
(
'
$escapedPath
'
);
// Foward slashes and spaces in a depfile have to be escaped on windows.
final
String
path
=
outputFile
.
path
.
replaceAll
(
r'\'
,
r'\\'
)
.
replaceAll
(
r' '
,
r'\ '
);
buffer
.
write
(
'
$path
'
);
}
else
{
buffer
.
write
(
'
${outputFile.path}
'
);
final
String
path
=
outputFile
.
path
.
replaceAll
(
r' '
,
r'\ '
);
buffer
.
write
(
'
$path
'
);
}
}
}
...
...
packages/flutter_tools/test/general.shard/build_system/depfile_test.dart
View file @
fa44a1cf
...
...
@@ -6,6 +6,7 @@ import 'package:file/memory.dart';
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/build_system/depfile.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:platform/platform.dart'
;
import
'../../src/common.dart'
;
import
'../../src/testbed.dart'
;
...
...
@@ -66,6 +67,39 @@ C:\\a.txt: C:\\b.txt
FileSystem:
()
=>
MemoryFileSystem
(
style:
FileSystemStyle
.
windows
),
}));
test
(
'Can escape depfile with windows file paths and spaces in directory names'
,
()
=>
testbed
.
run
(()
{
final
File
inputFile
=
globals
.
fs
.
directory
(
r'Hello Flutter'
).
childFile
(
'a.txt'
).
absolute
..
createSync
(
recursive:
true
);
final
File
outputFile
=
globals
.
fs
.
directory
(
r'Hello Flutter'
).
childFile
(
'b.txt'
).
absolute
..
createSync
();
final
Depfile
depfile
=
Depfile
(<
File
>[
inputFile
],
<
File
>[
outputFile
]);
final
File
outputDepfile
=
globals
.
fs
.
file
(
'depfile'
);
depfile
.
writeToFile
(
outputDepfile
);
expect
(
outputDepfile
.
readAsStringSync
(),
contains
(
r'C:\\Hello\ Flutter\\a.txt'
));
expect
(
outputDepfile
.
readAsStringSync
(),
contains
(
r'C:\\Hello\ Flutter\\b.txt'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(
style:
FileSystemStyle
.
windows
),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'windows'
),
}));
test
(
'Can escape depfile with spaces in directory names'
,
()
=>
testbed
.
run
(()
{
final
File
inputFile
=
globals
.
fs
.
directory
(
r'Hello Flutter'
).
childFile
(
'a.txt'
).
absolute
..
createSync
(
recursive:
true
);
final
File
outputFile
=
globals
.
fs
.
directory
(
r'Hello Flutter'
).
childFile
(
'b.txt'
).
absolute
..
createSync
();
final
Depfile
depfile
=
Depfile
(<
File
>[
inputFile
],
<
File
>[
outputFile
]);
final
File
outputDepfile
=
globals
.
fs
.
file
(
'depfile'
);
depfile
.
writeToFile
(
outputDepfile
);
expect
(
outputDepfile
.
readAsStringSync
(),
contains
(
r'/Hello\ Flutter/a.txt'
));
expect
(
outputDepfile
.
readAsStringSync
(),
contains
(
r'/Hello\ Flutter/b.txt'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(
style:
FileSystemStyle
.
posix
),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
),
}));
test
(
'Resillient to weird whitespace'
,
()
=>
testbed
.
run
(()
{
final
File
depfileSource
=
globals
.
fs
.
file
(
'example.d'
)..
writeAsStringSync
(
r''
'
a.txt
...
...
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