Skip to content

Commit 85935bb

Browse files
fix: Handle URLs with "&" correctly
1 parent f81136c commit 85935bb

File tree

8 files changed

+30
-27
lines changed

8 files changed

+30
-27
lines changed

src/assets/javascripts/controllers/link_suggestion_controller.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import { Controller } from '@hotwired/stimulus';
22

33
export default class extends Controller {
44
static get targets () {
5-
return ['input', 'message', 'suggestion'];
5+
return ['input', 'message'];
6+
}
7+
8+
static values = {
9+
url: String,
610
}
711

812
change (event) {
913
event.preventDefault();
1014

11-
this.inputTarget.value = this.suggestionTarget.innerHTML;
15+
this.inputTarget.value = this.urlValue;
1216
this.messageTarget.hidden = true;
1317
this.inputTarget.focus();
1418
}

src/views/collections/shares/index.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
<?= $this->include('collections/shares/_index.phtml', [
1010
'collection' => $collection,
11-
'type' => $type,
12-
'user_id' => $user_id,
13-
'from' => $from,
11+
'type' => $this->safe('type'),
12+
'user_id' => $this->safe('user_id'),
13+
'from' => $this->safe('from'),
1414
'errors' => $errors,
15-
'error' => $error,
15+
'error' => $this->safe('error'),
1616
]); ?>

src/views/collections/shares/index.turbo_stream.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<template>
33
<?= $this->include('collections/shares/_index.phtml', [
44
'collection' => $collection,
5-
'type' => $type,
6-
'user_id' => $user_id,
7-
'from' => $from,
5+
'type' => $this->safe('type'),
6+
'user_id' => $this->safe('user_id'),
7+
'from' => $this->safe('from'),
88
'errors' => $errors,
9-
'error' => $error,
9+
'error' => $this->safe('error'),
1010
]); ?>
1111
</template>
1212
</turbo-stream>

src/views/feeds/new.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
?>
99

1010
<?= $this->include('feeds/_new.phtml', [
11-
'url' => $url,
12-
'from' => $from,
11+
'url' => $this->safe('url'),
12+
'from' => $this->safe('from'),
1313
'errors' => $errors,
14-
'error' => $error,
14+
'error' => $this->safe('error'),
1515
]); ?>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<turbo-stream action="replace" target="modal-feeds-new">
22
<template>
33
<?= $this->include('feeds/_new.phtml', [
4-
'url' => $url,
5-
'from' => $from,
4+
'url' => $this->safe('url'),
5+
'from' => $this->safe('from'),
66
'errors' => $errors,
7-
'error' => $error,
7+
'error' => $this->safe('error'),
88
]); ?>
99
</template>
1010
</turbo-stream>

src/views/links/repairing/_new.phtml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<div
1818
class="form-group <?= isset($errors['url']) ? 'form-group--invalid' : '' ?>"
1919
data-controller="link-suggestion"
20+
data-link-suggestion-url-value="<?= $this->safe('url_cleared') ?>"
2021
>
2122
<label for="url">
2223
<?= _('What’s the address of the link?') ?>
@@ -47,9 +48,7 @@
4748
<p class="form-group__error" data-link-suggestion-target="message">
4849
<?= _f('%s has detected trackers in this <abbr>URL</abbr>. Suggestion:', $brand) ?>
4950

50-
<span data-link-suggestion-target="suggestion">
51-
<?= $url_cleared ?>
52-
</span>
51+
<?= $url_cleared ?>
5352

5453
<button
5554
class="button--small"

src/views/links/repairing/new.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
<?= $this->include('links/repairing/_new.phtml', [
1010
'link' => $link,
11-
'url' => $url,
12-
'url_cleared' => $url_cleared,
11+
'url' => $this->safe('url'),
12+
'url_cleared' => $this->safe('url_cleared'),
1313
'ask_sync' => $ask_sync,
14-
'from' => $from,
14+
'from' => $this->safe('from'),
1515
'errors' => $errors,
16-
'error' => $error,
16+
'error' => $this->safe('error'),
1717
]); ?>

src/views/links/repairing/new.turbo_stream.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<template>
33
<?= $this->include('links/repairing/_new.phtml', [
44
'link' => $link,
5-
'url' => $url,
6-
'url_cleared' => $url_cleared,
5+
'url' => $this->safe('url'),
6+
'url_cleared' => $this->safe('url_cleared'),
77
'ask_sync' => $ask_sync,
8-
'from' => $from,
8+
'from' => $this->safe('from'),
99
'errors' => $errors,
10-
'error' => $error,
10+
'error' => $this->safe('error'),
1111
]); ?>
1212
</template>
1313
</turbo-stream>

0 commit comments

Comments
 (0)