@astryxdesign/native 0.7.6-canary.3bf6f43 → 0.7.6-canary.3d44c58

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.
@@ -302,9 +302,13 @@ public struct Avatar<Status: View>: View {
302
302
 
303
303
  /// The URL the avatar opens, or `nil` when it has no usable `href`.
304
304
  var linkURL: URL? {
305
- // Only an absolute URL the system can open; a malformed or relative
306
- // `href` leaves the avatar static or a button.
307
- guard let url = url(props.href), url.scheme != nil else { return nil }
305
+ // Only an absolute URL the system can open, and never one core's
306
+ // navigation destinations refuse (a script URL or an HTML `data:` URL);
307
+ // a malformed, relative, or refused `href` leaves the avatar static or a
308
+ // button.
309
+ guard let href = props.href, astryxSafeDestination(href) != nil,
310
+ let url = url(href), url.scheme != nil
311
+ else { return nil }
308
312
  return url
309
313
  }
310
314
 
@@ -125,6 +125,20 @@ import Testing
125
125
  #expect(Avatar("Ada").linkURL == nil)
126
126
  }
127
127
 
128
+ // family:navigation-destinations FR4: a script URL or an HTML document in a
129
+ // data URL never makes the avatar a link; it stays a button with onClick, or
130
+ // static, as Swift Button and Item refuse them.
131
+ @MainActor
132
+ @Test func aRefusedDestinationLeavesTheAvatarWithoutALink() {
133
+ for refused in ["javascript:alert(1)", " JavaScript: alert(1)", "vbscript:msgbox", "data:text/html,<p>", "data: text/html,<p>"] {
134
+ #expect(Avatar("Ada", href: refused).linkURL == nil, "\(refused)")
135
+ #expect(Avatar("Ada", href: refused).tap == .none, "\(refused)")
136
+ #expect(Avatar("Ada", href: refused, onClick: {}).tap == .button, "\(refused)")
137
+ }
138
+ // Other schemes still open, as before.
139
+ #expect(Avatar("Ada", href: "data:image/png;base64,AAAA").linkURL != nil)
140
+ }
141
+
128
142
  @MainActor
129
143
  @Test func avatarsReadTheirTapAndTraits() {
130
144
  #expect(Avatar("Ada").tap == .none)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/native",
3
- "version": "0.7.6-canary.3bf6f43",
3
+ "version": "0.7.6-canary.3d44c58",
4
4
  "description": "Experimental native platforms for Astryx (iOS, Android, macOS, Windows) — published to npm only under the @canary dist-tag; never released as a stable (latest) version.",
5
5
  "author": "Meta Open Source",
6
6
  "license": "MIT",
@@ -70,10 +70,10 @@
70
70
  }
71
71
  },
72
72
  "peerDependencies": {
73
- "@astryxdesign/core": "0.7.6-canary.3bf6f43"
73
+ "@astryxdesign/core": "0.7.6-canary.3d44c58"
74
74
  },
75
75
  "devDependencies": {
76
- "@astryxdesign/core": "0.7.6-canary.3bf6f43"
76
+ "@astryxdesign/core": "0.7.6-canary.3d44c58"
77
77
  },
78
78
  "scripts": {
79
79
  "build": "node ../../scripts/clean-dist.mjs && tsc --project tsconfig.build.json && node scripts/generate.mjs --types",