Procházet zdrojové kódy

fix validator url update (#8436)

Closes https://github.com/FreshRSS/FreshRSS/issues/8435

Changes proposed in this pull request:
- update validator links to use the same open-url handler with prefix + encoding
- ensure the validator link reflects the current #url field value before opening
- keep existing open-url behavior for other links unchanged

How to test the feature manually:
1. Open feed edit (or add feed) form.
2. Change the feed URL in the URL field.
3. Click “Check the validity of the feed” and verify it opens the validator with the updated URL.
Tsung-Han Yu před 2 měsíci
rodič
revize
84604e0c64

+ 1 - 0
CREDITS.md

@@ -289,6 +289,7 @@ People are sorted by name so please keep this order.
 * [tonitonae](https://github.com/tonitonae): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:tonitonae)
 * [tonitonae](https://github.com/tonitonae): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:tonitonae)
 * [Troy Engel](https://github.com/troyengel): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:troyengel)
 * [Troy Engel](https://github.com/troyengel): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:troyengel)
 * [TryAllTheThings](https://github.com/tryallthethings): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:tryallthethings)
 * [TryAllTheThings](https://github.com/tryallthethings): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:tryallthethings)
+* [Tsung-Han Yu](https://github.com/johan456789): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:johan456789), [Web](https://tsunghanyu.com/)
 * [Twilek-de](https://github.com/Twilek-de): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:Twilek-de)
 * [Twilek-de](https://github.com/Twilek-de): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:Twilek-de)
 * [Uncovery](https://github.com/uncovery): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:uncovery)
 * [Uncovery](https://github.com/uncovery): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:uncovery)
 * [upskaling](https://github.com/upskaling): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:upskaling)
 * [upskaling](https://github.com/upskaling): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:upskaling)

+ 1 - 1
app/views/feed/add.phtml

@@ -50,7 +50,7 @@
 						<a class="btn open-url" target="_blank" rel="noreferrer" href="<?= $this->feed->url() ?>" data-input="url" title="<?= _t('gen.action.open_url') ?>"><?= _i('link') ?></a>
 						<a class="btn open-url" target="_blank" rel="noreferrer" href="<?= $this->feed->url() ?>" data-input="url" title="<?= _t('gen.action.open_url') ?>"><?= _i('link') ?></a>
 					</div>
 					</div>
 					<br />
 					<br />
-					<a class="btn" target="_blank" rel="noreferrer" href="https://validator.w3.org/feed/check.cgi?url=<?= $this->feed->url() ?>"><?= _t('sub.feed.validator') ?></a>
+					<a class="btn open-url" target="_blank" rel="noreferrer" data-input="url" data-prefix="https://validator.w3.org/feed/check.cgi?url=" data-encode="1" href="https://validator.w3.org/feed/check.cgi?url=<?= $this->feed->url() ?>"><?= _t('sub.feed.validator') ?></a>
 				</div>
 				</div>
 			</div>
 			</div>
 			<div class="form-group">
 			<div class="form-group">

+ 1 - 1
app/views/helpers/feed/update.phtml

@@ -95,7 +95,7 @@
 						<input type="url" name="url" id="url" value="<?= $this->feed->url() ?>" required="required" />
 						<input type="url" name="url" id="url" value="<?= $this->feed->url() ?>" required="required" />
 						<a class="btn open-url" target="_blank" rel="noreferrer" href="<?= $this->feed->url() ?>" data-input="url" title="<?= _t('gen.action.open_url') ?>"><?= _i('link') ?></a>
 						<a class="btn open-url" target="_blank" rel="noreferrer" href="<?= $this->feed->url() ?>" data-input="url" title="<?= _t('gen.action.open_url') ?>"><?= _i('link') ?></a>
 					</div>
 					</div>
-					<a class="btn" target="_blank" rel="noreferrer" href="https://validator.w3.org/feed/check.cgi?url=<?=
+					<a class="btn open-url" target="_blank" rel="noreferrer" data-input="url" data-prefix="https://validator.w3.org/feed/check.cgi?url=" data-encode="1" href="https://validator.w3.org/feed/check.cgi?url=<?=
 						rawurlencode(htmlspecialchars_decode($this->feed->url(), ENT_QUOTES)) ?>"><?= _t('sub.feed.validator') ?></a>
 						rawurlencode(htmlspecialchars_decode($this->feed->url(), ENT_QUOTES)) ?>"><?= _t('sub.feed.validator') ?></a>
 				</div>
 				</div>
 			</div>
 			</div>

+ 6 - 3
p/scripts/extra.js

@@ -395,11 +395,14 @@ function close_slider_listener(ev) {
 }
 }
 // </slider>
 // </slider>
 
 
-// overwrites the href attribute from the url input
+// updates href from the input value, with optional prefix/encoding
 function updateHref(ev) {
 function updateHref(ev) {
 	const urlField = document.getElementById(this.getAttribute('data-input'));
 	const urlField = document.getElementById(this.getAttribute('data-input'));
-	const url = urlField.value;
-	if (url.length > 0) {
+	const rawUrl = urlField.value;
+	const prefix = this.getAttribute('data-prefix') || '';
+	const shouldEncode = this.getAttribute('data-encode') === '1';
+	const url = prefix + (shouldEncode ? encodeURIComponent(rawUrl) : rawUrl);
+	if (rawUrl.length > 0) {
 		this.href = url;
 		this.href = url;
 		return true;
 		return true;
 	} else {
 	} else {