Commit 21bbba2
authored
Check that autoconsentMessageCallback exists before calling it (#7687)
Task/Issue URL:
https://app.asana.com/1/137249556945/task/1213142040936086
### Description
- Adds a guard around the JS in `ReplyHandler` to check that the
function exists before calling it.
### Steps to test this PR
- [ ] Smoke test autoconsent
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Small, localized change to injected JS string construction plus test
updates; behavior only differs when the callback is absent (now no-op
instead of error).
>
> **Overview**
> Prevents JavaScript reply injection from throwing when
`window.autoconsentMessageCallback` is missing by wrapping callback
invocation in a `typeof ... === 'function'` guard in
`ReplyHandler.constructReply`.
>
> Updates affected tests to expect the new multi-line guarded JS and
loosens JSON extraction in handler plugin tests by parsing the substring
between `window.autoconsentMessageCallback(` and `, window.origin`
instead of relying on an exact wrapper prefix/suffix.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
903c125. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent a77102a commit 21bbba2
File tree
5 files changed
+25
-9
lines changed- autoconsent/autoconsent-impl/src
- main/java/com/duckduckgo/autoconsent/impl/handlers
- test/java/com/duckduckgo/autoconsent/impl
- handlers
5 files changed
+25
-9
lines changedLines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | 29 | | |
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
133 | 139 | | |
134 | 140 | | |
135 | 141 | | |
| |||
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | | - | |
| 120 | + | |
| 121 | + | |
123 | 122 | | |
124 | 123 | | |
125 | 124 | | |
| |||
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
372 | | - | |
373 | | - | |
374 | | - | |
| 372 | + | |
| 373 | + | |
375 | 374 | | |
376 | 375 | | |
377 | 376 | | |
| |||
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
99 | 105 | | |
100 | 106 | | |
101 | 107 | | |
| |||
0 commit comments