mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-19 13:01:19 +00:00
fix(platforms): convert special characters to htmlentities to validate url
remove validate_url custom validator and replace with CI4's valid_url_strict
This commit is contained in:
parent
67b6e30d24
commit
82310a2e0b
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace Config;
|
||||
|
||||
use App\Validation\FileRules as AppFileRules;
|
||||
use App\Validation\Rules as AppRules;
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Validation\CreditCardRules;
|
||||
use CodeIgniter\Validation\FileRules;
|
||||
@ -24,7 +23,6 @@ class Validation extends BaseConfig
|
||||
FormatRules::class,
|
||||
FileRules::class,
|
||||
CreditCardRules::class,
|
||||
AppRules::class,
|
||||
AppFileRules::class,
|
||||
];
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2020 Ad Aures
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Validation;
|
||||
|
||||
class Rules
|
||||
{
|
||||
/**
|
||||
* Checks a URL to ensure it's formed correctly.
|
||||
*/
|
||||
public function validate_url(string $str = null): bool
|
||||
{
|
||||
if ($str === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return filter_var($str, FILTER_VALIDATE_URL) !== false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
}
|
@ -65,7 +65,7 @@ class PodcastImportController extends BaseController
|
||||
|
||||
$rules = [
|
||||
'handle' => 'required|regex_match[/^[a-zA-Z0-9\_]{1,32}$/]',
|
||||
'imported_feed_url' => 'required|validate_url',
|
||||
'imported_feed_url' => 'required|valid_url_strict',
|
||||
'season_number' => 'is_natural_no_zero|permit_empty',
|
||||
'max_episodes' => 'is_natural_no_zero|permit_empty',
|
||||
];
|
||||
|
@ -75,7 +75,7 @@ class PodcastPlatformController extends BaseController
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $validation->check($podcastPlatformUrl, 'validate_url')) {
|
||||
if (! $validation->check(htmlentities($podcastPlatformUrl), 'valid_url_strict')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} no és una imatge, o no és prou ample o alt.',
|
||||
'is_image_ratio' =>
|
||||
'{field} no és una imatge o no té la proporció correcta.',
|
||||
'validate_url' =>
|
||||
'El camp {field} ha de ser una adreça URL vàlida (p. ex., https://exemple.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} ist entweder kein Bild, oder es ist nicht breit oder hoch genug.',
|
||||
'is_image_ratio' =>
|
||||
'{field} ist entweder kein Bild oder nicht das richtige Verhältnis.',
|
||||
'validate_url' =>
|
||||
'Das {field} -Feld muss eine gültige URL sein (z.B. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} no es una imagen, o no es suficientemente ancha o alta.',
|
||||
'is_image_ratio' =>
|
||||
'{field} no es una imagen o no es de la proporción correcta.',
|
||||
'validate_url' =>
|
||||
'El campo {field} debe ser una URL válida (ej. https://ejemplo.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} n’est pas une image ou n’a pas la taille minimale requise.',
|
||||
'is_image_ratio' =>
|
||||
'{field} n’est pas une image ou n’est pas au bon format.',
|
||||
'validate_url' =>
|
||||
'Le champs {field} doit être une adresse valide (par exemple https://exemple.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'ou ben {field} non é unha imaxe ou non é suficientemente alta ou ancha.',
|
||||
'is_image_ratio' =>
|
||||
'ou ben {field} non é unha imaxe ou non ten proporcións axeitadas.',
|
||||
'validate_url' =>
|
||||
'O campo {field} ten que ser un URL válido (ex. https://exemplo.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} er anten ikkje eit bilete, eller er ikkje breitt og høgt nok.',
|
||||
'is_image_ratio' =>
|
||||
'{field} er anten ikkje eit bilete, eller har feil forhold mellom høgd og breidd.',
|
||||
'validate_url' =>
|
||||
'{field}-feltet må vera ei gyldig nettadresse (td. https://eksempel.no/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} nie jest obrazem, albo nie jest wystarczająco szeroki lub wysoki.',
|
||||
'is_image_ratio' =>
|
||||
'{field} nie jest obrazem, albo nie ma właściwych proporcji.',
|
||||
'validate_url' =>
|
||||
'Pole {field} musi być prawidłowym adresem URL (np. https://przyklad.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} não é uma imagem ou não é largo ou alto o suficiente.',
|
||||
'is_image_ratio' =>
|
||||
'{field} não é uma imagem ou não tem a proporção correta.',
|
||||
'validate_url' =>
|
||||
'O campo {field} deve ser uma URL válida (por exemplo, https://examplo.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} is either not an image, or it is not wide or tall enough.',
|
||||
'is_image_ratio' =>
|
||||
'{field} is either not an image or not of the right ratio.',
|
||||
'validate_url' =>
|
||||
'The {field} field must be a valid URL (eg. https://example.com/).',
|
||||
];
|
||||
|
@ -13,6 +13,4 @@ return [
|
||||
'{field} 不是一张图片,或者宽或高度不够。',
|
||||
'is_image_ratio' =>
|
||||
'{field} 不是图片或比例不正确。',
|
||||
'validate_url' =>
|
||||
'{field} 字段必须是有效的 URL(例如 https://example.com/)。',
|
||||
];
|
||||
|
@ -154,8 +154,8 @@ class InstallController extends Controller
|
||||
public function attemptInstanceConfig(): RedirectResponse
|
||||
{
|
||||
$rules = [
|
||||
'hostname' => 'required|validate_url',
|
||||
'media_base_url' => 'permit_empty|validate_url',
|
||||
'hostname' => 'required|valid_url_strict',
|
||||
'media_base_url' => 'permit_empty|valid_url_strict',
|
||||
'admin_gateway' => 'required',
|
||||
'auth_gateway' => 'required|differs[admin_gateway]',
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user