Chocobozzz / PeerTube

ActivityPub-federated video streaming platform using P2P directly in your web browser
https://joinpeertube.org/
GNU Affero General Public License v3.0
13.09k stars 1.51k forks source link

ActivityPub `summary` field appears to be plaintext instead of the spec-required HTML #5476

Open BentonEdmondson opened 1 year ago

BentonEdmondson commented 1 year ago

Describe the current behavior

For an account (example), it looks like the summary field contains plaintext:

{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://w3id.org/security/v1",
    {
      "RsaSignature2017": "https://w3id.org/security#RsaSignature2017"
    },
    {
      "pt": "https://joinpeertube.org/ns#",
      "sc": "http://schema.org/",
      "playlists": {
        "@id": "pt:playlists",
        "@type": "@id"
      },
      "support": {
        "@type": "sc:Text",
        "@id": "pt:support"
      },
      "icons": "as:icon"
    }
  ],
  "type": "Person",
  "id": "https://video.blender.org/accounts/blender",
  "following": "https://video.blender.org/accounts/blender/following",
  "followers": "https://video.blender.org/accounts/blender/followers",
  "playlists": "https://video.blender.org/accounts/blender/playlists",
  "inbox": "https://video.blender.org/accounts/blender/inbox",
  "outbox": "https://video.blender.org/accounts/blender/outbox",
  "preferredUsername": "blender",
  "url": "https://video.blender.org/accounts/blender",
  "name": "Blender",
  "endpoints": {
    "sharedInbox": "https://video.blender.org/inbox"
  },
  "publicKey": {
    "id": "https://video.blender.org/accounts/blender#main-key",
    "owner": "https://video.blender.org/accounts/blender",
    "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3Dd8CgG6dpIncIkXjwpE\nTeNIvsIAoGyKLVexLSJMag46ZllakH1g4FEBiaFGF9H8uQFQQN2D7HO+1ilu6KCC\n2bU2W6yGF1LKeDBTDUZV0BDQYSqRemnWG43TlS2PbcJRcWfqVmXNq7rDHdZaReM6\n5iIC8ilSctadBkwyfecv+wRIphKUuHC3CJKu4FAEXuA1pUN1dccIQOHdDJ60AN5f\nRZngFj04U0PnyoSYZgs1ABxFVwP9E2oDWwgaOQxKGiEV0+IN44cRmiQSrQHoELDS\ngKXUF8zmYZuKWGV0H6RUZuA5aVHbxF8NV+w8nhBz7lJGOWy9POR85iQ970ATvPKR\ndwIDAQAB\n-----END PUBLIC KEY-----"  },
  "published": "2018-10-24T14:55:59.623Z",
  "icon": {
    "type": "Image",
    "mediaType": "image/png",
    "height": 120,
    "width": 120,
    "url": "https://video.blender.org/lazy-static/avatars/27090054-f64c-4430-b8e3-875fcf2a5891.png"
  },
  "icons": [
    {
      "type": "Image",
      "mediaType": "image/png",
      "height": 48,
      "width": 48,
      "url": "https://video.blender.org/lazy-static/avatars/7721ca74-c24a-4592-9080-437418ffb820.png"
    },
    {
      "type": "Image",
      "mediaType": "image/png",
      "height": 120,
      "width": 120,
      "url": "https://video.blender.org/lazy-static/avatars/27090054-f64c-4430-b8e3-875fcf2a5891.png"
    }
  ],
  "summary": "Blender is the free and open source 3D creation suite. \n\nIt supports the entirety of the 3D pipeline—modeling, rigging, animation, simulation, rendering, compositing and motion tracking, even video editing and game creation.  \n\nBlender is well suited to individuals and small studios who benefit from its unified pipeline and responsive development process."
}

I believe it is to be interpreted as plaintext because the newlines are rendered as-is, whereas if they were rendered as HTML, they would be collapsed:

image

Steps to reproduce

curl -H "Accept: application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"" https://video.blender.org/a/blender/video-channels | jq

Describe the expected behavior

The spec says summary must be

A natural language summarization of the object encoded as HTML.

Solutions

  1. Encode it as HTML
  2. Set mediaType to text/plain to signify that it should be rendered as plaintext. Even though the spec says mediaType only describes the content field, I prefer this option; it seems weird to me that there would be no way to serve summary as non-text/html. And since content is pretty much always absent on actors, I think this is fine.

Additional information

The example is https://video.blender.org/accounts/blender but the problem seems to exist universally.

Chocobozzz commented 1 year ago

Also related to https://github.com/Chocobozzz/PeerTube/issues/2488