@autobusal/order-confirm 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package are documented here. This project follows
4
+ [Keep a Changelog](https://keepachangelog.com/) and [Semantic Versioning](https://semver.org/).
5
+
6
+ ## [1.0.1] - 2026-07-19
7
+
8
+ ### Security
9
+
10
+ - `OrderConfirm.tsx`: fixed an HTML-injection (XSS) vector. The `hash` segment
11
+ comes straight from the URL (`/orders/:type/:hash`) and was interpolated into
12
+ markup rendered via `dangerouslySetInnerHTML`. Added an `escapeHtml` helper
13
+ that encodes `& < > " '` and applied it to the hash before interpolation
14
+ (`<strong>${ escapeHtml(String(hash ?? '')) }</strong>`), so a crafted hash
15
+ (e.g. containing `<img onerror=...>`) can no longer inject markup.
16
+
17
+ ### Fixed
18
+
19
+ - `OrderConfirm.tsx`: the "Manage order" action now routes based on auth state.
20
+ A logged-in user is sent to `/account/orders` (where the order is listed)
21
+ instead of the public `/viewtrip/:hash` lookup form that email-gates access to
22
+ their own order; guests still use the public `/viewtrip/:hash` lookup.
23
+
24
+ Authored by Ferjolt Ozuni. Consolidated from the magus and alvavel whitelabel patch sets into canonical @autobusal source (eliminates per-repo patch-package divergence).
package/OrderConfirm.tsx CHANGED
@@ -12,6 +12,15 @@ interface Props {
12
12
  t: TFunction<'common'>
13
13
  }
14
14
 
15
+ // hash comes straight from the URL (/orders/:type/:hash) and is interpolated into
16
+ // HTML that gets rendered via dangerouslySetInnerHTML below - escape it so a
17
+ // crafted hash segment (e.g. containing <img onerror=...>) can't inject markup.
18
+ const escapeHtml = (value: string): string => (
19
+ value.replace(/[&<>"']/g, char => ({
20
+ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', '\'': '&#39;'
21
+ }[char] as string))
22
+ );
23
+
15
24
  const OrderConfirm = ({ t }: Props): (JSX.Element | null) => {
16
25
  const [ searchParams ] = useSearchParams();
17
26
 
@@ -30,7 +39,10 @@ const OrderConfirm = ({ t }: Props): (JSX.Element | null) => {
30
39
  }
31
40
 
32
41
  const onManage = (): void => {
33
- navigate(`/viewtrip/${ hash }`);
42
+ // a logged-in user shouldn't be sent to the public order-lookup form (which
43
+ // email-gates access to their OWN order) - send them into their account
44
+ // orders where the order is listed. Guests use the public lookup.
45
+ navigate(UserData ? '/account/orders' : `/viewtrip/${ hash }`);
34
46
  };
35
47
 
36
48
  const onBack = (): void => {
@@ -45,7 +57,7 @@ const OrderConfirm = ({ t }: Props): (JSX.Element | null) => {
45
57
  </Title>
46
58
 
47
59
  <div className="box" dangerouslySetInnerHTML={{
48
- __html: t(`order_confirm.content.${ type}`, { order: `<strong>${ hash }</strong>` })
60
+ __html: t(`order_confirm.content.${ type}`, { order: `<strong>${ escapeHtml(String(hash ?? '')) }</strong>` })
49
61
  }} />
50
62
 
51
63
  <>
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@autobusal/order-confirm",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
+ "author": "Ferjolt Ozuni",
4
5
  "type": "module",
5
6
  "main": "index.ts"
6
7
  }