Repository Public
1#!/bin/bash2# Regenerates the preview fixtures (macOS: sips, ffmpeg, LibreOffice; exceljs from services/api). Run from anywhere.3set -euo pipefail4cd "$(dirname "$0")"5ROOT="$(cd ../../.. && pwd)"6SOFFICE=/Applications/LibreOffice.app/Contents/MacOS/soffice7FFMPEG=/opt/homebrew/bin/ffmpeg8TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT910# PDF: 3 pages, the word "marmotte" 5 times (2 + 1 + 2)11node --input-type=module -e "12import { writeFileSync } from 'node:fs';13import { makePdf } from './pdf-gen.mjs';14writeFileSync('sample.pdf', makePdf([15 ['SP Drive - page un', 'La marmotte dort sous la neige.', 'Une autre Marmotte veille pres du terrier.'],16 ['SP Drive - page deux', 'Le castor construit un barrage.', 'La marmotte observe le castor.'],17 ['SP Drive - page trois', 'Derniere page du document.', 'MARMOTTE et marmotte, encore.'],18]));"1920# images: PNG and JPEG drawn by ffmpeg, HEIC by sips21"$FFMPEG" -loglevel error -y -f lavfi -i "testsrc2=size=320x240:rate=1" -frames:v 1 sample.png22"$FFMPEG" -loglevel error -y -f lavfi -i "smptebars=size=640x360:rate=1" -frames:v 1 -q:v 4 sample.jpg23sips -s format heic sample.png --out sample.heic >/dev/null2425# SVG that tries to run script three ways26cat > hostile.svg <<'SVG'27<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 200 120" width="200" height="120" onload="window.__pwned = 1; fetch('/api/v1/__pwned?via=svg-onload')">28 <rect width="200" height="120" fill="#2456e6"/>29 <circle cx="100" cy="60" r="36" fill="#ffd34d"/>30 <script>window.__pwned = 1; top.__pwned = 1; fetch('/api/v1/__pwned?via=svg-script');</script>31 <image href="/api/v1/__pwned?via=svg-image" width="1" height="1"/>32 <foreignObject width="1" height="1"><img xmlns="http://www.w3.org/1999/xhtml" src="x" onerror="window.__pwned = 1"/></foreignObject>33</svg>34SVG3536# video and audio: one second each37"$FFMPEG" -loglevel error -y -f lavfi -i "testsrc2=size=320x180:rate=15" -f lavfi -i "sine=frequency=440:sample_rate=44100" -t 1 -c:v libx264 -pix_fmt yuv420p -profile:v baseline -c:a aac -b:a 48k -movflags +faststart sample.mp438"$FFMPEG" -loglevel error -y -f lavfi -i "sine=frequency=523:sample_rate=44100" -t 1 -c:a libmp3lame -b:a 48k sample.mp33940# text family41printf 'Premiere ligne\nDeuxieme ligne avec une tres longue suite de mots pour verifier le retour a la ligne dans la visionneuse de texte de SP Drive, encore et encore et encore, puis encore une fois pour depasser la largeur d un grand ecran de bureau sans le moindre doute possible, et un peu plus loin pour faire bonne mesure.\n\n<script>window.__pwned = 1</script>\n\tindentation\nDerniere ligne\n' > sample.txt42cat > hostile.md <<'MD'43# Titre du document4445Un paragraphe avec du **gras**, de l'*italique* et du `code`.4647<script>window.__pwned = 1; fetch('/api/v1/__pwned?via=md-script');</script>4849<img src="x" onerror="window.__pwned = 1">5051<iframe src="javascript:parent.__pwned = 1"></iframe>5253[lien piege](javascript:window.__pwned=1) et [lien sain](https://example.org/page).5455<a href="javascript:window.__pwned=1" onclick="window.__pwned=1">ancre brute</a>56575859<div style="background:url(/api/v1/__pwned?via=md-style)">style</div>6061- un62- deux6364| A | B |65|---|---|66| 1 | 2 |67MD68printf 'nom,ville,note\r\n"Tremblay, Luc",Gatineau,"Il a dit ""bonjour"""\r\n"Roy; Anne","Québec","ligne 1\nligne 2"\r\nSimple,Hull,ok\r\n' > sample.csv69printf 'nom;montant\n"Gagnon; Paul";12,50\nCote;7,25\n' > semicolon.csv70cat > sample.json <<'JSON'71{"titre": "SP Drive", "version": 3, "actif": true, "vide": null, "tags": ["alpha", "beta"], "auteur": {"nom": "Marmotte", "contact": {"ville": "Gatineau"}}}72JSON73printf '{"cassé": [1, 2, \n' > broken.json74cat > sample.xml <<'XML'75<?xml version="1.0" encoding="UTF-8"?>76<catalogue><livre id="1"><titre>Le castor</titre></livre><script>window.__pwned = 1</script></catalogue>77XML7879# office documents through LibreOffice80cat > "$TMP/lettre.html" <<'HTML'81<html><body><h1>Rapport Castor</h1><p>Ce document Word contient le mot ornithorynque.</p></body></html>82HTML83"$SOFFICE" --headless --convert-to 'docx:MS Word 2007 XML' --outdir "$TMP" "$TMP/lettre.html" >/dev/null 2>&184cp "$TMP/lettre.docx" sample.docx85cat > "$TMP/diapos.fodp" <<'FODP'86<?xml version="1.0" encoding="UTF-8"?>87<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.presentation">88 <office:body><office:presentation>89 <draw:page draw:name="un"><draw:frame svg:x="2cm" svg:y="2cm" svg:width="20cm" svg:height="3cm"><draw:text-box><text:p>Diapositive Quokka</text:p></draw:text-box></draw:frame></draw:page>90 <draw:page draw:name="deux"><draw:frame svg:x="2cm" svg:y="2cm" svg:width="20cm" svg:height="3cm"><draw:text-box><text:p>Seconde diapositive</text:p></draw:text-box></draw:frame></draw:page>91 </office:presentation></office:body>92</office:document>93FODP94"$SOFFICE" --headless --convert-to pptx --outdir "$TMP" "$TMP/diapos.fodp" >/dev/null 2>&195cp "$TMP/diapos.pptx" sample.pptx9697# a PDF that needs a password to open ("secret")98echo '<html><body><p>secret castor</p></body></html>' > "$TMP/locked.html"99"$SOFFICE" --headless --convert-to 'pdf:writer_web_pdf_Export:{"EncryptFile":{"type":"boolean","value":"true"},"DocumentOpenPassword":{"type":"string","value":"secret"}}' --outdir "$TMP" "$TMP/locked.html" >/dev/null 2>&1100cp "$TMP/locked.pdf" locked.pdf101102# workbook with two sheets (exceljs lives in services/api)103(cd "$ROOT/services/api" && OUT="$OLDPWD/sample.xlsx" node --input-type=module -e "104import ExcelJS from 'exceljs';105const wb = new ExcelJS.Workbook();106const a = wb.addWorksheet('Ventes');107a.addRow(['Produit', 'Quantite', 'Prix']); a.addRow(['Sirop', 12, 8.5]); a.addRow(['Tuque', 3, 24]); a.addRow(['Total', { formula: 'B2+B3', result: 15 }, '']);108const b = wb.addWorksheet('Clients');109b.addRow(['Nom', 'Ville']); b.addRow(['Castor Bricoleur', 'Gatineau']);110await wb.xlsx.writeFile(process.env.OUT);")111112# archives with nested paths113mkdir -p "$TMP/arc/docs/notes/2026" "$TMP/arc/images"114echo 'bonjour' > "$TMP/arc/lisezmoi.txt"; echo 'note profonde' > "$TMP/arc/docs/notes/2026/secret.txt"; echo 'rapport' > "$TMP/arc/docs/rapport.txt"; cp sample.png "$TMP/arc/images/photo.png"115(cd "$TMP/arc" && zip -qr "$OLDPWD/sample.zip" . -x '.*' && COPYFILE_DISABLE=1 tar czf "$OLDPWD/sample.tar.gz" lisezmoi.txt docs images)116117# an unsupported type118head -c 2048 /dev/urandom > sample.bin119ls -la120