Commit Graph
18 Commits
Author SHA1 Message Date
Joffrey JAFFEUX e0234b5e0b FIX: ensures placeholders works in lists (#63)
Prior to this fix the following cases wouldn't work:
- nested lists
- a link in a list
2025-09-29 15:40:42 +02:00
Sérgio Saquetim 279871bdfd DEV: Fix compatibility with the Glimmer Post Stream (#57) 2025-05-06 15:08:09 -03:00
David Taylor 296864048a FIX: Scope a[href] detection to post (#43)
Corrects typo in a37e4bf266
2024-09-04 09:49:57 +01:00
David Taylor a37e4bf266 FIX: Restore replacement functionality for a[href] attributes (#42)
Followup to 948634fe31
2024-09-04 09:31:17 +01:00
David TaylorandJoffrey JAFFEUX 569b566d38 FIX: Multiple placeholders in a single post (#40)
The changes in 948634fe31 meant that only the most-recently-changed placeholder is actually applied.

This commit refactors things so that we store all placeholder values in JS, and then apply them all in a single pass over the DOM. As well as fixing the bug, this should be a significant perf improvement for posts with lots of placeholders

Also introduces some simple system specs.
---------

Co-authored-by: Joffrey JAFFEUX <[email protected]>
2024-08-29 12:37:21 +01:00
David Taylor 948634fe31 SECURITY: Apply transformations to text nodes only
Previously, the replacement system would modify raw HTML, which is prone to issues and vulnerabilities. With this commit, we iterate over text nodes only, and do simple string replacements on their content. That means that the user input never gets passed into an HTML parser, and there is no chance of injection attacks.

The re-rendering system is also simplified to store the original value for re-use later, instead of mapping position/length of replacements.

This does mean the behavior is changed slightly. Replacements will no longer be applied to html attributes (e.g `a[href]`). If this affects your use-case, please let us know [on Meta](https://meta.discourse.org/t/113533).

This is a followup to the fix in a62f711d56
2024-08-29 10:15:53 +01:00
Joffrey JAFFEUX a62f711d56 SECURITY: properly escape user input (#38)
We were failing to correctly escape content which we would then inject in the HTML of the post causing an XSS.

Note this XSS is stopped by CSP.
2024-08-20 18:06:58 +02:00
David Taylor a319c0baa1 DEV: Update linting (#28) 2024-03-27 18:55:28 +01:00
Jarek Radosz 05a727efd5 DEV: Use the new modal api (#26) 2023-12-05 23:15:32 +01:00
Alan Guo Xiang Tan 344f4dd0ea DEV: Switch to new addComposerToolbarPopupMenuOption plugin API (#25)
Why this change?

`api.addToolbarPopupMenuOptionsCallback` has been deprecated in https://github.com/discourse/discourse/commit/913fd3a7b392b492f6344102577960a6eada00ce
2023-10-23 08:08:57 +08:00
Joffrey JAFFEUX be75773375 FIX: fully rely on keyValueStore to prevent error (#12)
* FIX: fully rely on keyValueStore to prevent error

The component was generating errors for some users due to direct access to `localStorage`:

```
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.expireOldValues (https://d3bpeqsaub0i6y.cloudfront.net/theme-javascripts/33bf35dc19b970a42f8c1e7d57d8cc72d6205bbd.js?__ws=meta.discourse.org:157:14)
    at Object.initialize (https://d3bpeqsaub0i6y.cloudfront.net/theme-javascripts/33bf35dc19b970a42f8c1e7d57d8cc72d6205bbd.js?__ws=meta.discourse.org:193:12)
    at o.initialize (https://d11a6trkgmumsb.cloudfront.net/assets/discourse-2bd9a9aa6b5c9cbee990a03159f5bff41fe503fe74814c3b66b3770876913dd5.gz.js:68:38)
```

This commits removes old unnecessary code using cookies and uses latest API from core `removeKeys`. Old discourse instances will just not evict old keys which is a minor annoyance.

* linting
2022-08-22 00:25:50 +02:00
Jarek Radosz faf88c2209 DEV: Fix key-value-store:main deprecation (#11) 2022-08-13 22:40:11 +02:00
Jarek Radosz ba7ca9e588 DEV: Fix typo (#10) 2022-08-13 22:39:58 +02:00
Jarek Radosz 1c4f5b1a99 DEV: Add CI setup and fix linting issues (#9) 2022-06-18 21:27:31 +02:00
David Taylor 9a002eed80 FIX: Dropdowns following recent refactoring (#7) 2022-01-13 16:48:07 -08:00
David Taylor 9882e993c5 DEV: Remove JQuery 2022-01-13 13:02:06 +00:00
David Taylor 468cf81fd2 DEV: Migrate to local storage
Setting cookies means that they're sent in the request headers for every HTTP request. This will have a (tiny) impact on performance, plus it can raise privacy concerns. Using localStorage is more appropriate for this use case.

This commit includes migration logic for any previously-saved values.

Previously the cookies were set to last for the 'session'. localStorage doesn't have an expiration mechanism, so this commit implements a 7-day expiration on the values.
2022-01-13 13:02:06 +00:00
David Taylor 6c43321b28 DEV: Apply prettier, remove es6 extension 2022-01-13 13:02:06 +00:00