diff --git a/app/Entities/Tools/PageContent.php b/app/Entities/Tools/PageContent.php index b95131fce..dbb62021c 100644 --- a/app/Entities/Tools/PageContent.php +++ b/app/Entities/Tools/PageContent.php @@ -109,15 +109,35 @@ class PageContent /** * Convert all inline base64 content to uploaded image files. + * Regex is used to locate the start of data-uri definitions then + * manual looping over content is done to parse the whole data uri. + * Attempting to capture the whole data uri using regex can cause PHP + * PCRE limits to be hit with larger, multi-MB, files. */ protected function extractBase64ImagesFromMarkdown(string $markdown) { $matches = []; - preg_match_all('/!\[.*?]\(.*?(data:image\/.*?)[)"\s]/', $markdown, $matches); + $contentLength = strlen($markdown); + $replacements = []; + preg_match_all('/!\[.*?]\(.*?(data:image\/.{1,6};base64,)/', $markdown, $matches, PREG_OFFSET_CAPTURE); - foreach ($matches[1] as $base64Match) { - $newUrl = $this->base64ImageUriToUploadedImageUrl($base64Match); - $markdown = str_replace($base64Match, $newUrl, $markdown); + foreach ($matches[1] as $base64MatchPair) { + [$dataUri, $index] = $base64MatchPair; + + for ($i = strlen($dataUri) + $index; $i < $contentLength; $i++) { + $char = $markdown[$i]; + if ($char === ')' || $char === ' ' || $char === "\n" || $char === '"') { + break; + } + $dataUri .= $char; + } + + $newUrl = $this->base64ImageUriToUploadedImageUrl($dataUri); + $replacements[] = [$dataUri, $newUrl]; + } + + foreach ($replacements as [$dataUri, $newUrl]) { + $markdown = str_replace($dataUri, $newUrl, $markdown); } return $markdown; diff --git a/resources/js/components/wysiwyg-editor.js b/resources/js/components/wysiwyg-editor.js index 7a2b6ceba..2dd5da410 100644 --- a/resources/js/components/wysiwyg-editor.js +++ b/resources/js/components/wysiwyg-editor.js @@ -136,18 +136,14 @@ function codePlugin() { const selectedNode = editor.selection.getNode(); if (!elemIsCodeBlock(selectedNode)) { - const providedCode = editor.selection.getNode().textContent; + const providedCode = editor.selection.getContent({format: 'text'}); window.components.first('code-editor').open(providedCode, '', (code, lang) => { const wrap = document.createElement('div'); wrap.innerHTML = `
`;
wrap.querySelector('code').innerText = code;
- editor.formatter.toggle('pre');
- const node = editor.selection.getNode();
- editor.dom.setHTML(node, wrap.querySelector('pre').innerHTML);
- editor.fire('SetContent');
-
- editor.focus()
+ editor.insertContent(wrap.innerHTML);
+ editor.focus();
});
return;
}
diff --git a/resources/lang/ar/validation.php b/resources/lang/ar/validation.php
index d4d3aaf26..94112789d 100644
--- a/resources/lang/ar/validation.php
+++ b/resources/lang/ar/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => 'يجب أن يكون :attribute بعدد خانات بين :min و :max.',
'email' => 'يجب أن يكون :attribute عنوان بريد إلكتروني صالح.',
'ends_with' => 'يجب أن تنتهي السمة بأحد القيم التالية',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'حقل :attribute مطلوب.',
'gt' => [
'numeric' => 'يجب أن تكون السمة أكبر من: القيمة.',
diff --git a/resources/lang/bg/validation.php b/resources/lang/bg/validation.php
index 0a5b81d92..68ce6e7b4 100644
--- a/resources/lang/bg/validation.php
+++ b/resources/lang/bg/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute трябва да бъде с дължина между :min и :max цифри.',
'email' => ':attribute трябва да бъде валиден имейл адрес.',
'ends_with' => ':attribute трябва да свършва с един от следните символи: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'Полето :attribute е задължителен.',
'gt' => [
'numeric' => ':attribute трябва да бъде по-голям от :value.',
diff --git a/resources/lang/bs/validation.php b/resources/lang/bs/validation.php
index d6887ccc7..b07df9178 100644
--- a/resources/lang/bs/validation.php
+++ b/resources/lang/bs/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute mora imati između :min i :max brojeva.',
'email' => ':attribute mora biti ispravna e-mail adresa.',
'ends_with' => ':attribute mora završavati sa jednom od sljedećih: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'Polje :attribute je obavezno.',
'gt' => [
'numeric' => ':attribute mora biti veći od :value.',
diff --git a/resources/lang/ca/validation.php b/resources/lang/ca/validation.php
index 603182c1a..bc9be7d05 100644
--- a/resources/lang/ca/validation.php
+++ b/resources/lang/ca/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => 'El camp :attribute ha de tenir entre :min i :max dígits.',
'email' => 'El camp :attribute ha de ser una adreça electrònica vàlida.',
'ends_with' => 'El camp :attribute ha d\'acabar amb un dels següents valors: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'El camp :attribute és obligatori.',
'gt' => [
'numeric' => 'El camp :attribute ha de ser més gran que :value.',
diff --git a/resources/lang/cs/validation.php b/resources/lang/cs/validation.php
index e4e33bc0c..441fd30c8 100644
--- a/resources/lang/cs/validation.php
+++ b/resources/lang/cs/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute musí být dlouhé nejméně :min a nejvíce :max pozic.',
'email' => ':attribute není platný formát.',
'ends_with' => ':attribute musí končit jednou z následujících hodnot: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute musí být vyplněno.',
'gt' => [
'numeric' => ':attribute musí být větší než :value.',
diff --git a/resources/lang/da/validation.php b/resources/lang/da/validation.php
index c54b07a6e..649e0df33 100644
--- a/resources/lang/da/validation.php
+++ b/resources/lang/da/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute skal være mellem :min og :max cifre.',
'email' => ':attribute skal være en gyldig mail-adresse.',
'ends_with' => ':attribute skal slutte på en af følgende værdier: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute er obligatorisk.',
'gt' => [
'numeric' => ':attribute skal være større end :value.',
diff --git a/resources/lang/de/validation.php b/resources/lang/de/validation.php
index 5d08c241a..aa3203132 100644
--- a/resources/lang/de/validation.php
+++ b/resources/lang/de/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute muss zwischen :min und :max Stellen haben.',
'email' => ':attribute muss eine valide E-Mail-Adresse sein.',
'ends_with' => ':attribute muss mit einem der folgenden Werte: :values enden',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute ist erforderlich.',
'gt' => [
'numeric' => ':attribute muss größer als :value sein.',
diff --git a/resources/lang/de_informal/validation.php b/resources/lang/de_informal/validation.php
index 6603eccc8..ef45d1116 100644
--- a/resources/lang/de_informal/validation.php
+++ b/resources/lang/de_informal/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute muss zwischen :min und :max Stellen haben.',
'email' => ':attribute muss eine valide E-Mail-Adresse sein.',
'ends_with' => ':attribute muss mit einem der folgenden Werte: :values enden',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute ist erforderlich.',
'gt' => [
'numeric' => ':attribute muss größer als :value sein.',
diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php
index 1963b0df2..2a676c7c4 100644
--- a/resources/lang/en/validation.php
+++ b/resources/lang/en/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => 'The :attribute must be between :min and :max digits.',
'email' => 'The :attribute must be a valid email address.',
'ends_with' => 'The :attribute must end with one of the following: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'The :attribute field is required.',
'gt' => [
'numeric' => 'The :attribute must be greater than :value.',
diff --git a/resources/lang/es/validation.php b/resources/lang/es/validation.php
index 177eb812c..531ad2b69 100644
--- a/resources/lang/es/validation.php
+++ b/resources/lang/es/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute debe ser un valor entre :min y :max dígios.',
'email' => ':attribute debe ser un correo electrónico válido.',
'ends_with' => 'El :attribute debe terminar con uno de los siguientes: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'El campo :attribute es requerido.',
'gt' => [
'numeric' => 'El :attribute debe ser mayor que :value.',
diff --git a/resources/lang/es_AR/validation.php b/resources/lang/es_AR/validation.php
index 6b72a6549..aed5e57af 100644
--- a/resources/lang/es_AR/validation.php
+++ b/resources/lang/es_AR/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute debe ser un valor entre :min y :max dígios.',
'email' => ':attribute debe ser una dirección álida.',
'ends_with' => 'El :attribute debe terminar con uno de los siguientes: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'El campo :attribute es requerido.',
'gt' => [
'numeric' => 'El :attribute debe ser mayor que :value.',
diff --git a/resources/lang/et/validation.php b/resources/lang/et/validation.php
index ed615e66f..f241b0958 100644
--- a/resources/lang/et/validation.php
+++ b/resources/lang/et/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute peab olema :min ja :max numbri vahel.',
'email' => ':attribute peab olema kehtiv e-posti aadress.',
'ends_with' => ':attribute lõpus peab olema üks järgmistest väärtustest: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute väli on kohustuslik.',
'gt' => [
'numeric' => ':attribute peab olema suurem kui :value.',
diff --git a/resources/lang/fa/validation.php b/resources/lang/fa/validation.php
index 665451e8d..4578e1cdd 100644
--- a/resources/lang/fa/validation.php
+++ b/resources/lang/fa/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute باید بین :min و :max رقم باشد.',
'email' => ':attribute باید یک ایمیل معتبر باشد.',
'ends_with' => 'فیلد :attribute باید با یکی از مقادیر زیر خاتمه یابد: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'فیلد :attribute باید مقدار داشته باشد.',
'gt' => [
'numeric' => ':attribute باید بزرگتر از :value باشد.',
diff --git a/resources/lang/fr/common.php b/resources/lang/fr/common.php
index c373f747b..1df172dc3 100644
--- a/resources/lang/fr/common.php
+++ b/resources/lang/fr/common.php
@@ -75,7 +75,7 @@ return [
'status_active' => 'Actif',
'status_inactive' => 'Inactif',
'never' => 'Jamais',
- 'none' => 'None',
+ 'none' => 'Aucun',
// Header
'header_menu_expand' => 'Développer le menu',
diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php
index 71a5e8e08..23bb74800 100644
--- a/resources/lang/fr/validation.php
+++ b/resources/lang/fr/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute doit avoir une longueur entre :min et :max.',
'email' => ':attribute doit être une adresse e-mail valide.',
'ends_with' => ':attribute doit se terminer par une des valeurs suivantes : :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute est un champ requis.',
'gt' => [
'numeric' => ':attribute doit être plus grand que :value.',
diff --git a/resources/lang/he/validation.php b/resources/lang/he/validation.php
index e52c28b42..85f6c698e 100644
--- a/resources/lang/he/validation.php
+++ b/resources/lang/he/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => 'שדה :attribute חייב להיות בין :min ו-:max ספרות.',
'email' => 'שדה :attribute חייב להיות כתובת אימייל תקנית.',
'ends_with' => 'The :attribute must end with one of the following: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'שדה :attribute הוא חובה.',
'gt' => [
'numeric' => 'The :attribute must be greater than :value.',
diff --git a/resources/lang/hr/validation.php b/resources/lang/hr/validation.php
index b88e872f1..ad2eaa4e4 100644
--- a/resources/lang/hr/validation.php
+++ b/resources/lang/hr/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute mora biti između :min i :max znamenki.',
'email' => ':attribute mora biti valjana email adresa.',
'ends_with' => ':attribute mora završiti s :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute polje je obavezno.',
'gt' => [
'numeric' => ':attribute mora biti veći od :value.',
diff --git a/resources/lang/hu/validation.php b/resources/lang/hu/validation.php
index 3d24cec3c..db6d24f8a 100644
--- a/resources/lang/hu/validation.php
+++ b/resources/lang/hu/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute hosszának :min és :max számjegy között kell lennie.',
'email' => ':attribute érvényes email cím kell legyen.',
'ends_with' => ':attribute attribútumnak a következők egyikével kell végződnie: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute mező kötelező.',
'gt' => [
'numeric' => ':attribute nagyobb kell, hogy legyen, mint :value.',
diff --git a/resources/lang/id/validation.php b/resources/lang/id/validation.php
index 992f40329..36a3397f5 100644
--- a/resources/lang/id/validation.php
+++ b/resources/lang/id/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute harus diantara :min dan :max digit.',
'email' => ':attrtibute Harus alamat e-mail yang valid.',
'ends_with' => ':attribute harus diakhiri dengan salah satu dari berikut ini: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute bidang diperlukan.',
'gt' => [
'numeric' => ':attribute harus lebih besar dari :value.',
diff --git a/resources/lang/it/validation.php b/resources/lang/it/validation.php
index 62f070119..786077da5 100755
--- a/resources/lang/it/validation.php
+++ b/resources/lang/it/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => 'Il campo :attribute deve essere tra i numeri :min e :max.',
'email' => 'Il campo :attribute deve essere un indirizzo email valido.',
'ends_with' => ':attribute deve terminare con uno dei seguenti: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'Il campo :attribute field is required.',
'gt' => [
'numeric' => ':attribute deve essere maggiore di :value.',
diff --git a/resources/lang/ja/validation.php b/resources/lang/ja/validation.php
index f8a7f1326..4c96087f9 100644
--- a/resources/lang/ja/validation.php
+++ b/resources/lang/ja/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attributeは:min〜:maxである必要があります。',
'email' => ':attributeは正しいEメールアドレスである必要があります。',
'ends_with' => ':attributeは:valuesのいずれかで終わる必要があります。',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attributeは必須です。',
'gt' => [
'numeric' => ':attributeは:valueより大きな値である必要があります。',
diff --git a/resources/lang/ko/validation.php b/resources/lang/ko/validation.php
index ef8328103..19e5afc38 100644
--- a/resources/lang/ko/validation.php
+++ b/resources/lang/ko/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute(을)를 :min~:max자리로 구성하세요.',
'email' => ':attribute(을)를 유효한 메일 주소로 구성하세요.',
'ends_with' => ':attribute(을)를 :values(으)로 끝나게 구성하세요.',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute(을)를 구성하세요.',
'gt' => [
'numeric' => ':attribute(을)를 :value(이)가 넘게 구성하세요.',
diff --git a/resources/lang/lt/validation.php b/resources/lang/lt/validation.php
index 8fa9234cc..08470cf22 100644
--- a/resources/lang/lt/validation.php
+++ b/resources/lang/lt/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute turi būti tarp :min ir :max skaitmenų.',
'email' => ':attribute turi būti tinkamas elektroninio pašto adresas.',
'ends_with' => ':attribute turi pasibaigti vienu iš šių: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute laukas yra privalomas.',
'gt' => [
'numeric' => ':attribute turi būti didesnis negu :value.',
diff --git a/resources/lang/lv/common.php b/resources/lang/lv/common.php
index 3cc648906..e859027bc 100644
--- a/resources/lang/lv/common.php
+++ b/resources/lang/lv/common.php
@@ -74,8 +74,8 @@ return [
'status' => 'Statuss',
'status_active' => 'Aktīvs',
'status_inactive' => 'Neaktīvs',
- 'never' => 'Never',
- 'none' => 'None',
+ 'never' => 'Nekad',
+ 'none' => 'Neviens',
// Header
'header_menu_expand' => 'Izvērst galvenes izvēlni',
diff --git a/resources/lang/lv/settings.php b/resources/lang/lv/settings.php
index a5d23584b..1d1148b74 100644
--- a/resources/lang/lv/settings.php
+++ b/resources/lang/lv/settings.php
@@ -246,7 +246,7 @@ return [
'webhooks_events_warning' => 'Ņemiet vērā, ka šie notikumi tiks palaisti visiem izvēlētajiem notikumiem, pat ja norādītas pielāgotas piekļuves tiesības. Pārliecineities, ka webhook lietošana neatklās ierobežotas pieejamības saturu.',
'webhooks_events_all' => 'Visi sistēmas notikumi',
'webhooks_name' => 'Webhook nosaukums',
- 'webhooks_timeout' => 'Webhook Request Timeout (Seconds)',
+ 'webhooks_timeout' => 'Webhook pieprasījuma laika ierobežojums (sekundēs)',
'webhooks_endpoint' => 'Webhook adrese (endpoint)',
'webhooks_active' => 'Webhook aktīvs',
'webhook_events_table_header' => 'Notikumi',
@@ -255,10 +255,10 @@ return [
'webhooks_delete_confirm' => 'Vai tiešām vēlaties dzēst šo webhook?',
'webhooks_format_example' => 'Webhook formāta piemērs',
'webhooks_format_example_desc' => 'Webhook dati tiek nosūtīti kā POST pieprasījums norādītajai endpoint adresei kā JSON tālāk norādītajā formātā. "related_item" un "url" īpašības nav obligātas un ir atkarīgas no palaistā notikuma veida.',
- 'webhooks_status' => 'Webhook Status',
- 'webhooks_last_called' => 'Last Called:',
- 'webhooks_last_errored' => 'Last Errored:',
- 'webhooks_last_error_message' => 'Last Error Message:',
+ 'webhooks_status' => 'Webhook statuss',
+ 'webhooks_last_called' => 'Pēdejoreiz izsaukts:',
+ 'webhooks_last_errored' => 'Pedējoreiz kļūda:',
+ 'webhooks_last_error_message' => 'Pēdējais kļūdas paziņojums:',
//! If editing translations files directly please ignore this in all
diff --git a/resources/lang/lv/validation.php b/resources/lang/lv/validation.php
index 8dd939746..c10a23cdd 100644
--- a/resources/lang/lv/validation.php
+++ b/resources/lang/lv/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute jābūt starp :min un :max cipariem.',
'email' => ':attribute jābūt derīgai e-pasta adresei.',
'ends_with' => ':attribute jābeidzas ar vienu no :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute lauks ir obligāts.',
'gt' => [
'numeric' => ':attribute jābūt lielākam kā :value.',
diff --git a/resources/lang/nb/validation.php b/resources/lang/nb/validation.php
index 684645729..0e8917f37 100644
--- a/resources/lang/nb/validation.php
+++ b/resources/lang/nb/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute må være mellomg :min og :max tall.',
'email' => ':attribute må være en gyldig e-post.',
'ends_with' => ':attribute må slutte med en av verdiene: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute feltet er påkrevd.',
'gt' => [
'numeric' => ':attribute må være større enn :value.',
diff --git a/resources/lang/nl/validation.php b/resources/lang/nl/validation.php
index c572ce85b..01183ea7d 100644
--- a/resources/lang/nl/validation.php
+++ b/resources/lang/nl/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute moet tussen de :min en :max cijfers zijn.',
'email' => ':attribute is geen geldig e-mailadres.',
'ends_with' => ':attribute moet eindigen met een van de volgende: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute is verplicht.',
'gt' => [
'numeric' => ':attribute moet groter zijn dan :value.',
diff --git a/resources/lang/pl/validation.php b/resources/lang/pl/validation.php
index ab4c9da7b..ebf4f76e6 100644
--- a/resources/lang/pl/validation.php
+++ b/resources/lang/pl/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute musi mieć od :min do :max cyfr.',
'email' => ':attribute musi być prawidłowym adresem e-mail.',
'ends_with' => ':attribute musi kończyć się jedną z poniższych wartości: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute jest wymagany.',
'gt' => [
'numeric' => ':attribute musi być większy niż :value.',
diff --git a/resources/lang/pt/validation.php b/resources/lang/pt/validation.php
index b5a15ed36..abf2ce4bf 100644
--- a/resources/lang/pt/validation.php
+++ b/resources/lang/pt/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => 'O campo :attribute deve ter entre :min e :max dígitos.',
'email' => 'O campo :attribute deve ser um endereço de e-mail válido.',
'ends_with' => 'O campo :attribute deve terminar com um dos seguintes: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'O campo :attribute é requerido.',
'gt' => [
'numeric' => 'O campo :attribute deve ser maior que :value.',
diff --git a/resources/lang/pt_BR/validation.php b/resources/lang/pt_BR/validation.php
index 705534cb6..9c778f6b9 100644
--- a/resources/lang/pt_BR/validation.php
+++ b/resources/lang/pt_BR/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => 'O campo :attribute deve ter entre :min e :max dígitos.',
'email' => 'O campo :attribute deve ser um e-mail válido.',
'ends_with' => 'O campo :attribute deve terminar com um dos seguintes: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'O campo :attribute é requerido.',
'gt' => [
'numeric' => 'O campo :attribute deve ser maior que :value.',
diff --git a/resources/lang/ru/validation.php b/resources/lang/ru/validation.php
index 45cc96155..a0dec2b56 100644
--- a/resources/lang/ru/validation.php
+++ b/resources/lang/ru/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute должен иметь от :min до :max цифр.',
'email' => ':attribute должен быть корректным email адресом.',
'ends_with' => ':attribute должен заканчиваться одним из следующих: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute поле необходимо.',
'gt' => [
'numeric' => 'Значение :attribute должно быть больше чем :value.',
diff --git a/resources/lang/sk/validation.php b/resources/lang/sk/validation.php
index 416c7e8de..20770e4b6 100644
--- a/resources/lang/sk/validation.php
+++ b/resources/lang/sk/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute musí mať medzi :min a :max číslicami.',
'email' => ':attribute musí byť platná emailová adresa.',
'ends_with' => ':attribute musí končiť jednou z nasledujúcich hodnôt :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'Políčko :attribute je povinné.',
'gt' => [
'numeric' => 'Hodnota :attribute musí byť väčšia ako :value.',
diff --git a/resources/lang/sl/validation.php b/resources/lang/sl/validation.php
index 5b08463ca..92060dd6d 100644
--- a/resources/lang/sl/validation.php
+++ b/resources/lang/sl/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute mora biti med :min in :max števkami.',
'email' => ':attribute mora biti veljaven e-naslov.',
'ends_with' => 'The :attribute se mora končati z eno od določenih: :vrednost/values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'Polje ne sme biti prazno.',
'gt' => [
'numeric' => ':attribute mora biti večji kot :vrednost.',
diff --git a/resources/lang/sv/validation.php b/resources/lang/sv/validation.php
index 0c9cc3164..2d7f1da9a 100644
--- a/resources/lang/sv/validation.php
+++ b/resources/lang/sv/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute måste vara mellan :min och :max siffror.',
'email' => ':attribute måste vara en giltig e-postadress.',
'ends_with' => ':attribute måste sluta med något av följande: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute är obligatoriskt.',
'gt' => [
'numeric' => ':attribute måste vara större än :value.',
diff --git a/resources/lang/tr/validation.php b/resources/lang/tr/validation.php
index 9cd8093d4..50a30a5b5 100644
--- a/resources/lang/tr/validation.php
+++ b/resources/lang/tr/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute, en az :min ve en fazla :max basamaklı olmalıdır.',
'email' => ':attribute, geçerli bir e-posta adresi olmalıdır.',
'ends_with' => ':attribute, şunlardan birisiyle bitmelidir: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute alanı zorunludur.',
'gt' => [
'numeric' => ':attribute, :max değerinden büyük olmalıdır.',
diff --git a/resources/lang/uk/validation.php b/resources/lang/uk/validation.php
index 25322f2d9..a7fad6bf8 100644
--- a/resources/lang/uk/validation.php
+++ b/resources/lang/uk/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => 'Довжина цифрового поля :attribute повинна бути від :min до :max.',
'email' => 'Поле :attribute повинне містити коректну електронну адресу.',
'ends_with' => 'Поле :attribute має закінчуватися одним з наступних значень: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'Поле :attribute є обов\'язковим для заповнення.',
'gt' => [
'numeric' => 'Поле :attribute має бути більше ніж :value.',
diff --git a/resources/lang/vi/validation.php b/resources/lang/vi/validation.php
index 7e237cf9e..274e747f2 100644
--- a/resources/lang/vi/validation.php
+++ b/resources/lang/vi/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute phải có từ :min đến :max chữ số.',
'email' => ':attribute phải là địa chỉ email hợp lệ.',
'ends_with' => ':attribute phải kết thúc bằng một trong các ký tự: :values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => 'Trường :attribute là bắt buộc.',
'gt' => [
'numeric' => ':attribute phải lớn hơn :value.',
diff --git a/resources/lang/zh_CN/common.php b/resources/lang/zh_CN/common.php
index 36fc63ca2..ea62f2b97 100644
--- a/resources/lang/zh_CN/common.php
+++ b/resources/lang/zh_CN/common.php
@@ -75,7 +75,7 @@ return [
'status_active' => '已激活',
'status_inactive' => '未激活',
'never' => '从未',
- 'none' => 'None',
+ 'none' => '无',
// Header
'header_menu_expand' => '展开标头菜单',
diff --git a/resources/lang/zh_CN/validation.php b/resources/lang/zh_CN/validation.php
index 3398a1142..e38446e9f 100644
--- a/resources/lang/zh_CN/validation.php
+++ b/resources/lang/zh_CN/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute 必须为:min到:max位数。',
'email' => ':attribute 必须是有效的电子邮件地址。',
'ends_with' => ' :attribute 必须以 :values 后缀结尾',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute 字段是必需的。',
'gt' => [
'numeric' => ':attribute必须大于 :value.',
diff --git a/resources/lang/zh_TW/validation.php b/resources/lang/zh_TW/validation.php
index e93c182ee..2053674a6 100644
--- a/resources/lang/zh_TW/validation.php
+++ b/resources/lang/zh_TW/validation.php
@@ -32,6 +32,7 @@ return [
'digits_between' => ':attribute 必須為 :min 到 :max 位數。',
'email' => ':attribute 必須是有效的電子郵件地址。',
'ends_with' => ':attribute必須以下列之一結尾::values',
+ 'file' => 'The :attribute must be provided as a valid file.',
'filled' => ':attribute 欄位必填。',
'gt' => [
'numeric' => ':attribute 必須大於 :value。',
diff --git a/tests/Api/AttachmentsApiTest.php b/tests/Api/AttachmentsApiTest.php
index bfa47343e..d7625c938 100644
--- a/tests/Api/AttachmentsApiTest.php
+++ b/tests/Api/AttachmentsApiTest.php
@@ -102,6 +102,30 @@ class AttachmentsApiTest extends TestCase
unlink(storage_path($newItem->path));
}
+ public function test_upload_limit_restricts_attachment_uploads()
+ {
+ $this->actingAsApiAdmin();
+ /** @var Page $page */
+ $page = Page::query()->first();
+
+ config()->set('app.upload_limit', 1);
+
+ $file = tmpfile();
+ $filePath = stream_get_meta_data($file)['uri'];
+ fwrite($file, str_repeat('a', 1200000));
+ $file = new UploadedFile($filePath, 'test.txt', 'text/plain', null, true);
+
+ $details = [
+ 'name' => 'My attachment',
+ 'uploaded_to' => $page->id,
+ ];
+ $resp = $this->call('POST', $this->baseEndpoint, $details, [], ['file' => $file]);
+ $resp->assertStatus(422);
+ $resp->assertJson($this->validationResponse([
+ 'file' => ['The file may not be greater than 1000 kilobytes.'],
+ ]));
+ }
+
public function test_name_needed_to_create()
{
$this->actingAsApiAdmin();
@@ -115,15 +139,7 @@ class AttachmentsApiTest extends TestCase
$resp = $this->postJson($this->baseEndpoint, $details);
$resp->assertStatus(422);
- $resp->assertJson([
- 'error' => [
- 'message' => 'The given data was invalid.',
- 'validation' => [
- 'name' => ['The name field is required.'],
- ],
- 'code' => 422,
- ],
- ]);
+ $resp->assertJson($this->validationResponse(['name' => ['The name field is required.']]));
}
public function test_link_or_file_needed_to_create()
@@ -139,16 +155,27 @@ class AttachmentsApiTest extends TestCase
$resp = $this->postJson($this->baseEndpoint, $details);
$resp->assertStatus(422);
- $resp->assertJson([
- 'error' => [
- 'message' => 'The given data was invalid.',
- 'validation' => [
- 'file' => ['The file field is required when link is not present.'],
- 'link' => ['The link field is required when file is not present.'],
- ],
- 'code' => 422,
- ],
- ]);
+ $resp->assertJson($this->validationResponse([
+ 'file' => ['The file field is required when link is not present.'],
+ 'link' => ['The link field is required when file is not present.'],
+ ]));
+ }
+
+ public function test_message_shown_if_file_is_not_a_valid_file()
+ {
+ $this->actingAsApiAdmin();
+ /** @var Page $page */
+ $page = Page::query()->first();
+
+ $details = [
+ 'name' => 'my attachment',
+ 'uploaded_to' => $page->id,
+ 'file' => 'cat',
+ ];
+
+ $resp = $this->postJson($this->baseEndpoint, $details);
+ $resp->assertStatus(422);
+ $resp->assertJson($this->validationResponse(['file' => ['The file must be provided as a valid file.']]));
}
public function test_read_endpoint_for_link_attachment()
diff --git a/tests/Entity/PageContentTest.php b/tests/Entity/PageContentTest.php
index 9524186c8..20cde049a 100644
--- a/tests/Entity/PageContentTest.php
+++ b/tests/Entity/PageContentTest.php
@@ -657,6 +657,39 @@ class PageContentTest extends TestCase
$this->deleteImage($imagePath);
}
+ public function test_markdown_base64_extract_not_limited_by_pcre_limits()
+ {
+ $pcreBacktrackLimit = ini_get('pcre.backtrack_limit');
+ $pcreRecursionLimit = ini_get('pcre.recursion_limit');
+
+ $this->asEditor();
+ $page = Page::query()->first();
+
+ ini_set('pcre.backtrack_limit', '500');
+ ini_set('pcre.recursion_limit', '500');
+
+ $content = str_repeat('a', 5000);
+ $base64Content = base64_encode($content);
+
+ $this->put($page->getUrl(), [
+ 'name' => $page->name, 'summary' => '',
+ 'markdown' => 'test  ',
+ ]);
+
+ $page->refresh();
+ $this->assertStringMatchesFormat('test
%A