Snap metadata newline characters


#1

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?


#2

My guess is that they’re coming from when people edit these things in the web browser. Web browsers seem to send DOS-style line endings, and I would not be surprised if the store is simply preserving them.


#3

You’re right Conan. The section of text with all of the carriage returns was edited in a browser. That text was composed on dashboard.snapcraft.io.

I edited the Hiri description (in question above) a few minutes ago to see if I had somehow added additional characters into the description that shouldn’t be there. No luck, it seems the carriage returns are being added somewhere else.


#4

@natalia, if this is the case, would it be reasonable for the store to process the form input and remove the carriage returns?


#5

Hi @robert.ancell!

Sure, we can look into this. Would you please file a bug in the snapstore LP project?

Thank you.


#6

Filed https://bugs.launchpad.net/bugs/1717830


#7

FYI, a fix was released to normalize line-endings in the store web forms. From now on, updates to the description made in the web will use ‘\n’ instead of ‘\r\n’ for newlines.