In investigating a bug in GNOME Software I found that snapd sometimes returns JSON strings with newline characters as separators (\n
) and sometimes with carriage returns and newlines (\r\n
). This is very odd…
For example, /v2/find?name=atom
gives:
"description":"Atom is a free and open source text editor that is modern,\napproachable, and hackable to the core.\n",
and /v2/find?name=hiri
gives:
"description":"Hiri is an email client for Office 365 / Exchange / outlook.com / msn.com / hotmail.com / live.com. Basically all the Microsoft Email services :)\r\n\r\nHiri has full email, calendar and tasks functionality.\r\n\r\nHiri is a subscription service but you do have 14 days free to try it to see if you like it. \r\n\r\nVisit www.hiri.com for more information.","developer":"hiri","download-size":193998848,"icon":"https://dashboard.snapcraft.io/site_media/appmedia/2017/06/hiri-logo-256.png","id":"rqjJgJ4toGMPKL5GE86c1gbrYfX7R1I9"
If you query the store directly, you see the carriage returns coming from there:
$ http --json https://api.snapcraft.io/api/v1/snaps/details/hiri X-Ubuntu-Series:16 fields==description
HTTP/1.1 200 OK
Content-Length: 397
Content-Type: application/json
Date: Thu, 14 Sep 2017 08:39:05 GMT
Server: gunicorn/19.7.1
X-Request-Id: 8396f777-47bb-4d25-941b-f868d1b04f2a
X-VCS-Revision: 5f3da77
{
"description": "Hiri is an email client for Office 365 / Exchange / outlook.com / msn.com / hotmail.com / live.com. Basically all the Microsoft Email services :)\r\n\r\nHiri has full email, calendar and tasks functionality.\r\n\r\nHiri is a subscription service but you do have 14 days free to try it to see if you like it. \r\n\r\nVisit www.hiri.com for more information.",
"package_name": "hiri"
}
But the local snap metadata for Hiri has entirely different data:
$ cat /snap/hiri/current/meta/snap.yaml
apps:
hiri:
command: command-hiri.wrapper
plugs:
- x11
- unity7
- pulseaudio
- network
- opengl
- mount-observe
- home
- browser-support
architectures:
- amd64
confinement: strict
description: 'Email client, calendar and tasks for Exchange/Office 365
'
grade: stable
name: hiri
summary: Hiri email client
version: 1.2.1.0
So the question is, where are the carriage returns coming from? And can we stop them and standardise on \n
?