Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_tools] fix path escaping on in depfile generation #50538

Merged
merged 4 commits into from Feb 11, 2020

Conversation

jonahwilliams
Copy link
Member

Description

When a depfile is generated for gradle build, empty spaces need to be escaped when creating the depfile. I verified this works locally on my computer, and created a unit test for the right escaping.

#16604

@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Feb 11, 2020
final String escapedPath = outputFile.path.replaceAll(r'\', r'\\');
final String escapedPath = outputFile.path
.replaceAll(r'\', r'\\')
.replaceAll(r' ', r'\ ');
buffer.write(' $escapedPath');
} else {
buffer.write(' ${outputFile.path}');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does _separatorExpr imply that spaces have to be escaped on all platforms? That is, a space preceded by anything but a '' is a separator not just on Windows, but on other platforms as well.

expect(outputDepfile.readAsStringSync(), contains(r'C:\\Hello\ Flutter\\b.txt'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows),
Platform: () => FakePlatform(operatingSystem: 'windows'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test spaces in paths on other platforms, too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jonahwilliams jonahwilliams changed the title [flutter_tools] fix path escaping on windows depfile generation [flutter_tools] fix path escaping on in depfile generation Feb 11, 2020
@jonahwilliams
Copy link
Member Author

I double checked, and you're right - they have to be escaped on macOS/Linux too. Updating PR. 🤦‍♂

@jonahwilliams jonahwilliams merged commit fa44a1c into flutter:master Feb 11, 2020
@jonahwilliams jonahwilliams deleted the fix_windows_path_escape branch February 11, 2020 17:32
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants