Changeset 4c9f29a in Klonkt for src/services/AudioEmbedService.js
- Timestamp:
- 06/15/2026 03:23:14 AM (3 months ago)
- Branches:
- main
- Children:
- 3e86f1c
- Parents:
- 650b601
- git-author:
- roboburr <roboburr@…> (06/15/2026 03:22:47 AM)
- git-committer:
- roboburr <roboburr@…> (06/15/2026 03:23:14 AM)
- File:
-
- 1 edited
-
src/services/AudioEmbedService.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/AudioEmbedService.js
r650b601 r4c9f29a 16 16 url = url.trim(); 17 17 18 // Alleen http(s)-URL's embedden. De provider-regexes hieronder zijn NIET 19 // verankerd, dus zonder deze check zou bv. `javascript:alert(1)//youtu.be/x` 20 // matchen en als embed-URL belanden (stored XSS via een [[embed:...]]- 21 // shortcode — die tekst gaat niet langs de HTML-sanitizer omdat 'ie in een 22 // text-node zit). De scheme-guard sluit javascript:/data:/vbscript: enz. uit. 23 if (!/^https?:\/\//i.test(url)) return null; 24 18 25 // Spotify 19 26 if (/open\.spotify\.com\/(track|album|playlist|episode|show)\/([A-Za-z0-9]+)/i.test(url)) { 20 27 const match = url.match(/\/(track|album|playlist|episode|show)\/([A-Za-z0-9]+)/i); 21 return { provider: 'spotify', type: match[1], id: match[2] };28 return { provider: 'spotify', type: match[1], id: match[2], url }; 22 29 } 23 30 … … 37 44 } 38 45 39 // YouTube 40 if (/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([A-Za-z0-9_-]{6,20})/i.test(url)) { 41 const match = url.match(/(?:v=|youtu\.be\/|embed\/)([A-Za-z0-9_-]{6,20})/i); 42 return { provider: 'youtube', id: match[1] }; 46 // YouTube — video-id is altijd exact 11 tekens (lijnt uit met de client-side 47 // ytId() in embed-player.js, die ook {11} verwacht). 48 if (/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/|youtube\.com\/shorts\/|youtube\.com\/live\/)([A-Za-z0-9_-]{11})/i.test(url)) { 49 const match = url.match(/(?:v=|youtu\.be\/|embed\/|shorts\/|live\/)([A-Za-z0-9_-]{11})/i); 50 return { provider: 'youtube', id: match[1], url }; 43 51 } 44 52 … … 46 54 if (/vimeo\.com\/(?:video\/)?(\d+)/i.test(url)) { 47 55 const match = url.match(/\d+/); 48 return { provider: 'vimeo', id: match[0] };56 return { provider: 'vimeo', id: match[0], url }; 49 57 } 50 58 … … 54 62 static generateIframe(provider, config) { 55 63 switch (provider) { 64 // Eigen custom-spelers (client-side via embed-player.js + de echte 65 // platform-API's). We renderen een placeholder met data-attributen i.p.v. 66 // het kale platform-iframe, zodat de embed in ÓNZE huisstijl verschijnt. 67 case 'youtube': 68 return this.embedPlaceholder('youtube', config.id, 'video', 69 config.url || `https://youtu.be/${config.id}`); 70 case 'soundcloud': 71 return this.embedPlaceholder('soundcloud', config.url, 'track', config.url); 56 72 case 'spotify': 57 return this.spotifyIframe(config); 73 return this.embedPlaceholder('spotify', `spotify:${config.type}:${config.id}`, 74 config.type, config.url || `https://open.spotify.com/${config.type}/${config.id}`); 75 // Geen JS-API (Bandcamp/Apple) of niet-prioritair (Vimeo): blijven een 76 // iframe; mutual-exclusion loopt voor deze via de blur-fallback. 58 77 case 'bandcamp': 59 78 return this.bandcampIframe(config); 60 case 'soundcloud':61 return this.soundcloudIframe(config);62 79 case 'applemusic': 63 80 return this.applemusicIframe(config); 64 case 'youtube':65 return this.youtubeIframe(config);66 81 case 'vimeo': 67 82 return this.vimeoIframe(config); … … 69 84 return null; 70 85 } 86 } 87 88 /** 89 * Placeholder voor een eigen custom-speler. embed-player.js pikt 90 * .folio-embed[data-embed-provider] op en bouwt de kaart + speler client-side. 91 * ALLE waarden via escape() — post.content_html wordt ongeescaped uitgevoerd. 92 */ 93 static embedPlaceholder(provider, ref, type, url) { 94 const attrs = [ 95 `data-embed-provider="${this.escape(provider)}"`, 96 `data-embed-ref="${this.escape(ref)}"`, 97 type ? `data-embed-type="${this.escape(type)}"` : '', 98 `data-embed-url="${this.escape(url)}"`, 99 ].filter(Boolean).join(' '); 100 return `<div class="folio-embed folio-embed--${this.escape(provider)} pcms-embed pcms-embed-card pcms-embed-loading" ${attrs}></div>`; 71 101 } 72 102
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)