escape app name to account for special characters in name (closes #1252) (#1268)

Summary:
App Names can contain special characters. Escape them (and unescape later) so that device ID strings don't break.

Simpler is better - thanks to mweststrate for keeping me out of the rabbit hole
## Changelog

Escape app name to account for special characters in name
Pull Request resolved: https://github.com/facebook/flipper/pull/1268

Test Plan:
Added test to test character escaping: `cd desktop && yarn test -- -i app/src/utils/__tests__/clientUtils.node.tsx`

closes https://github.com/facebook/flipper/issues/1252

Reviewed By: passy

Differential Revision: D22066263

Pulled By: jknoxville

fbshipit-source-id: c820d055700ca6f55d35265528ce874eeb159216
This commit is contained in:
Jason Moore
2020-06-16 06:04:04 -07:00
committed by Facebook GitHub Bot
parent 96645a21b1
commit fec52a3989
2 changed files with 22 additions and 2 deletions

View File

@@ -48,3 +48,21 @@ test('client id deconstruction error logged', () => {
});
expect(consoleErrorSpy).toHaveBeenCalledTimes(1);
});
test('special characters in app name handled correctly', () => {
const consoleErrorSpy = jest.spyOn(global.console, 'error');
const testClient = {
app: '#myGreat#App&',
os: 'iOS',
device: 'iPhone Simulator',
device_id: 'EC431B79-69F1-4705-9FE5-9AE5D96378E1',
};
const clientId = buildClientId(testClient);
const deconstructedClientId = deconstructClientId(clientId);
expect(deconstructedClientId).toStrictEqual(testClient);
expect(consoleErrorSpy).toHaveBeenCalledTimes(0);
});