Commit Graph
142 Commits
Author SHA1 Message Date
hazre 3bb692fdb0 Merge branch 'dev' of github.com:SableClient/Sable into hazre/feat/arborium-migration
# Conflicts:
#	src/app/plugins/react-custom-html-parser.test.tsx
#	src/app/plugins/react-custom-html-parser.tsx
#	src/app/utils/sanitize.test.ts
#	src/app/utils/sanitize.ts
2026-03-30 23:30:29 +02:00
7w1 4d2fcfccbe fix: harden Matrix HTML sanitization (#571)
### Description

- switch Matrix custom HTML sanitization from `sanitize-html` to
`DOMPurify`
- enforce the Matrix v1.18 tag and attribute allowlist exactly,
including scheme and `mxc://` restrictions
- sanitize reply previews before trimming/parsing so untrusted
`formatted_body` never reaches the reply extraction path unsanitized
- move `data-mx-color` and `data-mx-bg-color` translation to render time
and explicitly ignore incoming `style` in the HTML parser
- use `sanitizeText` for plain-text interpolation paths that were
previously running through the HTML sanitizer
- add regression tests for sanitizer allowlist behavior, reply preview
sanitization, parser color translation, and parser-side style stripping

#### Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings

### AI disclosure:

- [ ] Partially AI assisted (clarify which code was AI assisted and
briefly explain what it does).
- [x] Fully AI generated (explain what all the generated code does in
moderate detail).

This PR replaces the Matrix custom HTML sanitizer with a DOMPurify-based
implementation that matches the Matrix v1.18 allowlist instead of the
broader legacy rules. The sanitizer now validates tag-specific
attributes, rejects incoming `style`, limits links to
`https/http/ftp/mailto/magnet`, limits images to `mxc://`, strips
`mx-reply`, and keeps the existing nesting guard. Reply previews now
sanitize `formatted_body` before any reply trimming or parsing. The
React HTML parser now turns `data-mx-color` and `data-mx-bg-color` into
React styles at render time and ignores raw incoming `style` attributes
even if unsanitized HTML somehow reaches the parser. The plain-text HTML
interpolation paths in forwarding, the room composer, and the message
editor now use text escaping instead of the HTML allowlist sanitizer.
The new tests lock down the sanitizer contract, the reply-preview
regression, parser color translation, and parser-side style stripping.
2026-03-30 02:50:05 +00:00
hazre 153a4903d3 fix: default dark code block theme to dracula 2026-03-30 00:03:57 +02:00
hazre fb1732ce82 fix: harden MXC image rendering and simplify HTML paths 2026-03-29 23:42:17 +02:00
Rye dae8e6ac29 fix(PMP, ID): changed pmp id handling and generation 2026-03-29 03:29:56 +02:00
hazre 0f7a28bf42 refactor: split code block themes into their own section 2026-03-28 22:36:32 +01:00
hazre 13bf74da87 feat: add system and manual code block theme modes 2026-03-28 20:45:50 +01:00
hazre 26755262cd feat: add reusable settings selectors and code block themes 2026-03-28 20:02:00 +01:00
hazre 149550639c Merge remote-tracking branch 'origin/dev' into hazre/fix/matrix-html-sanitization
# Conflicts:
#	src/app/components/message/Reply.tsx
#	src/app/features/room/RoomInput.tsx
2026-03-28 17:33:33 +01:00
hazre ee1b718737 fix: harden Matrix HTML sanitization 2026-03-28 17:11:25 +01:00
hazre 9a15cafc02 fix: trust arborium availability for unsupported labels 2026-03-27 12:37:56 +01:00
hazre 240ced593e fix: add arborium language compatibility mapping 2026-03-27 12:31:55 +01:00
hazre 575c4f96fb refactor: replace prism text highlighting with arborium 2026-03-27 12:31:55 +01:00
hazre 428505cc21 fix: preserve structured code blocks in parser 2026-03-27 12:31:55 +01:00
hazre bfdda68483 fix: handle whitespace in code block language lookup 2026-03-27 12:31:55 +01:00
hazre f804f07a3c feat: render message code blocks with arborium 2026-03-27 12:31:55 +01:00
hazre dda1be44be fix: use arborium dist theme urls 2026-03-27 12:31:54 +01:00
hazre 9148978326 feat: add arborium theme bridge 2026-03-27 12:31:54 +01:00
hazre bce5b50a24 fix: treat escaped arborium output as plain 2026-03-27 12:31:54 +01:00
hazre 0e0290f557 fix: align arborium runtime api with spec 2026-03-27 12:31:54 +01:00
hazre 286b85c434 fix: align arborium runtime api with spec 2026-03-27 12:31:54 +01:00
hazre c78beb8cb5 feat: add arborium runtime wrapper 2026-03-27 12:31:54 +01:00
Rye 0c7911cbf8 fix: remove unused files and added fallback for regex escaping 2026-03-27 02:32:41 +01:00
Rose 523fcbbc9f Merge branch 'dev' into feat/compat/pluralkit 2026-03-27 01:39:39 +01:00
7w1 95cdfa1b23 feat: room abbreviations with hover tooltips and space inheritance (#514)
<!-- Please read
https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before
submitting your pull request -->

### Description

Adds a room abbreviations feature: moderators can define term/definition
pairs in room settings. Defined terms are highlighted with a dotted
underline in messages and show a tooltip on hover (tap-to-pin on
mobile). Abbreviations defined in a parent space are inherited by child
rooms and nested spaces, with overrides allowed at each level. The
settings UI shows a flat list of inherited and locally-defined entries.

Fixes #

#### Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings

### AI disclosure:

- [ ] Partially AI assisted (clarify which code was AI assisted and
briefly explain what it does).
- [X] Fully AI generated (explain what all the generated code does in
moderate detail).

<!-- Write any explanation required here, but do not generate the
explanation using AI!! You must prove you understand what the code in
this PR does. -->

The code adds changes that allow for setting and viewing room
abbreviations, with an on-hover tooltip (or press on mobile -
semi-persistent). It stores these in the room state under a new key, and
recursively fetches abbreviations from the space level. This also adds
regex so that abbreviations correctly work at word boundaries. Also adds
the needed hooks to `room.ts` and `slidingSync.ts`
2026-03-26 21:18:00 +00:00
Rye 2a4fd48af9 feat(PMP-PK): added more options (removing shorthand,...) and documentation 2026-03-26 19:47:59 +01:00
Rye ba18d25bc2 fix(pk-compat-proxy): extracting message from proxied message 2026-03-26 14:39:44 +01:00
Rye 5f22d86a04 feat(pkit-compat): some steps towards recognizing proxies, not entirely there yet 2026-03-26 07:38:37 +01:00
Rye 3f706fe63a feat(pk-integration): added some simple, member related commands people might expect when comming from pluralkit 2026-03-26 00:59:29 +01:00
Evie Gauthier bf9deae8a1 fix(abbreviations): fix lint, typecheck, and format errors 2026-03-25 12:49:18 -04:00
Evie Gauthier 18a7ca092b fix(abbreviations): highlight terms in HTML-formatted messages
Previously, abbreviation term highlighting was skipped for any message
that has a formatted_body (virtually all messages from modern clients
using a rich-text editor), because RenderBody returned early from the
customBody path before reaching the abbreviation logic.

The fix adds an optional replaceTextNode callback to
getReactCustomHtmlParser. Since opts closes over itself, renderChildren
inside element handlers recurses through the same replace function, so
text nodes nested inside <p>, <strong>, <em>, list items, etc. are all
processed correctly.

buildAbbrReplaceTextNode is exported from RenderBody.tsx and wired
into both RoomTimeline and ThreadDrawer via useRoomAbbreviationsContext.
2026-03-25 12:13:21 -04:00
hazre f24cf52378 chore: merge dev into hazre/fix/sidebar-count-badge-positioning 2026-03-25 15:47:50 +01:00
hazre b7f9b851ff refactor: replace millify with Intl compact formatter 2026-03-25 15:26:32 +01:00
7w1 418fe2cc1a unduplicate code 2026-03-24 09:56:13 -05:00
7w1 7a6c74eeee decode urls safely! 2026-03-24 09:45:14 -05:00
7w1 4fbcfef90d feat: add editor multiline mode and many edge case fixes (#476)
### Description

Fixes #350

This adds a dynamic multiline layout to `CustomEditor`. When the message
input grows past a single line (word wrap, explicit newlines, or
multiple blocks), the editor shifts from a single-row layout into a
two-row grid, before/textarea on top, with responsive content spanning
the full width below. It drops back to single-row once the text fits on
one line again.

The old `replacementContent` prop (which swapped out the textarea on
mobile during voice recording) is gone. It's replaced by
`responsiveAfter`, which renders inline next to the send button in
single-line mode and moves down to the footer row in multiline mode.
There's also a `forceMultilineLayout` prop for when you want to push
into multiline immediately, which is what we use when the audio recorder
opens. This means the recorder now takes the same code path on desktop
and mobile instead of having a separate mobile-only branch.

A few other things got fixed along the way:

- Holding the record button on mobile was selecting the "following the
conversation" text underneath it. Fixed with `userSelect: none`.
(related to #350)
- The stop button's `onClick` was being skipped on mobile entirely, so
if `pointerup` got lost mid-drag there was no way to stop recording. Now
`onClick` works as a fallback when recording is already active. (a form
of recovery in case more situations like #350 happen again)
- The waveform bar count is now calculated from the actual container
width via `ResizeObserver` instead of a hardcoded number.
- `cleanupMediaRecorder` wasn't being called in all the
stop/delete/restart/error/unmount paths, which could leave the mic track
open. That's fixed.
- Firefox couldn't seek voice messages because `audio/webm` doesn't
include a seek index. Codec preference now puts `audio/ogg;codecs=opus`
first so Firefox records seekable blobs. Also added a `seekTo` helper
that waits for `loadedmetadata` if the audio element isn't ready yet,
and `audio.preload = 'auto'` + `audio.load()` on mount so Firefox parses
metadata right away.
- Multiline wrap detection is now debounced through
`requestAnimationFrame` and uses a `ResizeObserver` on the scroll
container to cut down on flicker and extra re-renders.
- Added cloudflared tunnels for easier testing on mobile

Also sorry for the cursed line height measurer, there was legit no other
way to detect it that didn't cause other issues.

Good amount of this was created with help of AI (like figuring out
options on how to fix the edge cases), especially the edge case unit
tests, but It had to be fixed by hand in many places and frankly I can't
tell you exactly where was what. I've been working on this for couple
days now.. (losing my mind over it)

### Screenshots:

https://github.com/user-attachments/assets/bcff3766-6c60-46c7-ac9e-a8b943a665d3

https://github.com/user-attachments/assets/367cdcc4-666e-4324-8e81-1b415feb0aca

#### Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings

### AI disclosure:

- [x] Partially AI assisted (clarify which code was AI assisted and
briefly explain what it does).
- [ ] Fully AI generated (explain what all the generated code does in
moderate detail).
2026-03-23 04:02:36 +00:00
Rawrington 525d3e311d i forgot typescript is evil sometimes 2026-03-23 00:53:01 +00:00
Rawrington 2283cd6711 Small refactor. JoinExisting works for starting a call/joining a voice room. 2026-03-22 23:54:19 +00:00
Rawrington a3fda5a13c Silly CallIntent for video auto turning on 2026-03-22 22:54:40 +00:00
hazre e5d52300b5 docs: clarify editor and recorder internals 2026-03-22 19:18:52 +01:00
hazre 2af3c72e30 fix: voice message preview seeking not working on firefox 2026-03-22 18:13:09 +01:00
hazre 340d643233 fix: fully tear down voice recorder audio graph 2026-03-22 18:13:09 +01:00
Rye a842bce6e1 stub: add PluralKit command message handler and data models 2026-03-18 15:05:43 +01:00
hazre 35e842f768 fix: simplify mobile stuff 2026-03-17 18:54:18 +01:00
hazre f81fdd38af chore: merge dev into nyxsutsn 2026-03-17 18:54:18 +01:00
Evie Gauthier 2ee72702e6 Merge pull request #314 from SableClient/fix/matrix-to-custom-base
fix: support custom matrix.to base URL via config
2026-03-17 03:04:28 +00:00
Evie Gauthier 55fd9bbc7e style(matrix-to): fix prettier formatting in test file 2026-03-16 21:51:39 -04:00
Evie Gauthier edc1c67ecf test(matrix-to): add unit tests; fix setMatrixToBase reset, http support, room regex 2026-03-16 21:43:51 -04:00
7w1 687d6721ce Merge pull request #127 from melogale/dev
Bring in sable-call!
2026-03-17 01:33:17 +00:00
melogale b224d936c4 final fix 2026-03-16 21:18:37 -04:00