firebase / firebase/firebase-tools
Newlines in firebase auth:export are not escaped
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 84
Description
### Environment info
**firebase-tools:** v9.21.0
**Platform:** macOS
### Test case
Firebase Auth has to be enabled for the issue to appear, but apart from that the issue can be reproduced using the 3 steps below.
### Steps to reproduce
1. Create a new user like this:
```ts
admin.auth().createUser({
displayName: 'Foo\nBar'
});
```
2. Use the Firebase CLI to export all users to a file:
```
firebase auth:export ./accounts.csv --format CSV --project old-project
```
3. Use the Firebase CLI to import all users from the accounts.csv file:
```
firebase auth:import ./accounts.csv --project=new-project
```
### Expected behavior
The exported users from Auth simply import to a different Firebase project using the CLI.
### Actual behavior
I am getting the following error:
The import fails with an error like this:
Error: Line 2 (...) has invalid data format: Password hash should be base64 encoded.
After investigating the data a bit I noticed some interesting data regarding all name fields:
A user added via Google Login had a newline (\n) in their "Name" (column 6) and "Google Display Name" (column 10), which resulted in the CSV also including a line break!
So the accounts.csv looked something like this:
123123123,foo.bar@example.com,true,passwordHash==,salt==,Foo
Bar,https://example.com/images.png,foo.bar@example.com,Foo
Bar,https://example.com/images.png,,,,,,,,,,,,,1111,1111,,false,,
Because of this new line in the name fields, the resulting CSV is incorrect and the importer assumed that the second line was a new entry even though it still was connected to the previous user.
Contributor guide
Assessment
This issue has not been assessed yet.