Ignore:
Timestamp:
07/16/2026 12:20:51 PM (8 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
e276d03
Parents:
8e7f0ec
git-author:
Robin <roboburr@…> (07/12/2026 10:30:07 PM)
git-committer:
Robin <roboburr@…> (07/16/2026 12:20:51 PM)
Message:

Fix: bare .webm/.mp4/.mp3 URLs render a native player

autoembed() and [[embed:]] now detect direct media-file URLs and emit a
<video>/<audio> element (was: left as a plain link). Sanitizer allows
video/audio/source with a tight attr + http(s)-scheme allowlist so
hand-authored and federated-in players survive. detectProvider() is left
untouched so the timeline/cover callers that switch on provider slugs are
unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/HtmlSanitizerService.js

    r8e7f0ec ra85f539  
    2525  'strong', 'em', 'b', 'i', 'u', 's', 'mark', 'small', 'sub', 'sup',
    2626  'code', 'a', 'span', 'img',
     27  // Native media (bare .webm/.mp4/.mp3 embeds + federated-in players)
     28  'video', 'audio', 'source',
    2729];
    2830
    2931// Per-tag attribute allowlist. '*' applies to every tag.
    3032const ALLOWED_ATTRS = {
    31   '*': ['class', 'id', 'dir', 'lang', 'data-sc'],
    32   a:   ['href', 'title', 'target', 'rel'],
    33   img: ['src', 'alt', 'title', 'width', 'height', 'loading'],
     33  '*':   ['class', 'id', 'dir', 'lang', 'data-sc'],
     34  a:     ['href', 'title', 'target', 'rel'],
     35  img:   ['src', 'alt', 'title', 'width', 'height', 'loading'],
     36  video: ['src', 'controls', 'preload', 'poster', 'width', 'height', 'loop', 'muted', 'autoplay', 'playsinline'],
     37  audio: ['src', 'controls', 'preload', 'loop', 'muted', 'autoplay'],
     38  source: ['src', 'type'],
    3439};
    3540
    3641const ALLOWED_SCHEMES = ['http', 'https', 'mailto', 'tel'];
    3742const ALLOWED_SCHEMES_BY_TAG = {
    38   img: ['http', 'https', 'data'],
    39   a:   ['http', 'https', 'mailto', 'tel'],
     43  img:    ['http', 'https', 'data'],
     44  a:      ['http', 'https', 'mailto', 'tel'],
     45  video:  ['http', 'https'],
     46  audio:  ['http', 'https'],
     47  source: ['http', 'https'],
    4048};
    4149
Note: See TracChangeset for help on using the changeset viewer.