nadar/quill-delta-parser
A PHP library that parses Quill WYSIWYG editor Delta JSON into sanitized HTML. Every element is handled by the same flexible, extendable mechanism, making custom elements easy to add, output safer, and the parser simple to understand and customize. Install via Composer.
Size listener for font-size attributes (3.7.0) expands compatibility with Quill.js’s formatting modules, making it more suitable for:
link, image, and video attributes at the listener layer. Architecturally this is the right place — validation happens at render time, before values reach href/src — but it shifts responsibility: the package is now a partial sanitizer, not a dumb transformer.$safeSchemes public property reinforce a modular architecture that supports policy injection per deployment (e.g., allow ftp in an internal DAM tool, deny it in a public marketing CMS).font-size values (e.g., convert px to rem for consistency).$safeSchemes is a natural fit for a Laravel config file (config/quill.php → quill.safe_schemes) bound via a service provider, keeping policy out of application code.Size listener and the scheme allowlist check are minimal, preserving the package’s low overhead.symfony/process 5.4.51, phpunit 8.5.52) — dev/transitive, no runtime impact.font-size support now covers a common Quill formatting op, reducing pre-processing needs.# for links, suppressed output for images/videos). Existing stored Deltas are not migrated or rewritten — the change is applied at parse/render time only.font-size attributes, enabling CSS overrides and responsive adjustments.image/video with unsafe schemes is dropped entirely rather than degraded — this can silently remove media from previously working content.| Risk Area | Mitigation Strategy | Update for 3.7.1 |
|---|---|---|
| Stored XSS (URI schemes) | Sanitize output HTML; validate attribute values. | Resolved in-package (GHSA-q7wv-vg5w-462j): link/image/video schemes validated against an allowlist. Upgrade is mandatory for any deployment rendering user-supplied Deltas. |
| Stored XSS (other vectors) | Sanitize output HTML. | Partially mitigated only. The fix covers URI schemes, not style/font-size/color attribute values or element/class injection. CSS-injection and style-based exfiltration remain the application’s responsibility — keep an HTML sanitizer on the render path. |
| Delta Schema Drift | Validate input Delta structure. | Unchanged from 3.7.0: Validate font-size values (numeric/valid CSS units). |
| Behavioral Regression (custom schemes) | Audit existing content; configure $safeSchemes. |
New: Deployments relying on ftp://, custom app schemes, or signed asset URLs will break. Enumerate legacy schemes before upgrading. |
| Performance | Benchmark with large Deltas; cache parsed HTML. | New: Allowlist check is a string comparison per attribute — negligible. However, see caching caveat below. |
| Custom Element Support | Test edge cases (e.g., nested custom elements). | No change. |
| Quill Version Mismatch | Document supported Delta ops versions. | No change (Quill v2.3.4+ for font-size). |
| Patch-Branch Fragmentation | Pin to a supported minor; track advisories. | New: Fix was backported to the 3.5.1 line (PR #106). Confirm which branches still receive fixes; plan to consolidate on 3.7.x to avoid maintaining multiple versions. |
font-size for responsive typography (e.g., mobile/desktop adjustments)?font-size units (e.g., convert px to em for consistency)?Size listener to support custom CSS variables (e.g., --font-size-base)?font-size parsing impact real-time collaborative editing (e.g., Google Docs-like apps)?ftp, tel, mailto, deep links, CDN-signed URLs)? This defines your $safeSchemes policy.font-size parsing with invalid values (e.g., "invalid", null).font-size ops (e.g., nested headings).javascript:, data:, vbscript:, mixed-case (JaVaScRiPt:), and whitespace/entity-obfuscated scheme payloads across link, image, and video.$safeSchemes override.<img>/<video> shell.font-size in Delta payloads (e.g., from Quill.js API calls).font-size into Blade templates or API responses.font-size or apply utility classes.$safeSchemes into config/quill.php and register listeners in a QuillServiceProvider so security policy is reviewable and environment-specific (strict in production, permissive in internal tools).Size module:
const quill = new Quill('#editor', {
modules: { size: true },
theme: 'snow'
});
font-size changes via Laravel Echo/Pusher.composer require nadar/quill-delta-parser:^3.7.1 and deploy. Treat as a security release, not a routine bump.composer audit in CI and add it to the pipeline if not already present."link", "image", "video" keys).$link = new Link();
$link->safeSchemes = ['http', 'https', 'mailto', 'tel', 'ftp'];
$lexer->overwriteListener(new Link(), $link);
rendered_html column, still contains the vulnerable markup. Purge and re-render, or backfill by re-parsing stored Deltas. Upgrading the package alone does not remediate the datastore.font-size parsing and scheme validation in a non-critical feature (e.g., blog post editor).font-size support.font-size ops.font-size (if needed).font-size (e.g., 16px) if parsing fails.font-size values (e.g., "100%" → sanitize to "1rem").warning) every neutralized URI scheme with content ID, so blocked-media regressions are measurable rather than anecdotal.| Component | Compatibility Notes | Update for 3.7.1 |
|---|---|---|
| PHP Version | Unchanged (PHP 8.1+). | No change. |
| Quill.js | Requires Quill v2.3.4+ for font-size module. |
No change. |
| Laravel Versions | Unchanged (Laravel 8+). | No change. |
| Custom Elements | Unchanged. | No change. |
| CSS Frameworks | Integrate with Tailwind/Laravel Mix for font-size utilities. |
No change. |
| Custom URI Schemes | Not previously relevant. | Behavioral break: ftp:// and other non-allowlisted schemes now render as # (links) or are dropped (images/videos). Requires explicit $safeSchemes opt-in. |
| Patch Level | — | New: Fix also backported to 3.5.1 (PR #106). Pin explicitly (^3.7.1) to avoid resolving to an unpatched range. |
font-size/Size listener work, so a security rollback can't be entangled with a feature regression.composer require nadar/quill-delta-parser:^3.7.1.Size module.$safeSchemes from config.font-size:
$html = $parser->parse($deltaWithFontSize);
<div class="prose">{{ $html }}</div>
font-size: Extend the parser to convert px to rem:
$parser->extend(function ($node) {
if ($node->getAttribute('font-size')) {
$node->setAttribute('style', 'font-size: ' . pxToRem($node->getAttribute('font-size')) . ';');
}
});
font-size (e.g., "auto", "inherit").mews/purifier) for style/class attributes, since 3.7.1 does not cover them.font-size for static content — but only after the cache purge in migration step 3.font-size parsing is CPU-intensive (unlikely).font-size module changes.Size/Link/Image/Video listeners must be re-verified against each patch — listener overwrites are the most likely upgrade casualty.font-size parsing warnings for invalid values.Size listener logic.font-size listener; prioritize testing if critical.PR #107), so any tooling parsing CHANGELOG.md internally will break.font-size).font-size parsing in large Deltas (e.g., 10K ops with nested sizes).font-size may increase size; compress if needed.| Failure Scenario | Impact | Mitigation | Update for 3.7.1 |
|---|---|---|---|
| Stored XSS via URI scheme | Account/session compromise, admin-context escalation | Validate/sanitize output HTML. | Resolved in 3.7.1 via allowlist; requires upgrade and cache purge to fully remediate. |
| XSS via style/class attributes | CSS injection, data exfiltration, UI redress | Sanitize output HTML. | New: Not covered by 3.7.1 — retain an application-level sanitizer for style, class, font-size, and color. |
| Malformed Delta Input | Parsing errors, crashes | Validate font-size values. |
New: Reject non-numeric/valid CSS units (e.g., "100%" → sanitize to "1rem"). |
| Legacy custom scheme links | Dead links, missing media, user complaints | Configure $safeSchemes; audit content. |
New: Enumerate stored schemes pre-upgrade; monitor neutralization logs post-upgrade. |
| Stale cached HTML | Vulnerability persists after patch | Purge response/object cache; re-render. | New: Highest-likelihood "we patched but are still exploitable" failure. Gate the release on cache invalidation. |
| Listener overwrite drift | Custom renderers bypass allowlist | Re-apply $safeSchemes to overwritten listener instances. |
New: Any overwriteListener call replaces the hardened default — verify each one. |
How can I help you explore Laravel packages today?