googleapis / googleapis/google-api-nodejs-client

Please remove Byte Order Mark returned from drive's `export` in `'text/plain'` format

Open
#2,404 1 comment 0 reactions 1 assignee Claimed by @sofisl View on GitHub
external priority: p2 type: bug
Dominant language
TypeScript
Stars
12.2k
Forks
2k
Avg merge
1d 9h
Merged PRs (30d)
24

Description

1) Is this a client library issue or a product issue?

Client library issue

2) Did someone already solve this?

no

3) Do you have a support contract?

no

#### Environment details

- OS: Linux 5.4 Ubuntu 18.04.5 LTS (Bionic Beaver)
- Node.js version: 14.4.0
- npm version: 6.14.5
- `googleapis` version: 61.0.0

#### Steps to reproduce

1. Make a create request, using for the `body` a string that does **not** begin with a [Byte Order Mark](https://www.unicode.org/charts/PDF/UFE70.pdf) and a `mimeType` of `'text/plain'`, such as
```
const requestBody = {
name,
parents: [folderId],
mimeType: 'application/vnd.google-apps.document',
};
const media = {
mimeType: 'text/plain',
body: 'foo', // <--- This string doesn't have a BOM.
};
const data = await drive.files.create({
requestBody,
media,
fields: 'id',
});
```
2. Make an export request of the previously created file with the `mimeType` set to `'text/plain'`, such as
```
const { data } = await drive.files.export({
fileId: id,
mimeType: 'text/plain',
});
```
3. The value `data.content` will contain a string that starts with a Byte Order Mark, `"\uFFEFfoo"`, which was not in the original string.

Being the BOM an invisible character, it is increadibly hard to spot. This makes [tests](https://github.com/facebook/jest/issues/10584) and application code harder to develop.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.