discourse/app/assets/javascripts
Godfrey Chan 2ae913f45e
Consistently import escape from discourse-common (#23790)
`escape` from `pretty-text/sanitizer` is a re-export of the same
function defined in `discourse-common`. Updating the import paths
across the codebase to use the `discourse-common` import path.

`escape` is a rather simple function that can be accomplished with
a regular expression in `discourse-common`.

On the other hand, the remaining parts in `pretty-text/sanitizer`
has a lot of code, PLUS it depend on the rather heavy "xss" NPM
library.

Currently, most of the consumers of `pretty-text/sanitizer` are of
the `{ escape }` varient. This is resolved by this PR.

The remaining usages are either:

1. via/through `PrettyText` which is essentially gated behind
   loading the markdown-it bundle, OR

2. via `sanitize` from `discourse/lib/text`

I believe we may ultimately be able to move all the usages to behind
the markdown-it bundle (or, equivilantly, set up another lazy bundle
for `sanitize`) and be able to shed the sanitization code and the
"xss" library from the initial page load.

`discourse/lib/text` also defines a `sanitizeAsync` which is gated
behind loading the markdown-it bundle.

Looking through the usages of `sanitize`, I believe most of these
can be safely switched to use `sanitizeAsync`, in that they are
already in an asynchrnous path that handles a server response. Most
of them are actually rendering a piece of server-generated HTML
message as flash message, so I am not sure there really is value in
sanitizing (we should be able to trust our own server?), but in any
case, code-wise, they should already be able to absorb the async
just fine.

I am not sure if `sanitize` and `sanitizeAsync` are actually API
compatible – they both take `options` but I think those `options` do
pretty different things. This is somethign for another person to
investigate down the road in another PR.

According to `all-the-plugins`, `discourse-graphviz` also import
from this location, so perhaps we should PR to update. That being
said, it doesn't really hurt anything to keep the alias around for
a while.
2023-10-11 22:21:01 +01:00
..
admin Consistently import escape from discourse-common (#23790) 2023-10-11 22:21:01 +01:00
bootstrap-json FIX: Embroider breaking index html structure (#23811) 2023-10-06 13:41:47 +02:00
confirm-new-email DEV: Add error message styling (#21225) 2023-04-25 08:40:18 -04:00
deprecation-silencer DEV: move deprecation silencer to a shared package (#22668) 2023-07-18 19:07:20 +01:00
dialog-holder Build(deps): Bump ember-cli-babel in /app/assets/javascripts (#23890) 2023-10-11 00:18:58 +02:00
discourse Consistently import escape from discourse-common (#23790) 2023-10-11 22:21:01 +01:00
discourse-common Consistently import escape from discourse-common (#23790) 2023-10-11 22:21:01 +01:00
discourse-hbr Build(deps): Bump ember-cli-babel in /app/assets/javascripts (#23890) 2023-10-11 00:18:58 +02:00
discourse-plugins Build(deps): Bump ember-cli-babel in /app/assets/javascripts (#23890) 2023-10-11 00:18:58 +02:00
discourse-widget-hbs Build(deps): Bump ember-cli-babel in /app/assets/javascripts (#23890) 2023-10-11 00:18:58 +02:00
docs DEV: enforces eslint’s curly rule to the codebase (#10720) 2020-09-22 16:28:28 +02:00
ember-addons DEV: Remove ember-addons (#9559) 2020-04-28 10:14:49 -04:00
ember-cli-progress-ci DEV: Add progress output in CI during ember-cli build (#17977) 2022-08-17 22:39:52 +01:00
ember-production-deprecations DEV: Clean up package.json files (#22349) 2023-06-30 13:01:45 +02:00
float-kit Build(deps): Bump ember-cli-babel in /app/assets/javascripts (#23890) 2023-10-11 00:18:58 +02:00
locales DEV: Raise an error in test env when I18n interpolate argument is missing (#23527) 2023-09-13 10:53:48 +08:00
patches DEV: Update the content-tag patch (#23840) 2023-10-09 12:01:58 +02:00
pretty-text Build(deps): Bump ember-cli-babel in /app/assets/javascripts (#23890) 2023-10-11 00:18:58 +02:00
select-kit Build(deps): Bump ember-cli-babel in /app/assets/javascripts (#23890) 2023-10-11 00:18:58 +02:00
theme-transpiler DEV: Sort imports 2023-10-10 21:46:54 +01:00
truth-helpers Build(deps): Bump ember-cli-babel in /app/assets/javascripts (#23890) 2023-10-11 00:18:58 +02:00
wizard Build(deps): Bump ember-cli-babel in /app/assets/javascripts (#23890) 2023-10-11 00:18:58 +02:00
.licensee.json DEV: Update sub-dependencies (#22325) 2023-06-29 17:08:33 +02:00
.npmrc DEV: Prevent npm usage (#13945) 2021-08-04 22:04:58 +02:00
handlebars-shim.js FIX: It seems sometimes shims are evaluated by older JS engines (#11813) 2021-01-22 10:41:01 -05:00
package.json DEV: Add gjs support for themes (#23473) 2023-10-02 12:36:06 +02:00
polyfills.js Drop support for iOS < 15.7 (#19847) 2023-01-16 17:28:59 +00:00
run-patch-package DEV: Automatically retry patch-package on failure (#23583) 2023-09-14 12:25:06 +01:00
service-worker.js.erb FIX: Ensure service-worker cache is cleaned correctly (#23204) 2023-08-23 13:58:32 +01:00
yarn.lock Build(deps): Bump ember-cli-babel in /app/assets/javascripts (#23890) 2023-10-11 00:18:58 +02:00