Potential fix for outdated firefox and some safari browsers not being able to send messages (#1010)

<!-- Please read
https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before
submitting your pull request -->

### Description

<!-- Please include a summary of the change. Please also include
relevant motivation and context. List any dependencies that are required
for this change. -->

Swaps a foreach to a for loop and some general hardening in the input
box related things.
No clue if this will work
fixes #1008 and fixes #557 

#### 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:

- [ ] My code follows the style guidelines of this project
- [ ] 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
- [ ] My changes generate no new warnings

### AI disclosure:

- [ ] 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).
<!-- 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. -->
This commit is contained in:
7w1 authored and GitHub committed 2026-07-01 21:36:42 -05:00
commit ef722ab259
2 files changed
+13 -10

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
default: patch
---
Fixed outdated Firefox versions and some Safari versions not being able to send messages.
+8 -10
View File
@@ -74,11 +74,11 @@ const elementToCustomHtml = (
return sanitizeText(matrixTo);
}
case BlockType.Emoticon:
return node.key.startsWith('mxc://')
return node.key?.startsWith('mxc://')
? `<img data-mx-emoticon src="${node.key}" alt="${sanitizeText(
node.shortcode
)}" title="${sanitizeText(node.shortcode)}" height="32" />`
: sanitizeText(node.key);
: sanitizeText(node.key ?? '');
case BlockType.Link:
return testMatrixTo(node.href)
? sanitizeText(node.href)
@@ -111,10 +111,9 @@ export const toMatrixCustomHTML = (
// strip nicknames if needed
if (opts.stripNickname && opts.nickNameReplacement) {
opts.nickNameReplacement?.keys().forEach((key) => {
const replacement = opts.nickNameReplacement!.get(key) ?? '';
for (const [key, replacement] of opts.nickNameReplacement) {
line = line.replaceAll(key, replacement);
});
}
}
markdownLines += line;
if (index === targetNodes.length - 1) {
@@ -145,7 +144,7 @@ const elementToPlainText = (node: CustomElement, children: string): string => {
case BlockType.Mention:
return node.name === '@room' ? node.name : node.id;
case BlockType.Emoticon:
return node.key.startsWith('mxc://') ? `:${node.shortcode}:` : node.key;
return node.key?.startsWith('mxc://') ? `:${node.shortcode}:` : (node.key ?? '');
case BlockType.Link:
return `[${children}](${node.href})`;
case BlockType.Command:
@@ -182,10 +181,9 @@ export const toPlainText = (
text = text.replaceAll(SPOILEREDLINKINPUTREGEX, '$1');
if (stripNickname && nickNameReplacement) {
nickNameReplacement?.keys().forEach((key) => {
const replacement = nickNameReplacement.get(key) ?? '';
for (const [key, replacement] of nickNameReplacement) {
text = text.replaceAll(key, replacement);
});
}
}
return text;
}
@@ -211,7 +209,7 @@ export const toRawText = (node: Descendant | Descendant[]): string => {
case BlockType.Link:
return `[${children}](${node.href})`;
case BlockType.Emoticon:
return node.key.startsWith('mxc://') ? `:${node.shortcode}:` : node.key;
return node.key?.startsWith('mxc://') ? `:${node.shortcode}:` : (node.key ?? '');
case BlockType.Mention:
return node.name === '@room' ? node.name : node.id;
case BlockType.Command: