From 7dc965d707d3e0c9c2c4aae74f3275e8045fa1a1 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sat, 10 Oct 2020 18:20:55 +0200 Subject: [PATCH 001/223] New translations en.json (Occitan) --- i18n/oc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/oc.json b/i18n/oc.json index ba9e69d1..3a2e09c2 100644 --- a/i18n/oc.json +++ b/i18n/oc.json @@ -7,7 +7,7 @@ "%s requires php %s or above to work. Sorry.": "O planhèm, %s necessita php %s o superior per foncionar.", "%s requires configuration section [%s] to be present in configuration file.": "%s fa besonh de la seccion de configuracion [%s] dins lo fichièr de configuracion per foncionar.", "Please wait %d seconds between each post.": [ - "Mercés d'esperar %d segonde entre cada publicacion.", + "Mercés d'esperar %d segonda entre cada publicacion", "Mercés d'esperar %d segondas entre cada publicacion.", "Mercés d'esperar %d segondas entre cada publicacion.", "Mercés d'esperar %d segondas entre cada publicacion." From 7a2592ba500b1d42336e0585bd0c0014edd2d29d Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 11 Oct 2020 11:31:19 +0200 Subject: [PATCH 002/223] New translations en.json (Occitan) --- i18n/oc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/oc.json b/i18n/oc.json index 3a2e09c2..39d846cf 100644 --- a/i18n/oc.json +++ b/i18n/oc.json @@ -7,7 +7,7 @@ "%s requires php %s or above to work. Sorry.": "O planhèm, %s necessita php %s o superior per foncionar.", "%s requires configuration section [%s] to be present in configuration file.": "%s fa besonh de la seccion de configuracion [%s] dins lo fichièr de configuracion per foncionar.", "Please wait %d seconds between each post.": [ - "Mercés d'esperar %d segonda entre cada publicacion", + "Mercés d'esperar %d segonda entre cada publicacion.", "Mercés d'esperar %d segondas entre cada publicacion.", "Mercés d'esperar %d segondas entre cada publicacion.", "Mercés d'esperar %d segondas entre cada publicacion." From eb32ea141956c0ed72e3186956895333f62e271c Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 1 Sep 2020 07:59:28 +0200 Subject: [PATCH 003/223] Make it possible to change the info text This makes it possible to change the last part of the info text and replace it with something individual. E.g pointing to the cmdline client. Signed-off-by: Andreas Schneider --- cfg/conf.sample.php | 3 +++ i18n/ar.json | 3 ++- i18n/bg.json | 3 ++- i18n/cs.json | 3 ++- i18n/de.json | 3 ++- i18n/el.json | 3 ++- i18n/en.json | 3 ++- i18n/es.json | 3 ++- i18n/fr.json | 3 ++- i18n/he.json | 3 ++- i18n/hi.json | 3 ++- i18n/hu.json | 3 ++- i18n/it.json | 3 ++- i18n/ja.json | 3 ++- i18n/ku.json | 3 ++- i18n/la.json | 3 ++- i18n/nl.json | 3 ++- i18n/no.json | 3 ++- i18n/oc.json | 3 ++- i18n/pl.json | 3 ++- i18n/pt.json | 3 ++- i18n/ru.json | 3 ++- i18n/sl.json | 3 ++- i18n/sv.json | 3 ++- i18n/tr.json | 3 ++- i18n/uk.json | 3 ++- i18n/zh.json | 3 ++- lib/Configuration.php | 1 + lib/Controller.php | 1 + tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 31 files changed, 59 insertions(+), 28 deletions(-) diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php index 6b9295e4..f3254ce8 100644 --- a/cfg/conf.sample.php +++ b/cfg/conf.sample.php @@ -39,6 +39,9 @@ sizelimit = 10485760 ; template to include, default is "bootstrap" (tpl/bootstrap.php) template = "bootstrap" +; (optional) info text to display +;info = "More information on the project page." + ; (optional) notice to display ; notice = "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service." diff --git a/i18n/ar.json b/i18n/ar.json index 482d6706..7312aa0d 100644 --- a/i18n/ar.json +++ b/i18n/ar.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.", + "More information on the project page.": "More information on the project page.", "Because ignorance is bliss": "Because ignorance is bliss", "en": "ar", "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", diff --git a/i18n/bg.json b/i18n/bg.json index 7d536ed8..e0ac98c7 100644 --- a/i18n/bg.json +++ b/i18n/bg.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s е изчистен и изцяло достъпен като отворен код, онлайн \"paste\" услуга, където сървъра не знае подадената информация. Тя се шифрова/дешифрова във браузъра използвайки 256 битов AES алгоритъм. Повече информация може да намерите на страницата на проекта (Английски)", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s е изчистен и изцяло достъпен като отворен код, онлайн \"paste\" услуга, където сървъра не знае подадената информация. Тя се шифрова/дешифрова във браузъра използвайки 256 битов AES алгоритъм.", + "More information on the project page.": "Повече информация може да намерите на страницата на проекта (Английски).", "Because ignorance is bliss": "Невежеството е блаженство", "en": "bg", "Paste does not exist, has expired or has been deleted.": "Информацията не съществува, срокът и е изтекъл или е била изтрита.", diff --git a/i18n/cs.json b/i18n/cs.json index e5540fc5..711ae588 100644 --- a/i18n/cs.json +++ b/i18n/cs.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s je minimalistický open source 'pastebin' server, který neanalyzuje vložená data. Data jsou šifrována v prohlížeči pomocí 256 bitů AES. Více informací na stránce projetu.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s je minimalistický open source 'pastebin' server, který neanalyzuje vložená data. Data jsou šifrována v prohlížeči pomocí 256 bitů AES.", + "More information on the project page.": "Více informací na stránce projetu.", "Because ignorance is bliss": "Protože nevědomost je sladká", "en": "cs", "Paste does not exist, has expired or has been deleted.": "Vložený text neexistuje, expiroval nebo byl odstraněn.", diff --git a/i18n/de.json b/i18n/de.json index b40d2911..17ee8496 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s ist ein minimalistischer, quelloffener \"Pastebin\"-artiger Dienst, bei dem der Server keinerlei Kenntnis der Inhalte hat. Die Daten werden im Browser mit 256 Bit AES ver- und entschlüsselt. Weitere Informationen sind auf der Projektseite zu finden.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s ist ein minimalistischer, quelloffener \"Pastebin\"-artiger Dienst, bei dem der Server keinerlei Kenntnis der Inhalte hat. Die Daten werden im Browser mit 256 Bit AES ver- und entschlüsselt.", + "More information on the project page.": "Weitere Informationen sind auf der Projektseite zu finden.", "Because ignorance is bliss": "Unwissenheit ist ein Segen", "en": "de", "Paste does not exist, has expired or has been deleted.": "Diesen Text gibt es nicht, er ist abgelaufen oder wurde gelöscht.", diff --git a/i18n/el.json b/i18n/el.json index c263340d..93c53fc0 100644 --- a/i18n/el.json +++ b/i18n/el.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.", + "More information on the project page.": "More information on the project page.", "Because ignorance is bliss": "Because ignorance is bliss", "en": "el", "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", diff --git a/i18n/en.json b/i18n/en.json index ddac0a5f..d5e3b474 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.", + "More information on the project page.": "More information on the project page.", "Because ignorance is bliss": "Because ignorance is bliss", "en": "en", "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", diff --git a/i18n/es.json b/i18n/es.json index e371c5c3..8bf1bed5 100644 --- a/i18n/es.json +++ b/i18n/es.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s es un \"pastebin\" en línea minimalista de código abierto, donde el servidor no tiene ningún conocimiento de los datos guardados. Los datos son cifrados/descifrados en el navegador usando 256 bits AES. Más información en la página del proyecto.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s es un \"pastebin\" en línea minimalista de código abierto, donde el servidor no tiene ningún conocimiento de los datos guardados. Los datos son cifrados/descifrados en el navegador usando 256 bits AES.", + "More information on the project page.": "Más información en la página del proyecto.", "Because ignorance is bliss": "Porque la ignorancia es dicha", "en": "es", "Paste does not exist, has expired or has been deleted.": "El \"paste\" no existe, ha caducado o ha sido eliminado.", diff --git a/i18n/fr.json b/i18n/fr.json index 429c3653..484eb0c7 100644 --- a/i18n/fr.json +++ b/i18n/fr.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s est un 'pastebin' (ou gestionnaire d'extraits de texte et de code source) minimaliste et open source, dans lequel le serveur n'a aucune connaissance des données envoyées. Les données sont chiffrées/déchiffrées dans le navigateur par un chiffrement AES 256 bits. Plus d'informations sur la page du projet.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s est un 'pastebin' (ou gestionnaire d'extraits de texte et de code source) minimaliste et open source, dans lequel le serveur n'a aucune connaissance des données envoyées. Les données sont chiffrées/déchiffrées dans le navigateur par un chiffrement AES 256 bits.", + "More information on the project page.": "Plus d'informations sur la page du projet.", "Because ignorance is bliss": "Parce que l'ignorance c'est le bonheur", "en": "fr", "Paste does not exist, has expired or has been deleted.": "Le paste n'existe pas, a expiré, ou a été supprimé.", diff --git a/i18n/he.json b/i18n/he.json index 52f8992d..c76313ea 100644 --- a/i18n/he.json +++ b/i18n/he.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.", + "More information on the project page.": "More information on the project page.", "Because ignorance is bliss": "כיוון שבורות היא ברכה", "en": "he", "Paste does not exist, has expired or has been deleted.": "ההדבקה לא קיימת, פגה או נמחקה.", diff --git a/i18n/hi.json b/i18n/hi.json index 5a3e6037..d775b09d 100644 --- a/i18n/hi.json +++ b/i18n/hi.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.", + "More information on the project page.": "More information on the project page.", "Because ignorance is bliss": "Because ignorance is bliss", "en": "hi", "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", diff --git a/i18n/hu.json b/i18n/hu.json index 3aa27584..23d47d85 100644 --- a/i18n/hu.json +++ b/i18n/hu.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "A %s egy minimalista, nyílt forráskódú adattároló szoftver, ahol a szerver semmilyen információt nem tárol a feltett adatról. Azt ugyanis a böngésződ segítségével titkosítja és oldja fel 256 bit hosszú titkosítási kulcsú AES-t használva. További információt a projekt oldalán találsz.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "A %s egy minimalista, nyílt forráskódú adattároló szoftver, ahol a szerver semmilyen információt nem tárol a feltett adatról. Azt ugyanis a böngésződ segítségével titkosítja és oldja fel 256 bit hosszú titkosítási kulcsú AES-t használva.", + "More information on the project page.": "További információt a projekt oldalán találsz.", "Because ignorance is bliss": "A titok egyfajta hatalom.", "en": "hu", "Paste does not exist, has expired or has been deleted.": "A bejegyzés nem létezik, lejárt vagy törölve lett.", diff --git a/i18n/it.json b/i18n/it.json index 6dc13a4e..e32e4f21 100644 --- a/i18n/it.json +++ b/i18n/it.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s è un sistema di tipo \"Pastebin\" online, open source, minimalista. Il server non possiede alcuna conoscenza (\"Zero Knowledge\") del contenuto dei dati inviati. I dati sono cifrati/decifrati nel Browser con algoritmo AES a 256 Bit. Per ulteriori informazioni, vedi Sito del progetto.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s è un sistema di tipo \"Pastebin\" online, open source, minimalista. Il server non possiede alcuna conoscenza (\"Zero Knowledge\") del contenuto dei dati inviati. I dati sono cifrati/decifrati nel Browser con algoritmo AES a 256 Bit.", + "More information on the project page.": "Per ulteriori informazioni, vedi Sito del progetto.", "Because ignorance is bliss": "Perché l'ignoranza è una benedizione (Because ignorance is bliss)", "en": "it", "Paste does not exist, has expired or has been deleted.": "Questo messaggio non esiste, è scaduto o è stato cancellato.", diff --git a/i18n/ja.json b/i18n/ja.json index f775dbb7..9368a681 100644 --- a/i18n/ja.json +++ b/i18n/ja.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.", + "More information on the project page.": "More information on the project page.", "Because ignorance is bliss": "Because ignorance is bliss", "en": "ja", "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", diff --git a/i18n/ku.json b/i18n/ku.json index 3ae85137..c1897da6 100644 --- a/i18n/ku.json +++ b/i18n/ku.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.", + "More information on the project page.": "More information on the project page.", "Because ignorance is bliss": "Because ignorance is bliss", "en": "ku", "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", diff --git a/i18n/la.json b/i18n/la.json index cdb4d0fd..babeb96c 100644 --- a/i18n/la.json +++ b/i18n/la.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivatumVinariam", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.", + "More information on the project page.": "More information on the project page.", "Because ignorance is bliss": "Because ignorance is bliss", "en": "la", "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", diff --git a/i18n/nl.json b/i18n/nl.json index 7eab51a6..76c9a901 100644 --- a/i18n/nl.json +++ b/i18n/nl.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s is een minimalistische, open source online pastebin waarbij de server geen kennis heeft van de geplakte gegevens. Gegevens worden gecodeerd/gedecodeerd in de browser met behulp van 256 bits AES. Meer informatie is te vinden op de projectpagina.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s is een minimalistische, open source online pastebin waarbij de server geen kennis heeft van de geplakte gegevens. Gegevens worden gecodeerd/gedecodeerd in de browser met behulp van 256 bits AES.", + "More information on the project page.": "Meer informatie is te vinden op de projectpagina.", "Because ignorance is bliss": "Onwetendheid is een zegen", "en": "nl", "Paste does not exist, has expired or has been deleted.": "Geplakte tekst bestaat niet, is verlopen of verwijderd.", diff --git a/i18n/no.json b/i18n/no.json index 34389307..bf26fff4 100644 --- a/i18n/no.json +++ b/i18n/no.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s er en minimalistisk, åpen kildekode, elektronisk tilgjengelig pastebin hvor serveren ikke har kunnskap om dataene som limes inn. Dataene krypteres/dekrypteres i nettleseren ved hjelp av 256 bits AES. Mer informasjon om prosjektet på prosjektsiden.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s er en minimalistisk, åpen kildekode, elektronisk tilgjengelig pastebin hvor serveren ikke har kunnskap om dataene som limes inn. Dataene krypteres/dekrypteres i nettleseren ved hjelp av 256 bits AES.", + "More information on the project page.": "Mer informasjon om prosjektet på prosjektsiden.", "Because ignorance is bliss": "Fordi uvitenhet er lykke", "en": "no", "Paste does not exist, has expired or has been deleted.": "Innlegget eksisterer ikke, er utløpt eller har blitt slettet.", diff --git a/i18n/oc.json b/i18n/oc.json index ba9e69d1..9d693260 100644 --- a/i18n/oc.json +++ b/i18n/oc.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s es un 'pastebin' (o gestionari d’extrachs de tèxte e còdi font) minimalista e open source, dins lo qual lo servidor a pas cap de coneissença de las donadas mandadas. Las donadas son chifradas/deschifradas dins lo navigator per un chiframent AES 256 bits. Mai informacions sus la pagina del projècte.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s es un 'pastebin' (o gestionari d’extrachs de tèxte e còdi font) minimalista e open source, dins lo qual lo servidor a pas cap de coneissença de las donadas mandadas. Las donadas son chifradas/deschifradas dins lo navigator per un chiframent AES 256 bits.", + "More information on the project page.": "Mai informacions sus la pagina del projècte.", "Because ignorance is bliss": "Perque lo bonaür es l’ignorància", "en": "oc", "Paste does not exist, has expired or has been deleted.": "Lo tèxte existís pas, a expirat, o es estat suprimit.", diff --git a/i18n/pl.json b/i18n/pl.json index 45c5c968..18e7479b 100644 --- a/i18n/pl.json +++ b/i18n/pl.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s jest minimalistycznym, otwartoźródłowym serwisem typu pastebin, w którym serwer nie ma jakichkolwiek informacji o tym, co jest wklejane. Dane są szyfrowane i deszyfrowane w przeglądarce z użyciem 256-bitowego klucza AES. Więcej informacji na stronie projektu.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s jest minimalistycznym, otwartoźródłowym serwisem typu pastebin, w którym serwer nie ma jakichkolwiek informacji o tym, co jest wklejane. Dane są szyfrowane i deszyfrowane w przeglądarce z użyciem 256-bitowego klucza AES.", + "More information on the project page.": "Więcej informacji na stronie projektu.", "Because ignorance is bliss": "Ponieważ ignorancja jest cnotą", "en": "pl", "Paste does not exist, has expired or has been deleted.": "Wklejka nie istnieje, wygasła albo została usunięta.", diff --git a/i18n/pt.json b/i18n/pt.json index afff1370..114d4510 100644 --- a/i18n/pt.json +++ b/i18n/pt.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s é um serviço minimalista e de código aberto do tipo \"pastebin\", em que o servidor tem zero conhecimento dos dados copiados. Os dados são cifrados e decifrados no navegador usando 256 bits AES. Mais informações na página do projeto.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s é um serviço minimalista e de código aberto do tipo \"pastebin\", em que o servidor tem zero conhecimento dos dados copiados. Os dados são cifrados e decifrados no navegador usando 256 bits AES.", + "More information on the project page.": "Mais informações na página do projeto.", "Because ignorance is bliss": "Porque a ignorância é uma benção", "en": "pt", "Paste does not exist, has expired or has been deleted.": "A cópia não existe, expirou ou já foi excluída.", diff --git a/i18n/ru.json b/i18n/ru.json index 5b7ace41..a1fa42b3 100644 --- a/i18n/ru.json +++ b/i18n/ru.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s это минималистичный Open Source проект для создания заметок, где сервер не знает ничего о сохраняемых данных. Данные шифруются/расшифровываются в браузере с использованием 256 битного шифрования AES. Подробнее можно узнать на сайте проекта.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s это минималистичный Open Source проект для создания заметок, где сервер не знает ничего о сохраняемых данных. Данные шифруются/расшифровываются в браузере с использованием 256 битного шифрования AES.", + "More information on the project page.": "Подробнее можно узнать на сайте проекта.", "Because ignorance is bliss": "Потому что неведение - благо", "en": "ru", "Paste does not exist, has expired or has been deleted.": "Запись не существует, просрочена или была удалена.", diff --git a/i18n/sl.json b/i18n/sl.json index de7c2b3e..15df291f 100644 --- a/i18n/sl.json +++ b/i18n/sl.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s je minimalističen, odprtokodni spletni 'pastebin', kjer server ne ve ničesar o prilepljenih podatkih. Podatki so zakodirani/odkodirani v brskalniku z uporabo 256 bitnega AES. Več informacij na spletni strani projekta..", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s je minimalističen, odprtokodni spletni 'pastebin', kjer server ne ve ničesar o prilepljenih podatkih. Podatki so zakodirani/odkodirani v brskalniku z uporabo 256 bitnega AES.", + "More information on the project page.": "Več informacij na spletni strani projekta..", "Because ignorance is bliss": "Ker kar ne veš ne boli.", "en": "sl", "Paste does not exist, has expired or has been deleted.": "Prilepek ne obstaja, mu je potekla življenjska doba, ali pa je izbrisan.", diff --git a/i18n/sv.json b/i18n/sv.json index 7de08313..f94a7866 100644 --- a/i18n/sv.json +++ b/i18n/sv.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.", + "More information on the project page.": "More information on the project page.", "Because ignorance is bliss": "Because ignorance is bliss", "en": "sv", "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", diff --git a/i18n/tr.json b/i18n/tr.json index 3902c3f7..876cb56d 100644 --- a/i18n/tr.json +++ b/i18n/tr.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.", + "More information on the project page.": "More information on the project page.", "Because ignorance is bliss": "Because ignorance is bliss", "en": "tr", "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", diff --git a/i18n/uk.json b/i18n/uk.json index 73ddd3ed..6aa0e7fa 100644 --- a/i18n/uk.json +++ b/i18n/uk.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s це мінімалістичний Open Source проєкт для створення нотаток, де сервер не знає нічого про дані, що зберігаються. Дані шифруються/розшифровуються у переглядачі з використанням 256-бітного шифрувания AES. Подробиці можна дізнатися на сайті проєкту.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s це мінімалістичний Open Source проєкт для створення нотаток, де сервер не знає нічого про дані, що зберігаються. Дані шифруються/розшифровуються у переглядачі з використанням 256-бітного шифрувания AES.", + "More information on the project page.": "Подробиці можна дізнатися на сайті проєкту.", "Because ignorance is bliss": "Бо незнання - благо", "en": "uk", "Paste does not exist, has expired or has been deleted.": "Допис не існує, протермінований чи був видалений.", diff --git a/i18n/zh.json b/i18n/zh.json index 880f96bf..cdf990a5 100644 --- a/i18n/zh.json +++ b/i18n/zh.json @@ -1,6 +1,7 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES. More information on the project page.": "%s是一个极简、开源、对粘贴内容毫不知情的在线粘贴板,数据在浏览器内进行AES-256加密。更多信息请查看项目主页。", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s是一个极简、开源、对粘贴内容毫不知情的在线粘贴板,数据在浏览器内进行AES-256加密。", + "More information on the project page.": "更多信息请查看项目主页。", "Because ignorance is bliss": "因为无知是福", "en": "zh", "Paste does not exist, has expired or has been deleted.": "粘贴内容不存在,已过期或已被删除。", diff --git a/lib/Configuration.php b/lib/Configuration.php index 06783706..962d023b 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -48,6 +48,7 @@ class Configuration 'syntaxhighlightingtheme' => null, 'sizelimit' => 10485760, 'template' => 'bootstrap', + 'info' => 'More information on the project page.', 'notice' => '', 'languageselection' => false, 'languagedefault' => '', diff --git a/lib/Controller.php b/lib/Controller.php index 744a5237..b1e2175e 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -380,6 +380,7 @@ class Controller $page->assign('SYNTAXHIGHLIGHTINGTHEME', $this->_conf->getKey('syntaxhighlightingtheme')); $page->assign('FORMATTER', $formatters); $page->assign('FORMATTERDEFAULT', $this->_conf->getKey('defaultformatter')); + $page->assign('INFO', I18n::_($this->_conf->getKey('info'))); $page->assign('NOTICE', I18n::_($this->_conf->getKey('notice'))); $page->assign('BURNAFTERREADINGSELECTED', $this->_conf->getKey('burnafterreadingselected')); $page->assign('PASSWORD', $this->_conf->getKey('password')); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index eef04448..deae4cd1 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -578,7 +578,7 @@ endif;

-

- in the browser using 256 bits AES. More information on the project page.', I18n::_($NAME)), PHP_EOL; ?> + in the browser using 256 bits AES.', I18n::_($NAME)), ' ', I18n::_($INFO), PHP_EOL; ?>

diff --git a/tpl/page.php b/tpl/page.php index 52ed5638..2c4e825e 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -76,7 +76,7 @@ endif;
- in the browser using 256 bits AES. More information on the project page.', I18n::_($NAME)); ?>
+ in the browser using 256 bits AES.', I18n::_($NAME)), ' ', I18n::_($INFO); ?>
From bb6a44ce7a5d6181fe54135ecb472f09e4202170 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Tue, 13 Oct 2020 07:28:35 +0200 Subject: [PATCH 004/223] remove double translation, avoid unsupported double quotes in INI file --- cfg/conf.sample.php | 3 ++- lib/Configuration.php | 2 +- lib/Controller.php | 2 +- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- tst/ViewTest.php | 1 + 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php index f3254ce8..e958c88d 100644 --- a/cfg/conf.sample.php +++ b/cfg/conf.sample.php @@ -40,7 +40,8 @@ sizelimit = 10485760 template = "bootstrap" ; (optional) info text to display -;info = "More information on the project page." +; use single, instead of double quotes for HTML attributes +;info = "More information on the project page." ; (optional) notice to display ; notice = "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service." diff --git a/lib/Configuration.php b/lib/Configuration.php index 962d023b..b598326b 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -48,7 +48,7 @@ class Configuration 'syntaxhighlightingtheme' => null, 'sizelimit' => 10485760, 'template' => 'bootstrap', - 'info' => 'More information on the project page.', + 'info' => 'More information on the project page.', 'notice' => '', 'languageselection' => false, 'languagedefault' => '', diff --git a/lib/Controller.php b/lib/Controller.php index b1e2175e..65243aaf 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -380,7 +380,7 @@ class Controller $page->assign('SYNTAXHIGHLIGHTINGTHEME', $this->_conf->getKey('syntaxhighlightingtheme')); $page->assign('FORMATTER', $formatters); $page->assign('FORMATTERDEFAULT', $this->_conf->getKey('defaultformatter')); - $page->assign('INFO', I18n::_($this->_conf->getKey('info'))); + $page->assign('INFO', I18n::_(str_replace("'", '"', $this->_conf->getKey('info')))); $page->assign('NOTICE', I18n::_($this->_conf->getKey('notice'))); $page->assign('BURNAFTERREADINGSELECTED', $this->_conf->getKey('burnafterreadingselected')); $page->assign('PASSWORD', $this->_conf->getKey('password')); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index deae4cd1..e476a87b 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -578,7 +578,7 @@ endif;

-

- in the browser using 256 bits AES.', I18n::_($NAME)), ' ', I18n::_($INFO), PHP_EOL; ?> + in the browser using 256 bits AES.', I18n::_($NAME)), ' ', $INFO, PHP_EOL; ?>

diff --git a/tpl/page.php b/tpl/page.php index 2c4e825e..f960557b 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -76,7 +76,7 @@ endif;
- in the browser using 256 bits AES.', I18n::_($NAME)), ' ', I18n::_($INFO); ?>
+ in the browser using 256 bits AES.', I18n::_($NAME)), ' ', $INFO; ?>
diff --git a/tst/ViewTest.php b/tst/ViewTest.php index 61530521..c729b4ef 100644 --- a/tst/ViewTest.php +++ b/tst/ViewTest.php @@ -49,6 +49,7 @@ class ViewTest extends PHPUnit_Framework_TestCase $page->assign('PASSWORD', true); $page->assign('FILEUPLOAD', false); $page->assign('ZEROBINCOMPATIBILITY', false); + $page->assign('INFO', 'example'); $page->assign('NOTICE', 'example'); $page->assign('LANGUAGESELECTION', ''); $page->assign('LANGUAGES', I18n::getLanguageLabels(I18n::getAvailableLanguages())); From 300bd61c2ef5fc02686f3df67ec3d7b7d51f0d68 Mon Sep 17 00:00:00 2001 From: Men770 Date: Tue, 13 Oct 2020 09:22:05 +0300 Subject: [PATCH 005/223] Update he.json --- i18n/he.json | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/i18n/he.json b/i18n/he.json index c76313ea..8e3933fc 100644 --- a/i18n/he.json +++ b/i18n/he.json @@ -5,7 +5,7 @@ "Because ignorance is bliss": "כיוון שבורות היא ברכה", "en": "he", "Paste does not exist, has expired or has been deleted.": "ההדבקה לא קיימת, פגה או נמחקה.", - "%s requires php %s or above to work. Sorry.": "%s requires php %s or above to work. Sorry.", + "%s requires php %s or above to work. Sorry.": "%s דורש PHP %s כדי לפעול.", "%s requires configuration section [%s] to be present in configuration file.": "%s דורש שסעיף ההגדרות [%s] יהיה קיים בקובץ ההגדרות.", "Please wait %d seconds between each post.": [ "נא להמתין שנייה אחת בין פרסום לפרסום.", @@ -23,7 +23,7 @@ "Wrong deletion token. Paste was not deleted.": "אסימון מחיקה שגוי. ההדבקה לא נמחקה.", "Paste was properly deleted.": "ההדבקה נמחקה כראוי.", "JavaScript is required for %s to work. Sorry for the inconvenience.": "צריך JavaScript כדי לאפשר ל־%s לפעול. סליחה על חוסר הנוחות.", - "%s requires a modern browser to work.": "%s requires a modern browser to work.", + "%s requires a modern browser to work.": "%s דורש דפדפן מודרני כדי לפעול.", "New": "חדש", "Send": "שליחה", "Clone": "שכפול", @@ -53,31 +53,31 @@ "%d hours (3rd plural)" ], "%d days": [ - "%d day (singular)", - "%d days (1st plural)", - "%d days (2nd plural)", - "%d days (3rd plural)" + "יום אחד", + "%d ימים", + "%d ימים", + "%d ימים" ], "%d weeks": [ - "%d week (singular)", - "%d weeks (1st plural)", - "%d weeks (2nd plural)", - "%d weeks (3rd plural)" + "שבוע אחד", + "%d שבועות", + "%d שבועות", + "%d שבועות" ], "%d months": [ - "%d month (singular)", - "%d months (1st plural)", - "%d months (2nd plural)", - "%d months (3rd plural)" + "חודש אחד", + "%d חודשים", + "%d חודשים", + "%d חודשים" ], "%d years": [ - "%d year (singular)", - "%d years (1st plural)", - "%d years (2nd plural)", - "%d years (3rd plural)" + "שנה אחת", + "%d שנים", + "%d שנים", + "%d שנים" ], "Never": "לעולם לא", - "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.", + "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "הערה: זהו שירות בדקה: המידע לא ישמר.", "This document will expire in %d seconds.": [ "This document will expire in %d second. (singular)", "This document will expire in %d seconds. (1st plural)", @@ -113,7 +113,7 @@ "Could not delete the paste, it was not stored in burn after reading mode.": "לא ניתן למחוק את ההדבקה, היא לא אוחסנה במצב קוראים-שורפים.", "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "לעיניך בלבד. לא לסגור את החלון הזה, ההודעה הזאת לא תופיע שוב.", "Could not decrypt comment; Wrong key?": "לא ניתן לפענח את ההערה, מפתח שגוי?", - "Reply": "Reply", + "Reply": "תגובה", "Anonymous": "אלמוני", "Avatar generated from IP address": "התמונה הייצוגית נוצרה מכתובת ה־IP", "Add comment": "הוספת תגובה", @@ -139,12 +139,12 @@ "EiB": "EiB", "ZiB": "ZiB", "YiB": "YiB", - "Format": "Format", + "Format": "פורמט", "Plain Text": "טקסט פשוט", "Source Code": "קוד מקור", "Markdown": "Markdown", "Download attachment": "הורדת קובץ מצורף", - "Cloned: '%s'": "Cloned: '%s'", + "Cloned: '%s'": "שוכפל: '%s'", "The cloned file '%s' was attached to this paste.": "The cloned file '%s' was attached to this paste.", "Attach a file": "צירוף קובץ", "alternatively drag & drop a file or paste an image from the clipboard": "alternatively drag & drop a file or paste an image from the clipboard", From 09496585451893292695f843582378c606c7d655 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Wed, 14 Oct 2020 07:08:06 +0200 Subject: [PATCH 006/223] New translations en.json (Norwegian) --- i18n/no.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/no.json b/i18n/no.json index bf26fff4..92b4a941 100644 --- a/i18n/no.json +++ b/i18n/no.json @@ -1,7 +1,7 @@ { "PrivateBin": "PrivateBin", "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s er en minimalistisk, åpen kildekode, elektronisk tilgjengelig pastebin hvor serveren ikke har kunnskap om dataene som limes inn. Dataene krypteres/dekrypteres i nettleseren ved hjelp av 256 bits AES.", - "More information on the project page.": "Mer informasjon om prosjektet på prosjektsiden.", + "More information on the project page.": "Mer informasjon om prosjektet på prosjektsiden.", "Because ignorance is bliss": "Fordi uvitenhet er lykke", "en": "no", "Paste does not exist, has expired or has been deleted.": "Innlegget eksisterer ikke, er utløpt eller har blitt slettet.", From 7381ddb5dce0fc953ba87fd9d5a3446f5410daec Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Wed, 14 Oct 2020 07:28:01 +0200 Subject: [PATCH 007/223] New translations en.json (Hebrew) --- i18n/he.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/he.json b/i18n/he.json index 8e3933fc..f9cb2326 100644 --- a/i18n/he.json +++ b/i18n/he.json @@ -139,7 +139,7 @@ "EiB": "EiB", "ZiB": "ZiB", "YiB": "YiB", - "Format": "פורמט", + "Format": "Format", "Plain Text": "טקסט פשוט", "Source Code": "קוד מקור", "Markdown": "Markdown", From 1da05948c7c07a59cb9b09d1578f0cbfad828b7f Mon Sep 17 00:00:00 2001 From: dy <60457873+goodboy-dy@users.noreply.github.com> Date: Sat, 14 Nov 2020 20:18:36 +0800 Subject: [PATCH 008/223] Create zh.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改了一些语言不习惯的地方 --- i18n/zh.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i18n/zh.json b/i18n/zh.json index cdf990a5..a1a70f2c 100644 --- a/i18n/zh.json +++ b/i18n/zh.json @@ -111,7 +111,7 @@ "Please enter the password for this paste:": "请输入这份粘贴内容的密码:", "Could not decrypt data (Wrong key?)": "无法解密数据(密钥错误?)", "Could not delete the paste, it was not stored in burn after reading mode.": "无法删除此粘贴内容,它没有以阅后即焚模式保存。", - "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "看!仔!细!了!不要关闭窗口,否则你再也见不到这条消息了。", + "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "注意啦!!!不要关闭窗口,否则你再也见不到这条消息了。", "Could not decrypt comment; Wrong key?": "无法解密评论; 密钥错误?", "Reply": "回复", "Anonymous": "匿名", @@ -162,7 +162,7 @@ "Loading…": "载入中…", "Decrypting paste…": "正在解密", "Preparing new paste…": "正在准备新的粘贴内容", - "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "如果这个消息一直存在,请参考 这里的 FAQ (英文版)进行故障排除。", + "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "如果这个消息一直存在,请参考 这里的 参考文档(英文版)进行故障排除。", "+++ no paste text +++": "+++ 没有粘贴内容 +++", "Could not get paste data: %s": "无法获取粘贴数据:%s", "QR code": "二维码", From 283561e34f756af14edf3f6b94bb2eef674a197a Mon Sep 17 00:00:00 2001 From: techboyg5 <63317676+techboyg5@users.noreply.github.com> Date: Sun, 22 Nov 2020 15:13:43 -0600 Subject: [PATCH 009/223] Language dropdown menu to the right --- tpl/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index e476a87b..37032fbd 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -422,7 +422,7 @@ if (strlen($LANGUAGESELECTION)) : ?>
diff --git a/tpl/page.php b/tpl/page.php index 2e0c385e..69310832 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -76,7 +76,14 @@ endif;
- in the browser using 256 bits AES.', I18n::_($NAME)), ' ', $INFO; ?>
+ ', ''), ' ', $INFO; + ?> +
From e6e985d92dc1492823a412ac1101ccd3df1fd76b Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 7 Mar 2021 19:56:19 +0100 Subject: [PATCH 039/223] apply StyleCI --- tpl/bootstrap.php | 12 ++++++------ tpl/page.php | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index b42f90d9..18ef595f 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -579,12 +579,12 @@ endif;

', ''), ' ', $INFO, PHP_EOL; - ?> + I18n::_('%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.', + I18n::_($NAME), + '%s', '%s' + ), + '', ''), ' ', $INFO, PHP_EOL; + ?>

diff --git a/tpl/page.php b/tpl/page.php index 69310832..aade5bd2 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -77,12 +77,12 @@ endif;
', ''), ' ', $INFO; - ?> + I18n::_('%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.', + I18n::_($NAME), + '%s', '%s' + ), + '', ''), ' ', $INFO; + ?>
Date: Sat, 6 Mar 2021 14:12:59 +0100 Subject: [PATCH 040/223] Avoid the use of markup in a translation. --- i18n/id.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/id.json b/i18n/id.json index 9dffd745..40d536e4 100644 --- a/i18n/id.json +++ b/i18n/id.json @@ -1,6 +1,6 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.": "%s adalah pastebin online sumber terbuka minimalis yang dimana server tersebut tidak memiliki pengetahuan tentang data yang ditempelkan. Data dienkripsi/didekripsi di browser menggunakan 256 bit AES.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s adalah pastebin online sumber terbuka minimalis yang dimana server tersebut tidak memiliki pengetahuan tentang data yang ditempelkan. Data dienkripsi/didekripsi %sdi browser%s menggunakan 256 bit AES.", "More information on the project page.": "Infomasi lebih lanjut pada halaman proyek.", "Because ignorance is bliss": "Karena ketidaktahuan adalah kebahagiaan", "en": "en", From f71e62c07ebac9a8b00aa16167b0e811fe5a6e06 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Mon, 8 Mar 2021 01:09:34 +0100 Subject: [PATCH 041/223] New translations en.json (Indonesian) --- i18n/id.json | 132 +++++++++++++++++++++++++-------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/i18n/id.json b/i18n/id.json index 40d536e4..8271d09f 100644 --- a/i18n/id.json +++ b/i18n/id.json @@ -2,8 +2,8 @@ "PrivateBin": "PrivateBin", "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s adalah pastebin online sumber terbuka minimalis yang dimana server tersebut tidak memiliki pengetahuan tentang data yang ditempelkan. Data dienkripsi/didekripsi %sdi browser%s menggunakan 256 bit AES.", "More information on the project page.": "Infomasi lebih lanjut pada halaman proyek.", - "Because ignorance is bliss": "Karena ketidaktahuan adalah kebahagiaan", - "en": "en", + "Because ignorance is bliss": "Karena ketidaktahuan adalah kebahagiaan, gitu loh", + "en": "id", "Paste does not exist, has expired or has been deleted.": "Paste tidak ada, telah kedaluwarsa atau telah dihapus.", "%s requires php %s or above to work. Sorry.": "%s memerlukan php %s atau versi diatasnya untuk dapat dijalankan. Maaf.", "%s requires configuration section [%s] to be present in configuration file.": "%s membutuhkan bagian konfigurasi [%s] untuk ada di file konfigurasi.", @@ -15,9 +15,9 @@ ], "Paste is limited to %s of encrypted data.": "Paste dibatasi sampai %s dari data yang dienskripsi.", "Invalid data.": "Data tidak valid.", - "You are unlucky. Try again.": "Anda belum beruntung. Coba kembali.", - "Error saving comment. Sorry.": "Terjadi kesalahan saat menyimpan komentar. Maaf.", - "Error saving paste. Sorry.": "Terjadi kesalahan saat menyimpan paste. Maaf.", + "You are unlucky. Try again.": "Anda belum beruntung. Coba kembali ya Kaka.", + "Error saving comment. Sorry.": "Terjadi kesalahan saat menyimpan komentar. Maaf ya Kaka.", + "Error saving paste. Sorry.": "Terjadi kesalahan saat menyimpan paste. Maaf ya Kaka.", "Invalid paste ID.": "ID paste tidak valid.", "Paste is not of burn-after-reading type.": "Paste bukan tipe hapus-setelah-membaca.", "Wrong deletion token. Paste was not deleted.": "Token penghapusan salah. Paste belum terhapus.", @@ -91,40 +91,40 @@ "This document will expire in %d minutes. (3rd plural)" ], "This document will expire in %d hours.": [ - "This document will expire in %d hour. (singular)", - "This document will expire in %d hours. (1st plural)", - "This document will expire in %d hours. (2nd plural)", - "This document will expire in %d hours. (3rd plural)" + "Dokumen ini akan kadaluarsa dalam %d jam.", + "Dokumen ini akan kadaluarsa dalam %d jam.", + "Dokumen ini akan kadaluarsa dalam %d jam.", + "Dokumen ini akan kadaluarsa dalam %d jam." ], "This document will expire in %d days.": [ - "This document will expire in %d day. (singular)", - "This document will expire in %d days. (1st plural)", - "This document will expire in %d days. (2nd plural)", - "This document will expire in %d days. (3rd plural)" + "Dokumen ini akan kadaluarsa dalam %d hari.", + "Dokumen ini akan kadaluarsa dalam %d hari.", + "Dokumen ini akan kadaluarsa dalam %d hari.", + "Dokumen ini akan kadaluarsa dalam %d hari." ], "This document will expire in %d months.": [ - "This document will expire in %d month. (singular)", - "This document will expire in %d months. (1st plural)", - "This document will expire in %d months. (2nd plural)", - "This document will expire in %d months. (3rd plural)" + "Dokumen ini akan kadaluarsa dalam %d bulan.", + "Dokumen ini akan kadaluarsa dalam %d bulan.", + "Dokumen ini akan kadaluarsa dalam %d bulan.", + "Dokumen ini akan kadaluarsa dalam %d bulan." ], - "Please enter the password for this paste:": "Please enter the password for this paste:", - "Could not decrypt data (Wrong key?)": "Could not decrypt data (Wrong key?)", - "Could not delete the paste, it was not stored in burn after reading mode.": "Could not delete the paste, it was not stored in burn after reading mode.", - "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.", - "Could not decrypt comment; Wrong key?": "Could not decrypt comment; Wrong key?", - "Reply": "Reply", - "Anonymous": "Anonymous", - "Avatar generated from IP address": "Avatar generated from IP address", - "Add comment": "Add comment", - "Optional nickname…": "Optional nickname…", - "Post comment": "Post comment", - "Sending comment…": "Sending comment…", - "Comment posted.": "Comment posted.", - "Could not refresh display: %s": "Could not refresh display: %s", - "unknown status": "unknown status", - "server error or not responding": "server error or not responding", - "Could not post comment: %s": "Could not post comment: %s", + "Please enter the password for this paste:": "Silahkan masukkan kata sandi untuk paste ini:", + "Could not decrypt data (Wrong key?)": "Tidak dapat mendekrip data (Salah kunci?)", + "Could not delete the paste, it was not stored in burn after reading mode.": "Tidak dapat menghapus paste, ini dikarenakan data tidak tersimpan dalam mode hapus setelah membaca.", + "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "HANYA UNTUK ANDA SAJA. Jangan tutup kolom jendela ini, pesan ini tidak akan dapat ditampilkan lagi.", + "Could not decrypt comment; Wrong key?": "Tidak dapat mendekrip komentar; Salah kunci?", + "Reply": "Balas", + "Anonymous": "Tanpa Nama", + "Avatar generated from IP address": "Avatar dihasilkan dari alamat IP", + "Add comment": "Tambah komentar", + "Optional nickname…": "Nama julukan tambahan…", + "Post comment": "Posting komentar", + "Sending comment…": "Mengirim komentar…", + "Comment posted.": "Komentar telah diposting.", + "Could not refresh display: %s": "Tidak dapat menyegarkan tampilan: %s", + "unknown status": "status tidak diketahui", + "server error or not responding": "kesalahan server atau server tidak merespon", + "Could not post comment: %s": "Tidak dapat memposting komentar: %s", "Sending paste…": "Mengirim paste…", "Your paste is %s (Hit [Ctrl]+[c] to copy)": "Paste Anda adalah %s(Tekan[Ctrl]+[c] untuk menyalin)", "Delete data": "Hapus data", @@ -152,36 +152,36 @@ "Remove attachment": "Hapus lampiran", "Your browser does not support uploading encrypted files. Please use a newer browser.": "Browser Anda tidak mendukung pengunggahan file terenkripsi. Harap gunakan browser yang lebih baru.", "Invalid attachment.": "Lampiran tidak valid.", - "Options": "Options", - "Shorten URL": "Shorten URL", - "Editor": "Editor", - "Preview": "Preview", - "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.": "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.", - "Decrypt": "Decrypt", - "Enter password": "Enter password", - "Loading…": "Loading…", - "Decrypting paste…": "Decrypting paste…", - "Preparing new paste…": "Preparing new paste…", - "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "In case this message never disappears please have a look at this FAQ for information to troubleshoot.", - "+++ no paste text +++": "+++ no paste text +++", - "Could not get paste data: %s": "Could not get paste data: %s", - "QR code": "QR code", - "This website is using an insecure HTTP connection! Please use it only for testing.": "This website is using an insecure HTTP connection! Please use it only for testing.", - "For more information see this FAQ entry.": "For more information see this FAQ entry.", - "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.": "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.", - "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.": "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.", - "waiting on user to provide a password": "waiting on user to provide a password", - "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.": "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.", - "Retry": "Retry", - "Showing raw text…": "Showing raw text…", - "Notice:": "Notice:", - "This link will expire after %s.": "This link will expire after %s.", - "This link can only be accessed once, do not use back or refresh button in your browser.": "This link can only be accessed once, do not use back or refresh button in your browser.", - "Link:": "Link:", - "Recipient may become aware of your timezone, convert time to UTC?": "Recipient may become aware of your timezone, convert time to UTC?", - "Use Current Timezone": "Use Current Timezone", - "Convert To UTC": "Convert To UTC", - "Close": "Close", - "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Options": "Pilihan", + "Shorten URL": "Pendekkan alamat URL", + "Editor": "Penyunting", + "Preview": "Pratinjau", + "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.": "%s memerlukan PATH berakhir dalam sebuah \"%s\". Silahkan perbarui PATH dalam index.php Anda.", + "Decrypt": "Dekrip", + "Enter password": "Masukkan kata sandi", + "Loading…": "Memuat…", + "Decrypting paste…": "Men-dekrip paste…", + "Preparing new paste…": "Menyiapkan paste baru…", + "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "Jika pesan ini tidak pernah menghilang, silahkan kunjungi dan lihat pada FAQ ini untuk informasi bagaimana menyelesaikan masalah tersebut.", + "+++ no paste text +++": "+++ tidak ada teks paste +++", + "Could not get paste data: %s": "Tidak dapat mengambil/menampilkan data paste: %s", + "QR code": "Kode QR", + "This website is using an insecure HTTP connection! Please use it only for testing.": "Situs web ini menggunakan koneksi HTTP yang tidak aman! Silahkan gunakan hanya untuk pengujian.", + "For more information see this FAQ entry.": "Untuk informasi lebih lanjut, lihat entri FAQ ini .", + "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.": "Browser Anda mungkin memerlukan koneksi HTTPS untuk mendukung API Webcrypto. Coba beralih ke HTTPS .", + "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.": "Browser Anda tidak mendukung Webassembly, yang digunakan untuk kompresi zlib. Anda dapat membuat dokumen yang tidak terkompresi, tetapi tidak akan dapat membaca berkas yang terkompresi.", + "waiting on user to provide a password": "menunggu pengguna untuk menyediakan kata sandi", + "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.": "Tidak dapat mendekrip data. Apakah Anda memasukkan kata sandi yang salah? Silahkan coba lagi dengan tombol di bagian atas.", + "Retry": "Coba lagi", + "Showing raw text…": "Menampilkan teks mentah…", + "Notice:": "Pengumuman:", + "This link will expire after %s.": "Tautan ini akan kadaluarsa setelah %s.", + "This link can only be accessed once, do not use back or refresh button in your browser.": "Tautan ini hanya dapat diakses satu kali, jangan gunakan tombol Kembali atau tombol Segarkan di browser Anda.", + "Link:": "Tautan:", + "Recipient may become aware of your timezone, convert time to UTC?": "Penerima dapat mengetahui zona waktu Anda, ubah waktu menjadi UTC?", + "Use Current Timezone": "Gunakan Zonawaktu Saat Ini", + "Convert To UTC": "Konversi Ke UTC", + "Close": "Tutup", + "Encrypted note on PrivateBin": "Catatan ter-ekrip di PrivateBin", + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kunjungi tautan ini untuk melihat catatan. Memberikan alamat URL pada siapapun juga, akan mengizinkan mereka untuk mengakses catatan, so pasti gitu loh Kaka." } From 5a9bcea3a919af84e275dc77c80ea270272a4663 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Tue, 9 Mar 2021 05:54:06 +0100 Subject: [PATCH 042/223] set plurals for and credit Indonesian translation --- CHANGELOG.md | 2 +- CREDITS.md | 1 + js/privatebin.js | 2 ++ lib/I18n.php | 2 ++ tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 6 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e8b8eb6..35c2a00e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # PrivateBin version history * **1.4 (not yet released)** - * ADDED: Translation for Hebrew and Lithuanian + * ADDED: Translation for Hebrew, Lithuanian and Indonesian * CHANGED: Upgrading libraries to: DOMpurify 2.0.14 * **1.3.4 (2020-03-22)** * CHANGED: Minimum required PHP version is 5.6, due to a change in the identicon library and to use php's native hash_equals() diff --git a/CREDITS.md b/CREDITS.md index ec593035..c750b870 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -48,3 +48,4 @@ Sébastien Sauvage - original idea and main developer * AndriiZ - Ukrainian * Yaron Shahrabani - Hebrew * Moo - Lithuanian +* whenwesober - Indonesian diff --git a/js/privatebin.js b/js/privatebin.js index 20e8c5e8..de8cb4dd 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -784,6 +784,8 @@ jQuery.PrivateBin = (function($, RawDeflate) { return n > 1 ? 1 : 0; case 'he': return n === 1 ? 0 : (n === 2 ? 1 : ((n < 0 || n > 10) && (n % 10 === 0) ? 2 : 3)); + case 'id': + return 0; case 'lt': return n % 10 === 1 && n % 100 !== 11 ? 0 : ((n % 10 >= 2 && n % 100 < 10 || n % 100 >= 20) ? 1 : 2); case 'pl': diff --git a/lib/I18n.php b/lib/I18n.php index f9fbd6ea..45e8dd52 100644 --- a/lib/I18n.php +++ b/lib/I18n.php @@ -323,6 +323,8 @@ class I18n return $n > 1 ? 1 : 0; case 'he': return $n === 1 ? 0 : ($n === 2 ? 1 : (($n < 0 || $n > 10) && ($n % 10 === 0) ? 2 : 3)); + case 'id': + return 0; case 'lt': return $n % 10 === 1 && $n % 100 !== 11 ? 0 : (($n % 10 >= 2 && $n % 100 < 10 || $n % 100 >= 20) ? 1 : 2); case 'pl': diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 18ef595f..c28b44dc 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index aade5bd2..49098111 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> - + From 4a5f08074b6c14132ecfe79a940e9734f9e40662 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sat, 27 Mar 2021 03:21:45 +0100 Subject: [PATCH 043/223] New translations en.json (Indonesian) --- i18n/id.json | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/i18n/id.json b/i18n/id.json index 8271d09f..487fd291 100644 --- a/i18n/id.json +++ b/i18n/id.json @@ -1,6 +1,6 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s adalah pastebin online sumber terbuka minimalis yang dimana server tersebut tidak memiliki pengetahuan tentang data yang ditempelkan. Data dienkripsi/didekripsi %sdi browser%s menggunakan 256 bit AES.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s adalah sebuah pastebin online sumber terbuka dan minimalis, dimana servernya tersebut tidak punya pengetahuan tentang data yang ditempelkan. Data tersebut di enkrip/dekrip %sdi dalam browser%s menggunakan metode enkrip AES 256 bit.", "More information on the project page.": "Infomasi lebih lanjut pada halaman proyek.", "Because ignorance is bliss": "Karena ketidaktahuan adalah kebahagiaan, gitu loh", "en": "id", @@ -60,35 +60,35 @@ ], "%d weeks": [ "%d minggu (tunggal)", - "%d weeks (1st plural)", - "%d weeks (2nd plural)", - "%d weeks (3rd plural)" + "%d minggu", + "%d minggu", + "%d minggu" ], "%d months": [ - "%d month (singular)", - "%d months (1st plural)", - "%d months (2nd plural)", - "%d months (3rd plural)" + "%d bulan", + "%d bulan", + "%d bulan", + "%d bulan" ], "%d years": [ - "%d year (singular)", - "%d years (1st plural)", - "%d years (2nd plural)", - "%d years (3rd plural)" + "%d tahun", + "%d tahun", + "%d tahun", + "%d tahun" ], - "Never": "Never", - "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.", + "Never": "Jangan pernah", + "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "Catatan: Ini adalah layanan percobaan: Data mungkin bisa terhapus kapanpun juga. Anak-anak kucing akan mati jika Anda mengekploitasi layanan ini.", "This document will expire in %d seconds.": [ - "This document will expire in %d second. (singular)", - "This document will expire in %d seconds. (1st plural)", - "This document will expire in %d seconds. (2nd plural)", - "This document will expire in %d seconds. (3rd plural)" + "Dokumen ini kadaluarsa dalam %d detik.", + "Dokumen ini kadaluarsa dalam %d detik.", + "Dokumen ini kadaluarsa dalam %d detik.", + "Dokumen ini kadaluarsa dalam %d detik." ], "This document will expire in %d minutes.": [ - "This document will expire in %d minute. (singular)", - "This document will expire in %d minutes. (1st plural)", - "This document will expire in %d minutes. (2nd plural)", - "This document will expire in %d minutes. (3rd plural)" + "Dokumen ini akan kadaluarsa dalam %d menit.", + "Dokumen ini akan kadaluarsa dalam %d menit.", + "Dokumen ini akan kadaluarsa dalam %d menit.", + "Dokumen ini akan kadaluarsa dalam %d menit." ], "This document will expire in %d hours.": [ "Dokumen ini akan kadaluarsa dalam %d jam.", @@ -126,7 +126,7 @@ "server error or not responding": "kesalahan server atau server tidak merespon", "Could not post comment: %s": "Tidak dapat memposting komentar: %s", "Sending paste…": "Mengirim paste…", - "Your paste is %s (Hit [Ctrl]+[c] to copy)": "Paste Anda adalah %s(Tekan[Ctrl]+[c] untuk menyalin)", + "Your paste is %s (Hit [Ctrl]+[c] to copy)": "Paste Anda adalah %s(Tekan [Ctrl]+[c] untuk menyalin)", "Delete data": "Hapus data", "Could not create paste: %s": "Tidak dapat membuat paste: %s", "Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)": "Tidak dapat mendekripsi paste: Kunci dekripsi tidak ada di URL (Apakah Anda menggunakan redirector atau penyingkat URL yang menghapus bagian dari URL?)", From f3fee65ba937b7bdd67934932016686758196cd2 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sat, 27 Mar 2021 10:00:26 +0100 Subject: [PATCH 044/223] New translations en.json (Catalan) --- i18n/ca.json | 187 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 i18n/ca.json diff --git a/i18n/ca.json b/i18n/ca.json new file mode 100644 index 00000000..25d0735e --- /dev/null +++ b/i18n/ca.json @@ -0,0 +1,187 @@ +{ + "PrivateBin": "PrivateBin", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.", + "More information on the project page.": "More information on the project page.", + "Because ignorance is bliss": "Because ignorance is bliss", + "en": "en", + "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", + "%s requires php %s or above to work. Sorry.": "%s requires php %s or above to work. Sorry.", + "%s requires configuration section [%s] to be present in configuration file.": "%s requires configuration section [%s] to be present in configuration file.", + "Please wait %d seconds between each post.": [ + "Please wait %d second between each post. (singular)", + "Please wait %d seconds between each post. (1st plural)", + "Please wait %d seconds between each post. (2nd plural)", + "Please wait %d seconds between each post. (3rd plural)" + ], + "Paste is limited to %s of encrypted data.": "Paste is limited to %s of encrypted data.", + "Invalid data.": "Invalid data.", + "You are unlucky. Try again.": "You are unlucky. Try again.", + "Error saving comment. Sorry.": "Error saving comment. Sorry.", + "Error saving paste. Sorry.": "Error saving paste. Sorry.", + "Invalid paste ID.": "Invalid paste ID.", + "Paste is not of burn-after-reading type.": "Paste is not of burn-after-reading type.", + "Wrong deletion token. Paste was not deleted.": "Wrong deletion token. Paste was not deleted.", + "Paste was properly deleted.": "Paste was properly deleted.", + "JavaScript is required for %s to work. Sorry for the inconvenience.": "JavaScript is required for %s to work. Sorry for the inconvenience.", + "%s requires a modern browser to work.": "%s requires a modern browser to work.", + "New": "New", + "Send": "Send", + "Clone": "Clone", + "Raw text": "Raw text", + "Expires": "Expires", + "Burn after reading": "Burn after reading", + "Open discussion": "Open discussion", + "Password (recommended)": "Password (recommended)", + "Discussion": "Discussion", + "Toggle navigation": "Toggle navigation", + "%d seconds": [ + "%d second (singular)", + "%d seconds (1st plural)", + "%d seconds (2nd plural)", + "%d seconds (3rd plural)" + ], + "%d minutes": [ + "%d minute (singular)", + "%d minutes (1st plural)", + "%d minutes (2nd plural)", + "%d minutes (3rd plural)" + ], + "%d hours": [ + "%d hour (singular)", + "%d hours (1st plural)", + "%d hours (2nd plural)", + "%d hours (3rd plural)" + ], + "%d days": [ + "%d day (singular)", + "%d days (1st plural)", + "%d days (2nd plural)", + "%d days (3rd plural)" + ], + "%d weeks": [ + "%d week (singular)", + "%d weeks (1st plural)", + "%d weeks (2nd plural)", + "%d weeks (3rd plural)" + ], + "%d months": [ + "%d month (singular)", + "%d months (1st plural)", + "%d months (2nd plural)", + "%d months (3rd plural)" + ], + "%d years": [ + "%d year (singular)", + "%d years (1st plural)", + "%d years (2nd plural)", + "%d years (3rd plural)" + ], + "Never": "Never", + "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.", + "This document will expire in %d seconds.": [ + "This document will expire in %d second. (singular)", + "This document will expire in %d seconds. (1st plural)", + "This document will expire in %d seconds. (2nd plural)", + "This document will expire in %d seconds. (3rd plural)" + ], + "This document will expire in %d minutes.": [ + "This document will expire in %d minute. (singular)", + "This document will expire in %d minutes. (1st plural)", + "This document will expire in %d minutes. (2nd plural)", + "This document will expire in %d minutes. (3rd plural)" + ], + "This document will expire in %d hours.": [ + "This document will expire in %d hour. (singular)", + "This document will expire in %d hours. (1st plural)", + "This document will expire in %d hours. (2nd plural)", + "This document will expire in %d hours. (3rd plural)" + ], + "This document will expire in %d days.": [ + "This document will expire in %d day. (singular)", + "This document will expire in %d days. (1st plural)", + "This document will expire in %d days. (2nd plural)", + "This document will expire in %d days. (3rd plural)" + ], + "This document will expire in %d months.": [ + "This document will expire in %d month. (singular)", + "This document will expire in %d months. (1st plural)", + "This document will expire in %d months. (2nd plural)", + "This document will expire in %d months. (3rd plural)" + ], + "Please enter the password for this paste:": "Please enter the password for this paste:", + "Could not decrypt data (Wrong key?)": "Could not decrypt data (Wrong key?)", + "Could not delete the paste, it was not stored in burn after reading mode.": "Could not delete the paste, it was not stored in burn after reading mode.", + "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.", + "Could not decrypt comment; Wrong key?": "Could not decrypt comment; Wrong key?", + "Reply": "Reply", + "Anonymous": "Anonymous", + "Avatar generated from IP address": "Avatar generated from IP address", + "Add comment": "Add comment", + "Optional nickname…": "Optional nickname…", + "Post comment": "Post comment", + "Sending comment…": "Sending comment…", + "Comment posted.": "Comment posted.", + "Could not refresh display: %s": "Could not refresh display: %s", + "unknown status": "unknown status", + "server error or not responding": "server error or not responding", + "Could not post comment: %s": "Could not post comment: %s", + "Sending paste…": "Sending paste…", + "Your paste is %s (Hit [Ctrl]+[c] to copy)": "Your paste is %s (Hit [Ctrl]+[c] to copy)", + "Delete data": "Delete data", + "Could not create paste: %s": "Could not create paste: %s", + "Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)": "Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)", + "B": "B", + "KiB": "KiB", + "MiB": "MiB", + "GiB": "GiB", + "TiB": "TiB", + "PiB": "PiB", + "EiB": "EiB", + "ZiB": "ZiB", + "YiB": "YiB", + "Format": "Format", + "Plain Text": "Plain Text", + "Source Code": "Source Code", + "Markdown": "Markdown", + "Download attachment": "Download attachment", + "Cloned: '%s'": "Cloned: '%s'", + "The cloned file '%s' was attached to this paste.": "The cloned file '%s' was attached to this paste.", + "Attach a file": "Attach a file", + "alternatively drag & drop a file or paste an image from the clipboard": "alternatively drag & drop a file or paste an image from the clipboard", + "File too large, to display a preview. Please download the attachment.": "File too large, to display a preview. Please download the attachment.", + "Remove attachment": "Remove attachment", + "Your browser does not support uploading encrypted files. Please use a newer browser.": "Your browser does not support uploading encrypted files. Please use a newer browser.", + "Invalid attachment.": "Invalid attachment.", + "Options": "Options", + "Shorten URL": "Shorten URL", + "Editor": "Editor", + "Preview": "Preview", + "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.": "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.", + "Decrypt": "Decrypt", + "Enter password": "Enter password", + "Loading…": "Loading…", + "Decrypting paste…": "Decrypting paste…", + "Preparing new paste…": "Preparing new paste…", + "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "In case this message never disappears please have a look at this FAQ for information to troubleshoot.", + "+++ no paste text +++": "+++ no paste text +++", + "Could not get paste data: %s": "Could not get paste data: %s", + "QR code": "QR code", + "This website is using an insecure HTTP connection! Please use it only for testing.": "This website is using an insecure HTTP connection! Please use it only for testing.", + "For more information see this FAQ entry.": "For more information see this FAQ entry.", + "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.": "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.", + "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.": "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.", + "waiting on user to provide a password": "waiting on user to provide a password", + "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.": "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.", + "Retry": "Retry", + "Showing raw text…": "Showing raw text…", + "Notice:": "Notice:", + "This link will expire after %s.": "This link will expire after %s.", + "This link can only be accessed once, do not use back or refresh button in your browser.": "This link can only be accessed once, do not use back or refresh button in your browser.", + "Link:": "Link:", + "Recipient may become aware of your timezone, convert time to UTC?": "Recipient may become aware of your timezone, convert time to UTC?", + "Use Current Timezone": "Use Current Timezone", + "Convert To UTC": "Convert To UTC", + "Close": "Close", + "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." +} From 52d65abce7d8ea07973d5adecdb5bad75da75936 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sat, 27 Mar 2021 14:30:25 +0100 Subject: [PATCH 045/223] New translations en.json (Catalan) --- i18n/ca.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/i18n/ca.json b/i18n/ca.json index 25d0735e..a33f427f 100644 --- a/i18n/ca.json +++ b/i18n/ca.json @@ -1,12 +1,12 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.", - "More information on the project page.": "More information on the project page.", - "Because ignorance is bliss": "Because ignorance is bliss", - "en": "en", - "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", - "%s requires php %s or above to work. Sorry.": "%s requires php %s or above to work. Sorry.", - "%s requires configuration section [%s] to be present in configuration file.": "%s requires configuration section [%s] to be present in configuration file.", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s és un pastebin en línia de codi obert i minimalista on el servidor no té coneixement de les dades enganxades. Les dades estan encriptades/desxifrades %sen el navegador%s utilitzant AES de 256 bits.", + "More information on the project page.": "Més informació a la pàgina del projecte.", + "Because ignorance is bliss": "Perquè la ignorància és felicitat", + "en": "ca", + "Paste does not exist, has expired or has been deleted.": "El paste no existeix, ha caducat o s'ha eliminat.", + "%s requires php %s or above to work. Sorry.": "%s requereix php %s o superior per funcionar. Ho sento.", + "%s requires configuration section [%s] to be present in configuration file.": "%s requereix que la secció de configuració [%s] sigui present al fitxer de configuració.", "Please wait %d seconds between each post.": [ "Please wait %d second between each post. (singular)", "Please wait %d seconds between each post. (1st plural)", From da0896fe42df508be15a3e4b6ed6cf054d859360 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Fri, 2 Apr 2021 09:00:27 +0200 Subject: [PATCH 046/223] set plurals for and credit Catalan translation --- CHANGELOG.md | 2 +- CREDITS.md | 1 + js/privatebin.js | 2 +- lib/I18n.php | 2 +- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35c2a00e..a5e832c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # PrivateBin version history * **1.4 (not yet released)** - * ADDED: Translation for Hebrew, Lithuanian and Indonesian + * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan * CHANGED: Upgrading libraries to: DOMpurify 2.0.14 * **1.3.4 (2020-03-22)** * CHANGED: Minimum required PHP version is 5.6, due to a change in the identicon library and to use php's native hash_equals() diff --git a/CREDITS.md b/CREDITS.md index c750b870..8b24f167 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -49,3 +49,4 @@ Sébastien Sauvage - original idea and main developer * Yaron Shahrabani - Hebrew * Moo - Lithuanian * whenwesober - Indonesian +* retiolus - Catalan diff --git a/js/privatebin.js b/js/privatebin.js index de8cb4dd..9beb3d99 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -795,7 +795,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { return n % 10 === 1 && n % 100 !== 11 ? 0 : (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2); case 'sl': return n % 100 === 1 ? 1 : (n % 100 === 2 ? 2 : (n % 100 === 3 || n % 100 === 4 ? 3 : 0)); - // bg, de, en, es, hu, it, nl, no, pt + // bg, ca, de, en, es, hu, it, nl, no, pt default: return n !== 1 ? 1 : 0; } diff --git a/lib/I18n.php b/lib/I18n.php index 45e8dd52..6299f220 100644 --- a/lib/I18n.php +++ b/lib/I18n.php @@ -334,7 +334,7 @@ class I18n return $n % 10 == 1 && $n % 100 != 11 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2); case 'sl': return $n % 100 == 1 ? 1 : ($n % 100 == 2 ? 2 : ($n % 100 == 3 || $n % 100 == 4 ? 3 : 0)); - // bg, de, en, es, hu, it, nl, no, pt + // bg, ca, de, en, es, hu, it, nl, no, pt default: return $n != 1 ? 1 : 0; } diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index c28b44dc..3e2bc930 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index 49098111..dfdee507 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> - + From 2e10bdbd22366055bb98a3eec59f77828d96e712 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Fri, 2 Apr 2021 09:09:47 +0200 Subject: [PATCH 047/223] update DOMpurify to version 2.2.7 --- CHANGELOG.md | 2 +- js/purify-2.0.14.js | 2 -- js/purify-2.2.7.js | 2 ++ tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 js/purify-2.0.14.js create mode 100644 js/purify-2.2.7.js diff --git a/CHANGELOG.md b/CHANGELOG.md index a5e832c5..09f95d81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ * **1.4 (not yet released)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan - * CHANGED: Upgrading libraries to: DOMpurify 2.0.14 + * CHANGED: Upgrading libraries to: DOMpurify 2.2.7 * **1.3.4 (2020-03-22)** * CHANGED: Minimum required PHP version is 5.6, due to a change in the identicon library and to use php's native hash_equals() * CHANGED: Upgrading libraries to: identicon 2.0.0 diff --git a/js/purify-2.0.14.js b/js/purify-2.0.14.js deleted file mode 100644 index a794b186..00000000 --- a/js/purify-2.0.14.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.0.8/LICENSE */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).DOMPurify=t()}(this,(function(){"use strict";var e=Object.hasOwnProperty,t=Object.setPrototypeOf,n=Object.isFrozen,r=Object.keys,o=Object.freeze,i=Object.seal,a=Object.create,l="undefined"!=typeof Reflect&&Reflect,c=l.apply,s=l.construct;c||(c=function(e,t,n){return e.apply(t,n)}),o||(o=function(e){return e}),i||(i=function(e){return e}),s||(s=function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1?n-1:0),o=1;o/gm),U=i(/^data-[\-\w.\u00B7-\uFFFF]/),j=i(/^aria-[\-\w]+$/),P=i(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),G=i(/^(?:\w+script|data):/i),W=i(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g),B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function q(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0&&void 0!==arguments[0]?arguments[0]:K(),n=function(t){return e(t)};if(n.version="2.0.14",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var i=t.document,a=!1,l=t.document,c=t.DocumentFragment,s=t.HTMLTemplateElement,k=t.Node,L=t.NodeFilter,Y=t.NamedNodeMap,X=void 0===Y?t.NamedNodeMap||t.MozNamedAttrMap:Y,$=t.Text,J=t.Comment,Q=t.DOMParser,Z=t.trustedTypes;if("function"==typeof s){var ee=l.createElement("template");ee.content&&ee.content.ownerDocument&&(l=ee.content.ownerDocument)}var te=V(Z,i),ne=te&&He?te.createHTML(""):"",re=l,oe=re.implementation,ie=re.createNodeIterator,ae=re.getElementsByTagName,le=re.createDocumentFragment,ce=i.importNode,se=E(l).documentMode?l.documentMode:{},ue={};n.isSupported=oe&&void 0!==oe.createHTMLDocument&&9!==se;var de=z,fe=I,pe=U,me=j,ye=G,ge=W,he=P,ve=null,be=_({},[].concat(q(M),q(D),q(N),q(O),q(R))),Te=null,Ae=_({},[].concat(q(w),q(F),q(H),q(C))),xe=null,Se=null,ke=!0,Le=!0,_e=!1,Ee=!1,Me=!1,De=!1,Ne=!1,Oe=!1,Re=!1,we=!1,Fe=!1,He=!1,Ce=!0,ze=!0,Ie=!1,Ue={},je=_({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","plaintext","script","style","svg","template","thead","title","video","xmp"]),Pe=null,Ge=_({},["audio","video","img","source","image","track"]),We=null,Be=_({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),qe=null,Ke=l.createElement("form"),Ve=function(e){qe&&qe===e||(e&&"object"===(void 0===e?"undefined":B(e))||(e={}),e=E(e),ve="ALLOWED_TAGS"in e?_({},e.ALLOWED_TAGS):be,Te="ALLOWED_ATTR"in e?_({},e.ALLOWED_ATTR):Ae,We="ADD_URI_SAFE_ATTR"in e?_(E(Be),e.ADD_URI_SAFE_ATTR):Be,Pe="ADD_DATA_URI_TAGS"in e?_(E(Ge),e.ADD_DATA_URI_TAGS):Ge,xe="FORBID_TAGS"in e?_({},e.FORBID_TAGS):{},Se="FORBID_ATTR"in e?_({},e.FORBID_ATTR):{},Ue="USE_PROFILES"in e&&e.USE_PROFILES,ke=!1!==e.ALLOW_ARIA_ATTR,Le=!1!==e.ALLOW_DATA_ATTR,_e=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ee=e.SAFE_FOR_JQUERY||!1,Me=e.SAFE_FOR_TEMPLATES||!1,De=e.WHOLE_DOCUMENT||!1,Re=e.RETURN_DOM||!1,we=e.RETURN_DOM_FRAGMENT||!1,Fe=e.RETURN_DOM_IMPORT||!1,He=e.RETURN_TRUSTED_TYPE||!1,Oe=e.FORCE_BODY||!1,Ce=!1!==e.SANITIZE_DOM,ze=!1!==e.KEEP_CONTENT,Ie=e.IN_PLACE||!1,he=e.ALLOWED_URI_REGEXP||he,Me&&(Le=!1),we&&(Re=!0),Ue&&(ve=_({},[].concat(q(R))),Te=[],!0===Ue.html&&(_(ve,M),_(Te,w)),!0===Ue.svg&&(_(ve,D),_(Te,F),_(Te,C)),!0===Ue.svgFilters&&(_(ve,N),_(Te,F),_(Te,C)),!0===Ue.mathMl&&(_(ve,O),_(Te,H),_(Te,C))),e.ADD_TAGS&&(ve===be&&(ve=E(ve)),_(ve,e.ADD_TAGS)),e.ADD_ATTR&&(Te===Ae&&(Te=E(Te)),_(Te,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&_(We,e.ADD_URI_SAFE_ATTR),ze&&(ve["#text"]=!0),De&&_(ve,["html","head","body"]),ve.table&&(_(ve,["tbody"]),delete xe.tbody),o&&o(e),qe=e)},Ye=function(e){m(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.outerHTML=ne}},Xe=function(e,t){try{m(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){m(n.removed,{attribute:null,from:t})}t.removeAttribute(e)},$e=function(e){var t=void 0,n=void 0;if(Oe)e=""+e;else{var r=h(e,/^[\r\n\t ]+/);n=r&&r[0]}var o=te?te.createHTML(e):e;try{t=(new Q).parseFromString(o,"text/html")}catch(e){}if(a&&_(xe,["title"]),!t||!t.documentElement){var i=(t=oe.createHTMLDocument("")).body;i.parentNode.removeChild(i.parentNode.firstElementChild),i.outerHTML=o}return e&&n&&t.body.insertBefore(l.createTextNode(n),t.body.childNodes[0]||null),ae.call(t,De?"html":"body")[0]};n.isSupported&&function(){try{var e=$e("</title><img>");A(/<\/title/,e.querySelector("title").innerHTML)&&(a=!0)}catch(e){}}();var Je=function(e){return ie.call(e.ownerDocument||e,e,L.SHOW_ELEMENT|L.SHOW_COMMENT|L.SHOW_TEXT,(function(){return L.FILTER_ACCEPT}),!1)},Qe=function(e){return!(e instanceof $||e instanceof J)&&!("string"==typeof e.nodeName&&"string"==typeof e.textContent&&"function"==typeof e.removeChild&&e.attributes instanceof X&&"function"==typeof e.removeAttribute&&"function"==typeof e.setAttribute&&"string"==typeof e.namespaceURI)},Ze=function(e){return"object"===(void 0===k?"undefined":B(k))?e instanceof k:e&&"object"===(void 0===e?"undefined":B(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},et=function(e,t,r){ue[e]&&u(ue[e],(function(e){e.call(n,t,r,qe)}))},tt=function(e){var t=void 0;if(et("beforeSanitizeElements",e,null),Qe(e))return Ye(e),!0;if(h(e.nodeName,/[\u0080-\uFFFF]/))return Ye(e),!0;var r=g(e.nodeName);if(et("uponSanitizeElement",e,{tagName:r,allowedTags:ve}),("svg"===r||"math"===r)&&0!==e.querySelectorAll("p, br").length)return Ye(e),!0;if(!ve[r]||xe[r]){if(ze&&!je[r]&&"function"==typeof e.insertAdjacentHTML)try{var o=e.innerHTML;e.insertAdjacentHTML("AfterEnd",te?te.createHTML(o):o)}catch(e){}return Ye(e),!0}return"noscript"===r&&A(/<\/noscript/i,e.innerHTML)||"noembed"===r&&A(/<\/noembed/i,e.innerHTML)?(Ye(e),!0):(!Ee||e.firstElementChild||e.content&&e.content.firstElementChild||!A(/</g,e.textContent)||(m(n.removed,{element:e.cloneNode()}),e.innerHTML?e.innerHTML=v(e.innerHTML,/</g,"<"):e.innerHTML=v(e.textContent,/</g,"<")),Me&&3===e.nodeType&&(t=e.textContent,t=v(t,de," "),t=v(t,fe," "),e.textContent!==t&&(m(n.removed,{element:e.cloneNode()}),e.textContent=t)),et("afterSanitizeElements",e,null),!1)},nt=function(e,t,n){if(Ce&&("id"===t||"name"===t)&&(n in l||n in Ke))return!1;if(Le&&A(pe,t));else if(ke&&A(me,t));else{if(!Te[t]||Se[t])return!1;if(We[t]);else if(A(he,v(n,ge,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==b(n,"data:")||!Pe[e]){if(_e&&!A(ye,v(n,ge,"")));else if(n)return!1}else;}return!0},rt=function(e){var t=void 0,o=void 0,i=void 0,a=void 0,l=void 0;et("beforeSanitizeAttributes",e,null);var c=e.attributes;if(c){var s={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Te};for(l=c.length;l--;){var u=t=c[l],m=u.name,h=u.namespaceURI;if(o=T(t.value),i=g(m),s.attrName=i,s.attrValue=o,s.keepAttr=!0,s.forceKeepAttr=void 0,et("uponSanitizeAttribute",e,s),o=s.attrValue,!s.forceKeepAttr){if("name"===i&&"IMG"===e.nodeName&&c.id)a=c.id,c=y(c,[]),Xe("id",e),Xe(m,e),d(c,a)>l&&e.setAttribute("id",a.value);else{if("INPUT"===e.nodeName&&"type"===i&&"file"===o&&s.keepAttr&&(Te[i]||!Se[i]))continue;"id"===m&&e.setAttribute(m,""),Xe(m,e)}if(s.keepAttr)if(Ee&&A(/\/>/i,o))Xe(m,e);else if(A(/svg|math/i,e.namespaceURI)&&A(x("</("+f(r(je),"|")+")","i"),o))Xe(m,e);else{Me&&(o=v(o,de," "),o=v(o,fe," "));var b=e.nodeName.toLowerCase();if(nt(b,i,o))try{h?e.setAttributeNS(h,m,o):e.setAttribute(m,o),p(n.removed)}catch(e){}}}}et("afterSanitizeAttributes",e,null)}},ot=function e(t){var n=void 0,r=Je(t);for(et("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)et("uponSanitizeShadowNode",n,null),tt(n)||(n.content instanceof c&&e(n.content),rt(n));et("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e,r){var o=void 0,a=void 0,l=void 0,s=void 0,u=void 0;if(e||(e="\x3c!--\x3e"),"string"!=typeof e&&!Ze(e)){if("function"!=typeof e.toString)throw S("toString is not a function");if("string"!=typeof(e=e.toString()))throw S("dirty is not a string, aborting")}if(!n.isSupported){if("object"===B(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(Ze(e))return t.toStaticHTML(e.outerHTML)}return e}if(Ne||Ve(r),n.removed=[],"string"==typeof e&&(Ie=!1),Ie);else if(e instanceof k)1===(a=(o=$e("\x3c!--\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===a.nodeName||"HTML"===a.nodeName?o=a:o.appendChild(a);else{if(!Re&&!Me&&!De&&-1===e.indexOf("<"))return te&&He?te.createHTML(e):e;if(!(o=$e(e)))return Re?null:ne}o&&Oe&&Ye(o.firstChild);for(var d=Je(Ie?e:o);l=d.nextNode();)3===l.nodeType&&l===s||tt(l)||(l.content instanceof c&&ot(l.content),rt(l),s=l);if(s=null,Ie)return e;if(Re){if(we)for(u=le.call(o.ownerDocument);o.firstChild;)u.appendChild(o.firstChild);else u=o;return Fe&&(u=ce.call(i,u,!0)),u}var f=De?o.outerHTML:o.innerHTML;return Me&&(f=v(f,de," "),f=v(f,fe," ")),te&&He?te.createHTML(f):f},n.setConfig=function(e){Ve(e),Ne=!0},n.clearConfig=function(){qe=null,Ne=!1},n.isValidAttribute=function(e,t,n){qe||Ve({});var r=g(e),o=g(t);return nt(r,o,n)},n.addHook=function(e,t){"function"==typeof t&&(ue[e]=ue[e]||[],m(ue[e],t))},n.removeHook=function(e){ue[e]&&p(ue[e])},n.removeHooks=function(e){ue[e]&&(ue[e]=[])},n.removeAllHooks=function(){ue={}},n}()})); diff --git a/js/purify-2.2.7.js b/js/purify-2.2.7.js new file mode 100644 index 00000000..e9e4badf --- /dev/null +++ b/js/purify-2.2.7.js @@ -0,0 +1,2 @@ +/*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.2.2/LICENSE */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).DOMPurify=t()}(this,(function(){"use strict";var e=Object.hasOwnProperty,t=Object.setPrototypeOf,n=Object.isFrozen,r=Object.getPrototypeOf,o=Object.getOwnPropertyDescriptor,i=Object.freeze,a=Object.seal,l=Object.create,c="undefined"!=typeof Reflect&&Reflect,s=c.apply,u=c.construct;s||(s=function(e,t,n){return e.apply(t,n)}),i||(i=function(e){return e}),a||(a=function(e){return e}),u||(u=function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(t))))});var f,m=x(Array.prototype.forEach),d=x(Array.prototype.pop),p=x(Array.prototype.push),g=x(String.prototype.toLowerCase),h=x(String.prototype.match),y=x(String.prototype.replace),v=x(String.prototype.indexOf),b=x(String.prototype.trim),T=x(RegExp.prototype.test),A=(f=TypeError,function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return u(f,t)});function x(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return s(e,t,r)}}function w(e,r){t&&t(e,null);for(var o=r.length;o--;){var i=r[o];if("string"==typeof i){var a=g(i);a!==i&&(n(r)||(r[o]=a),i=a)}e[i]=!0}return e}function S(t){var n=l(null),r=void 0;for(r in t)s(e,t,[r])&&(n[r]=t[r]);return n}function k(e,t){for(;null!==e;){var n=o(e,t);if(n){if(n.get)return x(n.get);if("function"==typeof n.value)return x(n.value)}e=r(e)}return function(e){return console.warn("fallback value for",e),null}}var R=i(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),_=i(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),D=i(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),E=i(["animate","color-profile","cursor","discard","fedropshadow","feimage","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),N=i(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),O=i(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),L=i(["#text"]),M=i(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns"]),F=i(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),C=i(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),I=i(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),z=a(/\{\{[\s\S]*|[\s\S]*\}\}/gm),H=a(/<%[\s\S]*|[\s\S]*%>/gm),U=a(/^data-[\-\w.\u00B7-\uFFFF]/),j=a(/^aria-[\-\w]+$/),P=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),B=a(/^(?:\w+script|data):/i),W=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function q(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var K=function(){return"undefined"==typeof window?null:window},V=function(e,t){if("object"!==(void 0===e?"undefined":G(e))||"function"!=typeof e.createPolicy)return null;var n=null,r="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(r)&&(n=t.currentScript.getAttribute(r));var o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}};return function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:K(),n=function(t){return e(t)};if(n.version="2.2.7",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var r=t.document,o=t.document,a=t.DocumentFragment,l=t.HTMLTemplateElement,c=t.Node,s=t.Element,u=t.NodeFilter,f=t.NamedNodeMap,x=void 0===f?t.NamedNodeMap||t.MozNamedAttrMap:f,Y=t.Text,X=t.Comment,$=t.DOMParser,Z=t.trustedTypes,J=s.prototype,Q=k(J,"cloneNode"),ee=k(J,"nextSibling"),te=k(J,"childNodes"),ne=k(J,"parentNode");if("function"==typeof l){var re=o.createElement("template");re.content&&re.content.ownerDocument&&(o=re.content.ownerDocument)}var oe=V(Z,r),ie=oe&&ze?oe.createHTML(""):"",ae=o,le=ae.implementation,ce=ae.createNodeIterator,se=ae.getElementsByTagName,ue=ae.createDocumentFragment,fe=r.importNode,me={};try{me=S(o).documentMode?o.documentMode:{}}catch(e){}var de={};n.isSupported="function"==typeof ne&&le&&void 0!==le.createHTMLDocument&&9!==me;var pe=z,ge=H,he=U,ye=j,ve=B,be=W,Te=P,Ae=null,xe=w({},[].concat(q(R),q(_),q(D),q(N),q(L))),we=null,Se=w({},[].concat(q(M),q(F),q(C),q(I))),ke=null,Re=null,_e=!0,De=!0,Ee=!1,Ne=!1,Oe=!1,Le=!1,Me=!1,Fe=!1,Ce=!1,Ie=!0,ze=!1,He=!0,Ue=!0,je=!1,Pe={},Be=w({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),We=null,Ge=w({},["audio","video","img","source","image","track"]),qe=null,Ke=w({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),Ve=null,Ye=o.createElement("form"),Xe=function(e){Ve&&Ve===e||(e&&"object"===(void 0===e?"undefined":G(e))||(e={}),e=S(e),Ae="ALLOWED_TAGS"in e?w({},e.ALLOWED_TAGS):xe,we="ALLOWED_ATTR"in e?w({},e.ALLOWED_ATTR):Se,qe="ADD_URI_SAFE_ATTR"in e?w(S(Ke),e.ADD_URI_SAFE_ATTR):Ke,We="ADD_DATA_URI_TAGS"in e?w(S(Ge),e.ADD_DATA_URI_TAGS):Ge,ke="FORBID_TAGS"in e?w({},e.FORBID_TAGS):{},Re="FORBID_ATTR"in e?w({},e.FORBID_ATTR):{},Pe="USE_PROFILES"in e&&e.USE_PROFILES,_e=!1!==e.ALLOW_ARIA_ATTR,De=!1!==e.ALLOW_DATA_ATTR,Ee=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=e.SAFE_FOR_TEMPLATES||!1,Oe=e.WHOLE_DOCUMENT||!1,Fe=e.RETURN_DOM||!1,Ce=e.RETURN_DOM_FRAGMENT||!1,Ie=!1!==e.RETURN_DOM_IMPORT,ze=e.RETURN_TRUSTED_TYPE||!1,Me=e.FORCE_BODY||!1,He=!1!==e.SANITIZE_DOM,Ue=!1!==e.KEEP_CONTENT,je=e.IN_PLACE||!1,Te=e.ALLOWED_URI_REGEXP||Te,Ne&&(De=!1),Ce&&(Fe=!0),Pe&&(Ae=w({},[].concat(q(L))),we=[],!0===Pe.html&&(w(Ae,R),w(we,M)),!0===Pe.svg&&(w(Ae,_),w(we,F),w(we,I)),!0===Pe.svgFilters&&(w(Ae,D),w(we,F),w(we,I)),!0===Pe.mathMl&&(w(Ae,N),w(we,C),w(we,I))),e.ADD_TAGS&&(Ae===xe&&(Ae=S(Ae)),w(Ae,e.ADD_TAGS)),e.ADD_ATTR&&(we===Se&&(we=S(we)),w(we,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&w(qe,e.ADD_URI_SAFE_ATTR),Ue&&(Ae["#text"]=!0),Oe&&w(Ae,["html","head","body"]),Ae.table&&(w(Ae,["tbody"]),delete ke.tbody),i&&i(e),Ve=e)},$e=w({},["mi","mo","mn","ms","mtext"]),Ze=w({},["foreignobject","desc","title","annotation-xml"]),Je=w({},_);w(Je,D),w(Je,E);var Qe=w({},N);w(Qe,O);var et="http://www.w3.org/1998/Math/MathML",tt="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml",rt=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:nt,tagName:"template"});var n=g(e.tagName),r=g(t.tagName);if(e.namespaceURI===tt)return t.namespaceURI===nt?"svg"===n:t.namespaceURI===et?"svg"===n&&("annotation-xml"===r||$e[r]):Boolean(Je[n]);if(e.namespaceURI===et)return t.namespaceURI===nt?"math"===n:t.namespaceURI===tt?"math"===n&&Ze[r]:Boolean(Qe[n]);if(e.namespaceURI===nt){if(t.namespaceURI===tt&&!Ze[r])return!1;if(t.namespaceURI===et&&!$e[r])return!1;var o=w({},["title","style","font","a","script"]);return!Qe[n]&&(o[n]||!Je[n])}return!1},ot=function(e){p(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=ie}catch(t){e.remove()}}},it=function(e,t){try{p(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){p(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!we[e])if(Fe||Ce)try{ot(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},at=function(e){var t=void 0,n=void 0;if(Me)e="<remove></remove>"+e;else{var r=h(e,/^[\r\n\t ]+/);n=r&&r[0]}var i=oe?oe.createHTML(e):e;try{t=(new $).parseFromString(i,"text/html")}catch(e){}if(!t||!t.documentElement){var a=(t=le.createHTMLDocument("")).body;a.parentNode.removeChild(a.parentNode.firstElementChild),a.outerHTML=i}return e&&n&&t.body.insertBefore(o.createTextNode(n),t.body.childNodes[0]||null),se.call(t,Oe?"html":"body")[0]},lt=function(e){return ce.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,(function(){return u.FILTER_ACCEPT}),!1)},ct=function(e){return!(e instanceof Y||e instanceof X)&&!("string"==typeof e.nodeName&&"string"==typeof e.textContent&&"function"==typeof e.removeChild&&e.attributes instanceof x&&"function"==typeof e.removeAttribute&&"function"==typeof e.setAttribute&&"string"==typeof e.namespaceURI&&"function"==typeof e.insertBefore)},st=function(e){return"object"===(void 0===c?"undefined":G(c))?e instanceof c:e&&"object"===(void 0===e?"undefined":G(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},ut=function(e,t,r){de[e]&&m(de[e],(function(e){e.call(n,t,r,Ve)}))},ft=function(e){var t=void 0;if(ut("beforeSanitizeElements",e,null),ct(e))return ot(e),!0;if(h(e.nodeName,/[\u0080-\uFFFF]/))return ot(e),!0;var r=g(e.nodeName);if(ut("uponSanitizeElement",e,{tagName:r,allowedTags:Ae}),!st(e.firstElementChild)&&(!st(e.content)||!st(e.content.firstElementChild))&&T(/<[/\w]/g,e.innerHTML)&&T(/<[/\w]/g,e.textContent))return ot(e),!0;if(!Ae[r]||ke[r]){if(Ue&&!Be[r]){var o=ne(e),i=te(e);if(i&&o)for(var a=i.length-1;a>=0;--a)o.insertBefore(Q(i[a],!0),ee(e))}return ot(e),!0}return e instanceof s&&!rt(e)?(ot(e),!0):"noscript"!==r&&"noembed"!==r||!T(/<\/no(script|embed)/i,e.innerHTML)?(Ne&&3===e.nodeType&&(t=e.textContent,t=y(t,pe," "),t=y(t,ge," "),e.textContent!==t&&(p(n.removed,{element:e.cloneNode()}),e.textContent=t)),ut("afterSanitizeElements",e,null),!1):(ot(e),!0)},mt=function(e,t,n){if(He&&("id"===t||"name"===t)&&(n in o||n in Ye))return!1;if(De&&T(he,t));else if(_e&&T(ye,t));else{if(!we[t]||Re[t])return!1;if(qe[t]);else if(T(Te,y(n,be,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(n,"data:")||!We[e]){if(Ee&&!T(ve,y(n,be,"")));else if(n)return!1}else;}return!0},dt=function(e){var t=void 0,r=void 0,o=void 0,i=void 0;ut("beforeSanitizeAttributes",e,null);var a=e.attributes;if(a){var l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:we};for(i=a.length;i--;){var c=t=a[i],s=c.name,u=c.namespaceURI;if(r=b(t.value),o=g(s),l.attrName=o,l.attrValue=r,l.keepAttr=!0,l.forceKeepAttr=void 0,ut("uponSanitizeAttribute",e,l),r=l.attrValue,!l.forceKeepAttr&&(it(s,e),l.keepAttr))if(T(/\/>/i,r))it(s,e);else{Ne&&(r=y(r,pe," "),r=y(r,ge," "));var f=e.nodeName.toLowerCase();if(mt(f,o,r))try{u?e.setAttributeNS(u,s,r):e.setAttribute(s,r),d(n.removed)}catch(e){}}}ut("afterSanitizeAttributes",e,null)}},pt=function e(t){var n=void 0,r=lt(t);for(ut("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)ut("uponSanitizeShadowNode",n,null),ft(n)||(n.content instanceof a&&e(n.content),dt(n));ut("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e,o){var i=void 0,l=void 0,s=void 0,u=void 0,f=void 0;if(e||(e="\x3c!--\x3e"),"string"!=typeof e&&!st(e)){if("function"!=typeof e.toString)throw A("toString is not a function");if("string"!=typeof(e=e.toString()))throw A("dirty is not a string, aborting")}if(!n.isSupported){if("object"===G(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(st(e))return t.toStaticHTML(e.outerHTML)}return e}if(Le||Xe(o),n.removed=[],"string"==typeof e&&(je=!1),je);else if(e instanceof c)1===(l=(i=at("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?i=l:i.appendChild(l);else{if(!Fe&&!Ne&&!Oe&&-1===e.indexOf("<"))return oe&&ze?oe.createHTML(e):e;if(!(i=at(e)))return Fe?null:ie}i&&Me&&ot(i.firstChild);for(var m=lt(je?e:i);s=m.nextNode();)3===s.nodeType&&s===u||ft(s)||(s.content instanceof a&&pt(s.content),dt(s),u=s);if(u=null,je)return e;if(Fe){if(Ce)for(f=ue.call(i.ownerDocument);i.firstChild;)f.appendChild(i.firstChild);else f=i;return Ie&&(f=fe.call(r,f,!0)),f}var d=Oe?i.outerHTML:i.innerHTML;return Ne&&(d=y(d,pe," "),d=y(d,ge," ")),oe&&ze?oe.createHTML(d):d},n.setConfig=function(e){Xe(e),Le=!0},n.clearConfig=function(){Ve=null,Le=!1},n.isValidAttribute=function(e,t,n){Ve||Xe({});var r=g(e),o=g(t);return mt(r,o,n)},n.addHook=function(e,t){"function"==typeof t&&(de[e]=de[e]||[],p(de[e],t))},n.removeHook=function(e){de[e]&&d(de[e])},n.removeHooks=function(e){de[e]&&(de[e]=[])},n.removeAllHooks=function(){de={}},n}()})); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 3e2bc930..7fed83fc 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -70,7 +70,7 @@ if ($MARKDOWN) : <?php endif; ?> - <script type="text/javascript" data-cfasync="false" src="js/purify-2.0.14.js" integrity="sha512-kbLhjIj/m/AW++o2eErCfqPueoX2btJo7VznhEC2YQRbVR/+Eup3w7thwDZwoCZ/gLrPxTX3W4H2KzupLg2PKA==" crossorigin="anonymous"></script> + <script type="text/javascript" data-cfasync="false" src="js/purify-2.2.7.js" integrity="sha512-7Ka1I/nJuR2CL8wzIS5PJS4HgEMd0HJ6kfAl6fFhwFBB27rhztFbe0tS+Ex+Qg+5n4nZIT4lty4k4Di3+X9T4A==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-3IcMpzyLRym+sBfYDMbQknNHwBW6Yh+B4aqhGrh7nkqvvNEcShmuZSPg+OVbtTvpX/9ylJl217gmtXiMNu0lZg==" crossorigin="anonymous"></script> <!-- icon --> diff --git a/tpl/page.php b/tpl/page.php index dfdee507..8361a538 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -48,7 +48,7 @@ if ($MARKDOWN): <?php endif; ?> - <script type="text/javascript" data-cfasync="false" src="js/purify-2.0.14.js" integrity="sha512-kbLhjIj/m/AW++o2eErCfqPueoX2btJo7VznhEC2YQRbVR/+Eup3w7thwDZwoCZ/gLrPxTX3W4H2KzupLg2PKA==" crossorigin="anonymous"></script> + <script type="text/javascript" data-cfasync="false" src="js/purify-2.2.7.js" integrity="sha512-7Ka1I/nJuR2CL8wzIS5PJS4HgEMd0HJ6kfAl6fFhwFBB27rhztFbe0tS+Ex+Qg+5n4nZIT4lty4k4Di3+X9T4A==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-3IcMpzyLRym+sBfYDMbQknNHwBW6Yh+B4aqhGrh7nkqvvNEcShmuZSPg+OVbtTvpX/9ylJl217gmtXiMNu0lZg==" crossorigin="anonymous"></script> <!-- icon --> From a40f3b29503070d2a630acef22518ff8292f5983 Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Sat, 3 Apr 2021 07:04:59 +0200 Subject: [PATCH 048/223] update DOMpurify to version 2.2.7 --- js/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/common.js b/js/common.js index 750e63d0..b23ed221 100644 --- a/js/common.js +++ b/js/common.js @@ -17,7 +17,7 @@ require('./prettify'); global.prettyPrint = window.PR.prettyPrint; global.prettyPrintOne = window.PR.prettyPrintOne; global.showdown = require('./showdown-1.9.1'); -global.DOMPurify = require('./purify-2.0.14'); +global.DOMPurify = require('./purify-2.2.7'); global.baseX = require('./base-x-3.0.7').baseX; global.Legacy = require('./legacy').Legacy; require('./bootstrap-3.3.7'); From 3780db627dbbc43faa22ae763fee9216ba1fdbf6 Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Sat, 3 Apr 2021 08:28:36 +0200 Subject: [PATCH 049/223] update changelog --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09f95d81..93c9f3fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,22 @@ * **1.4 (not yet released)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan + * ADDED: Make the project info configurable (#681) * CHANGED: Upgrading libraries to: DOMpurify 2.2.7 + * CHANGED: Open all links in new window (#630) + * FIXED: PDF display in Firefox (#630) + * FIXED: Allow pasting into password input dialog (#630) + * FIXED: Display of expiration date in email (#630) + * FIXED: Allow display of durations in weeks (#630) + * FIXED: Avoid exposing burn-after-reading messages from cache (#630) + * FIXED: Only display the dropzone when it should (#630) + * FIXED: Detect delete token properly (#630) + * FIXED: Sanitize output from `Helper.urls2links()` (#630) + * FIXED: Avoid recreation of existing pasteurl element when calling URL shortener (#630) + * FIXED: Downloads in Chrome >= 83 (#634) + * FIXED: Display of empty files (#663) + * FIXED: Improve OpenGraph attributes (#651) + * FIXED: Italic segment of project information (#756) * **1.3.4 (2020-03-22)** * CHANGED: Minimum required PHP version is 5.6, due to a change in the identicon library and to use php's native hash_equals() * CHANGED: Upgrading libraries to: identicon 2.0.0 From a227443cb60820bafab8b96f5f9e47e3860529a4 Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Sun, 4 Apr 2021 11:38:50 +0200 Subject: [PATCH 050/223] add missing indonesian language --- i18n/languages.json | 1 + 1 file changed, 1 insertion(+) diff --git a/i18n/languages.json b/i18n/languages.json index dace6f1e..6a83544b 100644 --- a/i18n/languages.json +++ b/i18n/languages.json @@ -66,6 +66,7 @@ "ie": ["Interlingue", "Interlingue"], "ga": ["Gaeilge", "Irish"], "ig": ["Asụsụ Igbo", "Igbo"], + "in": ["bahasa Indonesia","Indonesian"], "ik": ["Iñupiaq", "Inupiaq"], "io": ["Ido", "Ido"], "is": ["Íslenska", "Icelandic"], From df126f89d690f45b1052dd3c364202ae8012fadd Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Sun, 4 Apr 2021 11:39:46 +0200 Subject: [PATCH 051/223] add missing translation, fixes #715 --- i18n/ar.json | 3 ++- i18n/bg.json | 3 ++- i18n/ca.json | 3 ++- i18n/cs.json | 3 ++- i18n/de.json | 3 ++- i18n/el.json | 3 ++- i18n/en.json | 3 ++- i18n/es.json | 3 ++- i18n/fr.json | 3 ++- i18n/he.json | 3 ++- i18n/hi.json | 3 ++- i18n/hu.json | 3 ++- i18n/id.json | 3 ++- i18n/it.json | 3 ++- i18n/ja.json | 3 ++- i18n/ku.json | 3 ++- i18n/la.json | 3 ++- i18n/lt.json | 3 ++- i18n/nl.json | 3 ++- i18n/no.json | 3 ++- i18n/oc.json | 3 ++- i18n/pl.json | 3 ++- i18n/pt.json | 3 ++- i18n/ru.json | 3 ++- i18n/sl.json | 3 ++- i18n/sv.json | 3 ++- i18n/tr.json | 3 ++- i18n/uk.json | 3 ++- i18n/zh.json | 3 ++- 29 files changed, 58 insertions(+), 29 deletions(-) diff --git a/i18n/ar.json b/i18n/ar.json index df40bfa9..8b8e1aef 100644 --- a/i18n/ar.json +++ b/i18n/ar.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/bg.json b/i18n/bg.json index c14fac37..8ddd1f54 100644 --- a/i18n/bg.json +++ b/i18n/bg.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/ca.json b/i18n/ca.json index a33f427f..a4e6d3fd 100644 --- a/i18n/ca.json +++ b/i18n/ca.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/cs.json b/i18n/cs.json index 74de8ced..1a6249ad 100644 --- a/i18n/cs.json +++ b/i18n/cs.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/de.json b/i18n/de.json index 07beee79..dd320460 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -183,5 +183,6 @@ "Convert To UTC": "In UTC umwandeln", "Close": "Schliessen", "Encrypted note on PrivateBin": "Verschlüsselte Notiz auf PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besuche diese Verknüpfung um das Dokument zu sehen. Wird die URL an eine andere Person gegeben, so kann diese Person ebenfalls auf dieses Dokument zugreifen." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besuche diese Verknüpfung um das Dokument zu sehen. Wird die URL an eine andere Person gegeben, so kann diese Person ebenfalls auf dieses Dokument zugreifen.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/el.json b/i18n/el.json index dd439028..6fd45e41 100644 --- a/i18n/el.json +++ b/i18n/el.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/en.json b/i18n/en.json index 25d0735e..295f5129 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/es.json b/i18n/es.json index 2128c621..4e93e669 100644 --- a/i18n/es.json +++ b/i18n/es.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convertir A UTC", "Close": "Cerrar", "Encrypted note on PrivateBin": "Nota cifrada en PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visite este enlace para ver la nota. Dar la URL a cualquier persona también les permite acceder a la nota." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visite este enlace para ver la nota. Dar la URL a cualquier persona también les permite acceder a la nota.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/fr.json b/i18n/fr.json index 0f295b8a..95ec2f1a 100644 --- a/i18n/fr.json +++ b/i18n/fr.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convertir en UTC", "Close": "Fermer", "Encrypted note on PrivateBin": "Message chiffré sur PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visiter ce lien pour voir la note. Donner l'URL à une autre personne lui permet également d'accéder à la note." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visiter ce lien pour voir la note. Donner l'URL à une autre personne lui permet également d'accéder à la note.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/he.json b/i18n/he.json index 6a244579..206587b5 100644 --- a/i18n/he.json +++ b/i18n/he.json @@ -183,5 +183,6 @@ "Convert To UTC": "המרה ל־UTC", "Close": "סגירה", "Encrypted note on PrivateBin": "הערה מוצפנת ב־PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "נא לבקר בקישור כדי לצפות בהערה. מסירת הקישור לאנשים כלשהם תאפשר גם להם לגשת להערה." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "נא לבקר בקישור כדי לצפות בהערה. מסירת הקישור לאנשים כלשהם תאפשר גם להם לגשת להערה.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/hi.json b/i18n/hi.json index c6bb1c6b..a248e828 100644 --- a/i18n/hi.json +++ b/i18n/hi.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/hu.json b/i18n/hu.json index 0f6bda98..b8708367 100644 --- a/i18n/hu.json +++ b/i18n/hu.json @@ -183,5 +183,6 @@ "Convert To UTC": "Átalakítás UTC időzónára", "Close": "Bezárás", "Encrypted note on PrivateBin": "Titkosított jegyzet a PrivateBinen", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Látogasd meg ezt a hivatkozást a bejegyzés megtekintéséhez. Ha mások számára is megadod ezt a linket, azzal hozzáférnek ők is." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Látogasd meg ezt a hivatkozást a bejegyzés megtekintéséhez. Ha mások számára is megadod ezt a linket, azzal hozzáférnek ők is.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/id.json b/i18n/id.json index 487fd291..248121d1 100644 --- a/i18n/id.json +++ b/i18n/id.json @@ -183,5 +183,6 @@ "Convert To UTC": "Konversi Ke UTC", "Close": "Tutup", "Encrypted note on PrivateBin": "Catatan ter-ekrip di PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kunjungi tautan ini untuk melihat catatan. Memberikan alamat URL pada siapapun juga, akan mengizinkan mereka untuk mengakses catatan, so pasti gitu loh Kaka." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kunjungi tautan ini untuk melihat catatan. Memberikan alamat URL pada siapapun juga, akan mengizinkan mereka untuk mengakses catatan, so pasti gitu loh Kaka.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/it.json b/i18n/it.json index 2ad0621e..81b11a83 100644 --- a/i18n/it.json +++ b/i18n/it.json @@ -183,5 +183,6 @@ "Convert To UTC": "Converti a UTC", "Close": "Chiudi", "Encrypted note on PrivateBin": "Nota crittografata su PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visita questo collegamento per vedere la nota. Dare l'URL a chiunque consente anche a loro di accedere alla nota." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visita questo collegamento per vedere la nota. Dare l'URL a chiunque consente anche a loro di accedere alla nota.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/ja.json b/i18n/ja.json index 1b6e4666..bf4f7cad 100644 --- a/i18n/ja.json +++ b/i18n/ja.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/ku.json b/i18n/ku.json index 74971d24..0ff29acb 100644 --- a/i18n/ku.json +++ b/i18n/ku.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/la.json b/i18n/la.json index 1570cdd9..4d648cb9 100644 --- a/i18n/la.json +++ b/i18n/la.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/lt.json b/i18n/lt.json index ce74bdb9..f973f4f6 100644 --- a/i18n/lt.json +++ b/i18n/lt.json @@ -183,5 +183,6 @@ "Convert To UTC": "Konvertuoti į UTC", "Close": "Užverti", "Encrypted note on PrivateBin": "Šifruoti užrašai ties PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Norėdami matyti užrašus, aplankykite šį tinklalapį. Pasidalinus šiuo URL adresu su kitais žmonėmis, jiems taip pat bus leidžiama prieiga prie šių užrašų." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Norėdami matyti užrašus, aplankykite šį tinklalapį. Pasidalinus šiuo URL adresu su kitais žmonėmis, jiems taip pat bus leidžiama prieiga prie šių užrašų.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/nl.json b/i18n/nl.json index b4415bd7..54586ffb 100644 --- a/i18n/nl.json +++ b/i18n/nl.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/no.json b/i18n/no.json index 2962f8d2..ac6e369c 100644 --- a/i18n/no.json +++ b/i18n/no.json @@ -183,5 +183,6 @@ "Convert To UTC": "Konverter til UTC", "Close": "Steng", "Encrypted note on PrivateBin": "Kryptert notat på PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besøk denne lenken for å se notatet. Hvis lenken deles med andre, vil de også kunne se notatet." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besøk denne lenken for å se notatet. Hvis lenken deles med andre, vil de også kunne se notatet.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/oc.json b/i18n/oc.json index 1fc4aca5..49e3ddec 100644 --- a/i18n/oc.json +++ b/i18n/oc.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convertir en UTC", "Close": "Tampar", "Encrypted note on PrivateBin": "Nòtas chifradas sus PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visitatz aqueste ligam per veire la nòta. Fornir lo ligam a qualqu’un mai li permet tanben d’accedir a la nòta." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visitatz aqueste ligam per veire la nòta. Fornir lo ligam a qualqu’un mai li permet tanben d’accedir a la nòta.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/pl.json b/i18n/pl.json index c8abbc2e..c18ad227 100644 --- a/i18n/pl.json +++ b/i18n/pl.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/pt.json b/i18n/pt.json index 9872a572..60492078 100644 --- a/i18n/pt.json +++ b/i18n/pt.json @@ -183,5 +183,6 @@ "Convert To UTC": "Converter para UTC", "Close": "Fechar", "Encrypted note on PrivateBin": "Nota criptografada no PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visite esse link para ver a nota. Dar a URL para qualquer um permite que eles também acessem a nota." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visite esse link para ver a nota. Dar a URL para qualquer um permite que eles também acessem a nota.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/ru.json b/i18n/ru.json index a61168ab..b697f700 100644 --- a/i18n/ru.json +++ b/i18n/ru.json @@ -183,5 +183,6 @@ "Convert To UTC": "Конвертировать в UTC", "Close": "Закрыть", "Encrypted note on PrivateBin": "Зашифрованная запись на PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Посетите эту ссылку чтобы просмотреть запись. Передача ссылки кому либо позволит им получить доступ к записи тоже." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Посетите эту ссылку чтобы просмотреть запись. Передача ссылки кому либо позволит им получить доступ к записи тоже.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/sl.json b/i18n/sl.json index 4e951c79..51b9caa4 100644 --- a/i18n/sl.json +++ b/i18n/sl.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/sv.json b/i18n/sv.json index 622ba246..e0859497 100644 --- a/i18n/sv.json +++ b/i18n/sv.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/tr.json b/i18n/tr.json index d254f7d8..daedf8f8 100644 --- a/i18n/tr.json +++ b/i18n/tr.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/uk.json b/i18n/uk.json index c699db8b..2808c712 100644 --- a/i18n/uk.json +++ b/i18n/uk.json @@ -183,5 +183,6 @@ "Convert To UTC": "Convert To UTC", "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too." + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } diff --git a/i18n/zh.json b/i18n/zh.json index 0543076d..67a456f9 100644 --- a/i18n/zh.json +++ b/i18n/zh.json @@ -183,5 +183,6 @@ "Convert To UTC": "转换为UTC", "Close": "关闭", "Encrypted note on PrivateBin": "PrivateBin上的加密笔记", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "访问这个链接来查看该笔记。 将这个URL发送给任何人即可允许其访问该笔记。" + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "访问这个链接来查看该笔记。 将这个URL发送给任何人即可允许其访问该笔记。", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." } From 99358bbffc49d4c79d5c8cf6d0910d27471850ed Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Sun, 4 Apr 2021 11:41:14 +0200 Subject: [PATCH 052/223] translate new message, kudos @Cellophile in #715 --- i18n/fr.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/fr.json b/i18n/fr.json index 95ec2f1a..409d4499 100644 --- a/i18n/fr.json +++ b/i18n/fr.json @@ -184,5 +184,5 @@ "Close": "Fermer", "Encrypted note on PrivateBin": "Message chiffré sur PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visiter ce lien pour voir la note. Donner l'URL à une autre personne lui permet également d'accéder à la note.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "Raccourcir l'URL peut exposer votre clé de déchiffrement dans l'URL." } From 7ca33019d2a81c85a585c0c0aef228c8ba959567 Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Sun, 4 Apr 2021 11:43:27 +0200 Subject: [PATCH 053/223] translate new message --- i18n/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/de.json b/i18n/de.json index dd320460..dd8a48a7 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -184,5 +184,5 @@ "Close": "Schliessen", "Encrypted note on PrivateBin": "Verschlüsselte Notiz auf PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besuche diese Verknüpfung um das Dokument zu sehen. Wird die URL an eine andere Person gegeben, so kann diese Person ebenfalls auf dieses Dokument zugreifen.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "Der URL-Verkürzer kann den Schlüssel in der URL enthüllen." } From 2ca479786c528012631f5017e9dedea84ff77b23 Mon Sep 17 00:00:00 2001 From: George <george@fozzie.dev> Date: Sun, 4 Apr 2021 12:05:48 +0100 Subject: [PATCH 054/223] Remove mention of HPKP in the README. HPKP has been removed by all major browsers and according to Can I use it is only supported by browsers that have last received an update over a year ago - https://caniuse.com/?search=HPKP. --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d35035f0..6551df43 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,7 @@ without losing any data. Otherwise you would also have to trust your internet provider, and any country the traffic passes through. Additionally the instance should be secured by - [HSTS](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security) and - ideally by [HPKP](https://en.wikipedia.org/wiki/HTTP_Public_Key_Pinning) using a - certificate. It can use traditional certificate authorities and/or use + [HSTS](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security). It can use traditional certificate authorities and/or use [DNSSEC](https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions) protected [DANE](https://en.wikipedia.org/wiki/DNS-based_Authentication_of_Named_Entities) From cdc970a434c6c5293a66c52267f10433d3bbeaae Mon Sep 17 00:00:00 2001 From: rugk <rugk+git@posteo.de> Date: Sun, 4 Apr 2021 13:29:41 +0200 Subject: [PATCH 055/223] Let's try Codacy code scanning again It should now be included into GitHub's security tab. Fixes https://github.com/PrivateBin/PrivateBin/issues/741 --- codacy-analysis.yml | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 codacy-analysis.yml diff --git a/codacy-analysis.yml b/codacy-analysis.yml new file mode 100644 index 00000000..9850708b --- /dev/null +++ b/codacy-analysis.yml @@ -0,0 +1,49 @@ +# This workflow checks out code, performs a Codacy security scan +# and integrates the results with the +# GitHub Advanced Security code scanning feature. For more information on +# the Codacy security scan action usage and parameters, see +# https://github.com/codacy/codacy-analysis-cli-action. +# For more information on Codacy Analysis CLI in general, see +# https://github.com/codacy/codacy-analysis-cli. + +name: Codacy Security Scan + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '45 16 * * 1' + +jobs: + codacy-security-scan: + name: Codacy Security Scan + runs-on: ubuntu-latest + steps: + # Checkout the repository to the GitHub Actions runner + - name: Checkout code + uses: actions/checkout@v2 + + # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis + - name: Run Codacy Analysis CLI + uses: codacy/codacy-analysis-cli-action@1.1.0 + with: + # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository + # You can also omit the token and run the tools that support default configurations + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + verbose: true + output: results.sarif + format: sarif + # Adjust severity of non-security issues + gh-code-scanning-compat: true + # Force 0 exit code to allow SARIF file generation + # This will handover control about PR rejection to the GitHub side + max-allowed-issues: 2147483647 + + # Upload the SARIF file generated in the previous step + - name: Upload SARIF results file + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: results.sarif From 5fd829aa092694b069f0b10725fc00e4eb0c1946 Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Mon, 5 Apr 2021 12:50:23 +0200 Subject: [PATCH 056/223] adding unit tests for TopNav.resetInput(), triggering bug described in #682 --- js/test/TopNav.js | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/js/test/TopNav.js b/js/test/TopNav.js index e5a29c41..314d5ce6 100644 --- a/js/test/TopNav.js +++ b/js/test/TopNav.js @@ -317,6 +317,92 @@ describe('TopNav', function () { ); }); + describe('resetInput', function () { + before(function () { + cleanup(); + }); + + it( + 'reset inputs to defaults (options off)', + function () { + var results = []; + $('body').html( + '<nav><div id="navbar"><ul><li id="burnafterreadingoption" ' + + 'class="hidden"><label><input type="checkbox" ' + + 'id="burnafterreading" name="burnafterreading" /> ' + + 'Burn after reading</label></li><li id="opendiscussionoption" ' + + 'class="hidden"><label><input type="checkbox" ' + + 'id="opendiscussion" name="opendiscussion" /> ' + + 'Open discussion</label></li></ul></div></nav>' + ); + $.PrivateBin.TopNav.init(); + results.push( + !$.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + !$.PrivateBin.TopNav.getOpenDiscussion() + ); + $('#burnafterreading').attr('checked', 'checked'); + $('#opendiscussion').attr('checked', 'checked'); + results.push( + $.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + $.PrivateBin.TopNav.getOpenDiscussion() + ); + $.PrivateBin.TopNav.resetInput(); + results.push( + !$.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + !$.PrivateBin.TopNav.getOpenDiscussion() + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + + it( + 'reset inputs to defaults (options on)', + function () { + var results = []; + $('body').html( + '<nav><div id="navbar"><ul><li id="burnafterreadingoption" ' + + 'class="hidden"><label><input type="checkbox" ' + + 'id="burnafterreading" name="burnafterreading" checked="checked" /> ' + + 'Burn after reading</label></li><li id="opendiscussionoption" ' + + 'class="hidden"><label><input type="checkbox" ' + + 'id="opendiscussion" name="opendiscussion" checked="checked" /> ' + + 'Open discussion</label></li></ul></div></nav>' + ); + $.PrivateBin.TopNav.init(); + results.push( + $.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + $.PrivateBin.TopNav.getOpenDiscussion() + ); + $('#burnafterreading').removeAttr('checked'); + $('#opendiscussion').removeAttr('checked'); + results.push( + !$.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + !$.PrivateBin.TopNav.getOpenDiscussion() + ); + $.PrivateBin.TopNav.resetInput(); + results.push( + $.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + $.PrivateBin.TopNav.getOpenDiscussion() + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + }); + describe('getExpiration', function () { before(function () { cleanup(); From 77ee40909f144afceb6c24ad2233f3bc83b638bd Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Mon, 5 Apr 2021 13:24:53 +0200 Subject: [PATCH 057/223] record defaults during initialization, fixes #682 --- js/privatebin.js | 15 +++++++++------ js/test/TopNav.js | 45 ++++++++++++++++++++++++++++++++++++++++++--- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 9beb3d99..c18bdfea 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -3508,6 +3508,8 @@ jQuery.PrivateBin = (function($, RawDeflate) { let createButtonsDisplayed = false, viewButtonsDisplayed = false, + burnAfterReadingDefault = false, + openDiscussionDefault = false, $attach, $burnAfterReading, $burnAfterReadingOption, @@ -4152,11 +4154,10 @@ jQuery.PrivateBin = (function($, RawDeflate) { me.resetInput = function() { clearAttachmentInput(); - - $openDiscussion.prop('checked', false); - $burnAfterReading.prop('checked', false); - $openDiscussionOption.removeClass('buttondisabled'); - $burnAfterReadingOption.removeClass('buttondisabled'); + $burnAfterReading.prop('checked', burnAfterReadingDefault); + $openDiscussion.prop('checked', openDiscussionDefault); + if (openDiscussionDefault) $openDiscussionOption.removeClass('buttondisabled'); + if (burnAfterReadingDefault) $burnAfterReadingOption.removeClass('buttondisabled'); // TODO: reset expiration time }; @@ -4356,7 +4357,9 @@ jQuery.PrivateBin = (function($, RawDeflate) { changeBurnAfterReading(); changeOpenDiscussion(); - // get default value from template or fall back to set value + // get default values from template or fall back to set value + burnAfterReadingDefault = me.getBurnAfterReading(); + openDiscussionDefault = me.getOpenDiscussion(); pasteExpiration = Model.getExpirationDefault() || pasteExpiration; createButtonsDisplayed = false; diff --git a/js/test/TopNav.js b/js/test/TopNav.js index 314d5ce6..29639643 100644 --- a/js/test/TopNav.js +++ b/js/test/TopNav.js @@ -363,7 +363,7 @@ describe('TopNav', function () { ); it( - 'reset inputs to defaults (options on)', + 'reset inputs to defaults (burnafterreading on)', function () { var results = []; $('body').html( @@ -380,10 +380,9 @@ describe('TopNav', function () { $.PrivateBin.TopNav.getBurnAfterReading() ); results.push( - $.PrivateBin.TopNav.getOpenDiscussion() + !$.PrivateBin.TopNav.getOpenDiscussion() ); $('#burnafterreading').removeAttr('checked'); - $('#opendiscussion').removeAttr('checked'); results.push( !$.PrivateBin.TopNav.getBurnAfterReading() ); @@ -394,6 +393,46 @@ describe('TopNav', function () { results.push( $.PrivateBin.TopNav.getBurnAfterReading() ); + results.push( + !$.PrivateBin.TopNav.getOpenDiscussion() + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + + it( + 'reset inputs to defaults (opendiscussion on)', + function () { + var results = []; + $('body').html( + '<nav><div id="navbar"><ul><li id="burnafterreadingoption" ' + + 'class="hidden"><label><input type="checkbox" ' + + 'id="burnafterreading" name="burnafterreading" /> ' + + 'Burn after reading</label></li><li id="opendiscussionoption" ' + + 'class="hidden"><label><input type="checkbox" ' + + 'id="opendiscussion" name="opendiscussion" checked="checked" /> ' + + 'Open discussion</label></li></ul></div></nav>' + ); + $.PrivateBin.TopNav.init(); + results.push( + !$.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + $.PrivateBin.TopNav.getOpenDiscussion() + ); + $('#opendiscussion').removeAttr('checked'); + $('#burnafterreading').prop('checked', true); + results.push( + $.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + !$.PrivateBin.TopNav.getOpenDiscussion() + ); + $.PrivateBin.TopNav.resetInput(); + results.push( + !$.PrivateBin.TopNav.getBurnAfterReading() + ); results.push( $.PrivateBin.TopNav.getOpenDiscussion() ); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 7fed83fc..81bc3554 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> <script type="text/javascript" data-cfasync="false" src="js/purify-2.2.7.js" integrity="sha512-7Ka1I/nJuR2CL8wzIS5PJS4HgEMd0HJ6kfAl6fFhwFBB27rhztFbe0tS+Ex+Qg+5n4nZIT4lty4k4Di3+X9T4A==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script> - <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-3IcMpzyLRym+sBfYDMbQknNHwBW6Yh+B4aqhGrh7nkqvvNEcShmuZSPg+OVbtTvpX/9ylJl217gmtXiMNu0lZg==" crossorigin="anonymous"></script> + <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-vJA5JXQBkfshqUIYHM/SkXWjBpwrZLlSXYRm+NERFD7t4Dg0tEdDV0NdBsItj1NXqfJ1062fT5okEav5eqUSMA==" crossorigin="anonymous"></script> <!-- icon --> <link rel="apple-touch-icon" href="<?php echo I18n::encode($BASEPATH); ?>img/apple-touch-icon.png" sizes="180x180" /> <link rel="icon" type="image/png" href="img/favicon-32x32.png" sizes="32x32" /> diff --git a/tpl/page.php b/tpl/page.php index 8361a538..c139f9c0 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> <script type="text/javascript" data-cfasync="false" src="js/purify-2.2.7.js" integrity="sha512-7Ka1I/nJuR2CL8wzIS5PJS4HgEMd0HJ6kfAl6fFhwFBB27rhztFbe0tS+Ex+Qg+5n4nZIT4lty4k4Di3+X9T4A==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script> - <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-3IcMpzyLRym+sBfYDMbQknNHwBW6Yh+B4aqhGrh7nkqvvNEcShmuZSPg+OVbtTvpX/9ylJl217gmtXiMNu0lZg==" crossorigin="anonymous"></script> + <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-vJA5JXQBkfshqUIYHM/SkXWjBpwrZLlSXYRm+NERFD7t4Dg0tEdDV0NdBsItj1NXqfJ1062fT5okEav5eqUSMA==" crossorigin="anonymous"></script> <!-- icon --> <link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" /> <link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" /> From a369202c5178035a0fb3f978b92eb6040c8ec3e2 Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Mon, 5 Apr 2021 13:47:37 +0200 Subject: [PATCH 058/223] add missing expiration reset --- js/privatebin.js | 12 +++++++++--- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index c18bdfea..32ed9681 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -4156,10 +4156,16 @@ jQuery.PrivateBin = (function($, RawDeflate) { clearAttachmentInput(); $burnAfterReading.prop('checked', burnAfterReadingDefault); $openDiscussion.prop('checked', openDiscussionDefault); - if (openDiscussionDefault) $openDiscussionOption.removeClass('buttondisabled'); - if (burnAfterReadingDefault) $burnAfterReadingOption.removeClass('buttondisabled'); + if (openDiscussionDefault || !burnAfterReadingDefault) $openDiscussionOption.removeClass('buttondisabled'); + if (burnAfterReadingDefault || !openDiscussionDefault) $burnAfterReadingOption.removeClass('buttondisabled'); - // TODO: reset expiration time + pasteExpiration = Model.getExpirationDefault() || pasteExpiration; + $('#pasteExpiration>option').each(function() { + const $this = $(this); + if ($this.val() === pasteExpiration) { + $('#pasteExpirationDisplay').text($this.text()); + } + }); }; /** diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 81bc3554..5f2d0382 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> <script type="text/javascript" data-cfasync="false" src="js/purify-2.2.7.js" integrity="sha512-7Ka1I/nJuR2CL8wzIS5PJS4HgEMd0HJ6kfAl6fFhwFBB27rhztFbe0tS+Ex+Qg+5n4nZIT4lty4k4Di3+X9T4A==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script> - <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-vJA5JXQBkfshqUIYHM/SkXWjBpwrZLlSXYRm+NERFD7t4Dg0tEdDV0NdBsItj1NXqfJ1062fT5okEav5eqUSMA==" crossorigin="anonymous"></script> + <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-j14FgvVKISnKDHFcU10MHg1v+m148Txkz585Hx6UOqBe8nwldVF3uhDN+Ohp5ddg9gZS89aRzHplX4C7/ZfeTA==" crossorigin="anonymous"></script> <!-- icon --> <link rel="apple-touch-icon" href="<?php echo I18n::encode($BASEPATH); ?>img/apple-touch-icon.png" sizes="180x180" /> <link rel="icon" type="image/png" href="img/favicon-32x32.png" sizes="32x32" /> diff --git a/tpl/page.php b/tpl/page.php index c139f9c0..0789680b 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> <script type="text/javascript" data-cfasync="false" src="js/purify-2.2.7.js" integrity="sha512-7Ka1I/nJuR2CL8wzIS5PJS4HgEMd0HJ6kfAl6fFhwFBB27rhztFbe0tS+Ex+Qg+5n4nZIT4lty4k4Di3+X9T4A==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script> - <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-vJA5JXQBkfshqUIYHM/SkXWjBpwrZLlSXYRm+NERFD7t4Dg0tEdDV0NdBsItj1NXqfJ1062fT5okEav5eqUSMA==" crossorigin="anonymous"></script> + <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-j14FgvVKISnKDHFcU10MHg1v+m148Txkz585Hx6UOqBe8nwldVF3uhDN+Ohp5ddg9gZS89aRzHplX4C7/ZfeTA==" crossorigin="anonymous"></script> <!-- icon --> <link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" /> <link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" /> From ec022b2db9a869191fac960f44cf88a41d58a036 Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Mon, 5 Apr 2021 13:51:23 +0200 Subject: [PATCH 059/223] documenting fix for #682 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93c9f3fe..b097bea8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ * FIXED: Downloads in Chrome >= 83 (#634) * FIXED: Display of empty files (#663) * FIXED: Improve OpenGraph attributes (#651) + * FIXED: Reset to configured burn-after-reading, discussion and expiration settings (#682) * FIXED: Italic segment of project information (#756) * **1.3.4 (2020-03-22)** * CHANGED: Minimum required PHP version is 5.6, due to a change in the identicon library and to use php's native hash_equals() From 458ebcb3213a65063c2b4e0194439d45cf0d1b7a Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Mon, 5 Apr 2021 16:44:12 +0200 Subject: [PATCH 060/223] incrementing version --- CHANGELOG.md | 1 + INSTALL.md | 2 +- Makefile | 4 ++-- README.md | 2 +- SECURITY.md | 4 ++-- css/bootstrap/privatebin.css | 2 +- css/noscript.css | 2 +- css/privatebin.css | 2 +- index.php | 2 +- js/privatebin.js | 2 +- lib/Configuration.php | 2 +- lib/Controller.php | 4 ++-- lib/Data/AbstractData.php | 2 +- lib/Data/Database.php | 2 +- lib/Data/Filesystem.php | 2 +- lib/Filter.php | 2 +- lib/FormatV2.php | 2 +- lib/I18n.php | 2 +- lib/Json.php | 2 +- lib/Model.php | 2 +- lib/Model/AbstractModel.php | 2 +- lib/Model/Comment.php | 2 +- lib/Model/Paste.php | 2 +- lib/Persistence/AbstractPersistence.php | 2 +- lib/Persistence/DataStore.php | 2 +- lib/Persistence/PurgeLimiter.php | 2 +- lib/Persistence/ServerSalt.php | 2 +- lib/Persistence/TrafficLimiter.php | 2 +- lib/Request.php | 2 +- lib/View.php | 2 +- lib/Vizhash16x16.php | 2 +- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 33 files changed, 36 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b097bea8..52a54ede 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # PrivateBin version history * **1.4 (not yet released)** + * **1.3.5 (2021-04-05)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan * ADDED: Make the project info configurable (#681) * CHANGED: Upgrading libraries to: DOMpurify 2.2.7 diff --git a/INSTALL.md b/INSTALL.md index 68b9d9df..df0cac23 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -187,7 +187,7 @@ CREATE INDEX parent ON prefix_comment(pasteid); CREATE TABLE prefix_config ( id CHAR(16) NOT NULL, value TEXT, PRIMARY KEY (id) ); -INSERT INTO prefix_config VALUES('VERSION', '1.3.4'); +INSERT INTO prefix_config VALUES('VERSION', '1.3.5'); ``` In **PostgreSQL**, the data, attachment, nickname and vizhash columns needs to be TEXT and not BLOB or MEDIUMBLOB. diff --git a/Makefile b/Makefile index ca176d39..4bf6e01a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: all coverage coverage-js coverage-php doc doc-js doc-php increment sign test test-js test-php help -CURRENT_VERSION = 1.3.4 -VERSION ?= 1.3.5 +CURRENT_VERSION = 1.3.5 +VERSION ?= 1.3.6 VERSION_FILES = index.php cfg/ *.md css/ i18n/ img/ js/privatebin.js lib/ Makefile tpl/ tst/ REGEX_CURRENT_VERSION := $(shell echo $(CURRENT_VERSION) | sed "s/\./\\\./g") REGEX_VERSION := $(shell echo $(VERSION) | sed "s/\./\\\./g") diff --git a/README.md b/README.md index 6551df43..7d39952c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [![PrivateBin](https://cdn.rawgit.com/PrivateBin/assets/master/images/preview/logoSmall.png)](https://privatebin.info/) -*Current version: 1.3.4* +*Current version: 1.3.5* **PrivateBin** is a minimalist, open source online [pastebin](https://en.wikipedia.org/wiki/Pastebin) where the server has zero knowledge of pasted data. diff --git a/SECURITY.md b/SECURITY.md index 1a5bf963..e00398b9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,8 +4,8 @@ | Version | Supported | | ------- | ------------------ | -| 1.3.4 | :heavy_check_mark: | -| < 1.3.4 | :x: | +| 1.3.5 | :heavy_check_mark: | +| < 1.3.5 | :x: | ## Reporting a Vulnerability diff --git a/css/bootstrap/privatebin.css b/css/bootstrap/privatebin.css index 72e420ed..de8b6797 100644 --- a/css/bootstrap/privatebin.css +++ b/css/bootstrap/privatebin.css @@ -6,7 +6,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ body { diff --git a/css/noscript.css b/css/noscript.css index e44670f0..f42e419f 100644 --- a/css/noscript.css +++ b/css/noscript.css @@ -6,7 +6,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ /* When there is no script at all other */ diff --git a/css/privatebin.css b/css/privatebin.css index a3ab5ea6..8b4e6a0a 100644 --- a/css/privatebin.css +++ b/css/privatebin.css @@ -6,7 +6,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ /* CSS Reset from YUI 3.4.1 (build 4118) - Copyright 2011 Yahoo! Inc. All rights reserved. diff --git a/index.php b/index.php index a6d7cdf2..f846adb7 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ // change this, if your php files and data is outside of your webservers document root diff --git a/js/privatebin.js b/js/privatebin.js index 32ed9681..42cdd961 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -6,7 +6,7 @@ * @see {@link https://github.com/PrivateBin/PrivateBin} * @copyright 2012 Sébastien SAUVAGE ({@link http://sebsauvage.net}) * @license {@link https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License} - * @version 1.3.4 + * @version 1.3.5 * @name PrivateBin * @namespace */ diff --git a/lib/Configuration.php b/lib/Configuration.php index b598326b..2a326caf 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin; diff --git a/lib/Controller.php b/lib/Controller.php index 65243aaf..38fc09d9 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin; @@ -28,7 +28,7 @@ class Controller * * @const string */ - const VERSION = '1.3.4'; + const VERSION = '1.3.5'; /** * minimal required PHP version diff --git a/lib/Data/AbstractData.php b/lib/Data/AbstractData.php index 9c925838..077864ec 100644 --- a/lib/Data/AbstractData.php +++ b/lib/Data/AbstractData.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin\Data; diff --git a/lib/Data/Database.php b/lib/Data/Database.php index aa05e95a..607013ba 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin\Data; diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 3e9b237f..96ee6915 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin\Data; diff --git a/lib/Filter.php b/lib/Filter.php index 547e2395..0ad87d3c 100644 --- a/lib/Filter.php +++ b/lib/Filter.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin; diff --git a/lib/FormatV2.php b/lib/FormatV2.php index 31cc5b84..a06aa5d3 100644 --- a/lib/FormatV2.php +++ b/lib/FormatV2.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin; diff --git a/lib/I18n.php b/lib/I18n.php index 6299f220..ea7d07f9 100644 --- a/lib/I18n.php +++ b/lib/I18n.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin; diff --git a/lib/Json.php b/lib/Json.php index 6916d27f..b6567ed5 100644 --- a/lib/Json.php +++ b/lib/Json.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin; diff --git a/lib/Model.php b/lib/Model.php index f5dd5577..5abb1d15 100644 --- a/lib/Model.php +++ b/lib/Model.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin; diff --git a/lib/Model/AbstractModel.php b/lib/Model/AbstractModel.php index b7273399..f2ab1daa 100644 --- a/lib/Model/AbstractModel.php +++ b/lib/Model/AbstractModel.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin\Model; diff --git a/lib/Model/Comment.php b/lib/Model/Comment.php index 68045aa9..4b3fc828 100644 --- a/lib/Model/Comment.php +++ b/lib/Model/Comment.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin\Model; diff --git a/lib/Model/Paste.php b/lib/Model/Paste.php index 0aa2a967..6f343938 100644 --- a/lib/Model/Paste.php +++ b/lib/Model/Paste.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin\Model; diff --git a/lib/Persistence/AbstractPersistence.php b/lib/Persistence/AbstractPersistence.php index a4011d2d..0dcef50e 100644 --- a/lib/Persistence/AbstractPersistence.php +++ b/lib/Persistence/AbstractPersistence.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin\Persistence; diff --git a/lib/Persistence/DataStore.php b/lib/Persistence/DataStore.php index f60fc972..d96f0707 100644 --- a/lib/Persistence/DataStore.php +++ b/lib/Persistence/DataStore.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin\Persistence; diff --git a/lib/Persistence/PurgeLimiter.php b/lib/Persistence/PurgeLimiter.php index 0e987953..ea07e322 100644 --- a/lib/Persistence/PurgeLimiter.php +++ b/lib/Persistence/PurgeLimiter.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin\Persistence; diff --git a/lib/Persistence/ServerSalt.php b/lib/Persistence/ServerSalt.php index 7764129f..329a8ef2 100644 --- a/lib/Persistence/ServerSalt.php +++ b/lib/Persistence/ServerSalt.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin\Persistence; diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 0e6a34b0..a16cd0b3 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin\Persistence; diff --git a/lib/Request.php b/lib/Request.php index 785f0f45..cfa883ad 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin; diff --git a/lib/View.php b/lib/View.php index b154ed86..81698047 100644 --- a/lib/View.php +++ b/lib/View.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.3.4 + * @version 1.3.5 */ namespace PrivateBin; diff --git a/lib/Vizhash16x16.php b/lib/Vizhash16x16.php index 0292de3c..77584eb0 100644 --- a/lib/Vizhash16x16.php +++ b/lib/Vizhash16x16.php @@ -8,7 +8,7 @@ * @link http://sebsauvage.net/wiki/doku.php?id=php:vizhash_gd * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 0.0.5 beta PrivateBin 1.3.4 + * @version 0.0.5 beta PrivateBin 1.3.5 */ namespace PrivateBin; diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 5f2d0382..581f83c0 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> <script type="text/javascript" data-cfasync="false" src="js/purify-2.2.7.js" integrity="sha512-7Ka1I/nJuR2CL8wzIS5PJS4HgEMd0HJ6kfAl6fFhwFBB27rhztFbe0tS+Ex+Qg+5n4nZIT4lty4k4Di3+X9T4A==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script> - <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-j14FgvVKISnKDHFcU10MHg1v+m148Txkz585Hx6UOqBe8nwldVF3uhDN+Ohp5ddg9gZS89aRzHplX4C7/ZfeTA==" crossorigin="anonymous"></script> + <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-wuKnPu9+bTYhJ0HRhUmw0UxWYP5mbQehFNspkD9N4mTlxLkjRZXPnMt/nfT2/U62rRDUw1HL3SvveKJe2v4EBw==" crossorigin="anonymous"></script> <!-- icon --> <link rel="apple-touch-icon" href="<?php echo I18n::encode($BASEPATH); ?>img/apple-touch-icon.png" sizes="180x180" /> <link rel="icon" type="image/png" href="img/favicon-32x32.png" sizes="32x32" /> diff --git a/tpl/page.php b/tpl/page.php index 0789680b..097b528a 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> <script type="text/javascript" data-cfasync="false" src="js/purify-2.2.7.js" integrity="sha512-7Ka1I/nJuR2CL8wzIS5PJS4HgEMd0HJ6kfAl6fFhwFBB27rhztFbe0tS+Ex+Qg+5n4nZIT4lty4k4Di3+X9T4A==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script> - <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-j14FgvVKISnKDHFcU10MHg1v+m148Txkz585Hx6UOqBe8nwldVF3uhDN+Ohp5ddg9gZS89aRzHplX4C7/ZfeTA==" crossorigin="anonymous"></script> + <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-wuKnPu9+bTYhJ0HRhUmw0UxWYP5mbQehFNspkD9N4mTlxLkjRZXPnMt/nfT2/U62rRDUw1HL3SvveKJe2v4EBw==" crossorigin="anonymous"></script> <!-- icon --> <link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" /> <link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" /> From 65d8f896c758d5b0ff324cde6d9dd73542facdb2 Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Mon, 5 Apr 2021 17:05:46 +0200 Subject: [PATCH 061/223] fix make coverage-php --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4bf6e01a..ca443f56 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ coverage-js: ## Run JS unit tests and generate code coverage reports. coverage-php: ## Run PHP unit tests and generate code coverage reports. cd tst && phpunit 2> /dev/null - cd log/php-coverage-report && sed -i "s#$(CURDIR)##g" *.html */*.html + cd tst/log/php-coverage-report && sed -i "s#$(CURDIR)##g" *.html */*.html doc: doc-js doc-php ## Generate all code documentation. From 30c8d97517346e206c324fc1bedc6bbeee8d1fcf Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Mon, 5 Apr 2021 17:11:51 +0200 Subject: [PATCH 062/223] update PHP dependencies --- Makefile | 3 + composer.json | 6 +- composer.lock | 268 +++++++++++------- vendor/composer/ClassLoader.php | 4 +- vendor/composer/autoload_real.php | 3 + .../random_compat/phpunit-autoload.php | 14 + 6 files changed, 185 insertions(+), 113 deletions(-) create mode 100644 vendor/paragonie/random_compat/phpunit-autoload.php diff --git a/Makefile b/Makefile index ca443f56..691d72bf 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ REGEX_VERSION := $(shell echo $(VERSION) | sed "s/\./\\\./g") all: coverage doc ## Equivalent to running `make coverage doc`. +composer: ## Update composer dependencies (only production ones, optimize the autoloader) + composer update --no-dev --optimize-autoloader + coverage: coverage-js coverage-php ## Run all unit tests and generate code coverage reports. coverage-js: ## Run JS unit tests and generate code coverage reports. diff --git a/composer.json b/composer.json index c1086acf..899c863f 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,8 @@ "docs" : "https://privatebin.info/codedoc/" }, "require" : { - "php" : "^5.6.0 || ^7.0", - "paragonie/random_compat" : "2.0.18", + "php" : "^5.6.0 || ^7.0 || ^8.0", + "paragonie/random_compat" : "2.0.19", "yzalis/identicon" : "2.0.0" }, "require-dev" : { @@ -39,4 +39,4 @@ "config" : { "autoloader-suffix" : "DontChange" } -} +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index d8bf1cce..80d2276f 100644 --- a/composer.lock +++ b/composer.lock @@ -1,23 +1,23 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "203b93e3e8cb37cc45988bb0ca1364bc", + "content-hash": "9d110873bf15a6abd66734e8a818134c", "packages": [ { "name": "paragonie/random_compat", - "version": "v2.0.18", + "version": "v2.0.19", "source": { "type": "git", "url": "https://github.com/paragonie/random_compat.git", - "reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db" + "reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/0a58ef6e3146256cc3dc7cc393927bcc7d1b72db", - "reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/446fc9faa5c2a9ddf65eb7121c0af7e857295241", + "reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241", "shasum": "" }, "require": { @@ -53,7 +53,7 @@ "pseudorandom", "random" ], - "time": "2019-01-03T20:59:08+00:00" + "time": "2020-10-15T10:06:57+00:00" }, { "name": "yzalis/identicon", @@ -105,42 +105,38 @@ "identicon", "image" ], + "abandoned": true, "time": "2019-10-14T09:30:57+00:00" } ], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^6.0", + "doctrine/coding-standard": "^8.0", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^7.0" + "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, "autoload": { "psr-4": { "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" @@ -154,7 +150,7 @@ { "name": "Marco Pivetta", "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "homepage": "https://ocramius.github.io/" } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", @@ -163,24 +159,38 @@ "constructor", "instantiate" ], - "time": "2019-10-21T16:45:58+00:00" + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2020-11-10T18:47:58+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.9.5", + "version": "1.10.2", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "replace": { "myclabs/deep-copy": "self.version" @@ -211,32 +221,35 @@ "object", "object graph" ], - "time": "2020-01-17T21:11:47+00:00" + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-11-13T09:40:50+00:00" }, { "name": "phpdocumentor/reflection-common", - "version": "2.0.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", "shasum": "" }, "require": { - "php": ">=7.1" - }, - "require-dev": { - "phpunit/phpunit": "~6" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-2.x": "2.x-dev" } }, "autoload": { @@ -263,45 +276,41 @@ "reflection", "static analysis" ], - "time": "2018-08-07T13:53:10+00:00" + "time": "2020-06-27T09:03:43+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.4", + "version": "5.2.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", - "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", - "webmozart/assert": "^1.0" + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" }, "require-dev": { - "doctrine/instantiator": "^1.0.5", - "mockery/mockery": "^1.0", - "phpdocumentor/type-resolver": "0.4.*", - "phpunit/phpunit": "^6.4" + "mockery/mockery": "~1.3.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -312,38 +321,40 @@ { "name": "Mike van Riel", "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-12-28T18:55:12+00:00" + "time": "2020-09-03T19:13:55+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.0.1", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", "shasum": "" }, "require": { - "php": "^7.1", + "php": "^7.2 || ^8.0", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "^7.1", - "mockery/mockery": "~1", - "phpunit/phpunit": "^7.0" + "ext-tokenizer": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-1.x": "1.x-dev" } }, "autoload": { @@ -362,20 +373,20 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2019-08-22T18:11:29+00:00" + "time": "2020-09-17T18:55:26+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.10.2", + "version": "v1.10.3", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9" + "reference": "451c3cd1418cf640de218914901e51b064abb093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b4400efc9d206e83138e2bb97ed7f5b14b831cd9", - "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", + "reference": "451c3cd1418cf640de218914901e51b064abb093", "shasum": "" }, "require": { @@ -425,7 +436,7 @@ "spy", "stub" ], - "time": "2020-01-20T15:57:02+00:00" + "time": "2020-03-05T15:02:03+00:00" }, { "name": "phpunit/php-code-coverage", @@ -674,6 +685,7 @@ "keywords": [ "tokenizer" ], + "abandoned": true, "time": "2017-11-27T05:48:46+00:00" }, { @@ -820,23 +832,23 @@ }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { @@ -861,7 +873,13 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T08:15:22+00:00" }, { "name": "sebastian/comparator", @@ -1333,20 +1351,20 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.17.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9" + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e94c8b1bbe2bc77507a1056cdb06451c75b427f9", - "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-ctype": "For best performance" @@ -1354,7 +1372,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -1387,20 +1409,34 @@ "polyfill", "portable" ], - "time": "2020-05-12T16:14:59+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/yaml", - "version": "v4.4.9", + "version": "v4.4.21", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a" + "reference": "3871c720871029f008928244e56cf43497da7e9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a", - "reference": "c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a", + "url": "https://api.github.com/repos/symfony/yaml/zipball/3871c720871029f008928244e56cf43497da7e9d", + "reference": "3871c720871029f008928244e56cf43497da7e9d", "shasum": "" }, "require": { @@ -1417,11 +1453,6 @@ "symfony/console": "For validating YAML files using the lint command" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.4-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\Yaml\\": "" @@ -1444,35 +1475,55 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Yaml Component", + "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", - "time": "2020-05-20T08:37:50+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-05T17:58:50+00:00" }, { "name": "webmozart/assert", - "version": "1.6.0", + "version": "1.10.0", "source": { "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" + "url": "https://github.com/webmozarts/assert.git", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^7.2 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { - "vimeo/psalm": "<3.6.0" + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<4.6.1 || 4.6.2" }, "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^7.5.13" + "phpunit/phpunit": "^8.5.13" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -1494,7 +1545,7 @@ "check", "validate" ], - "time": "2019-11-24T13:36:37+00:00" + "time": "2021-03-09T10:59:23+00:00" } ], "aliases": [], @@ -1503,7 +1554,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^5.6.0 || ^7.0" + "php": "^5.6.0 || ^7.0 || ^8.0" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index dc02dfb1..fce8549f 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -279,7 +279,7 @@ class ClassLoader */ public function setApcuPrefix($apcuPrefix) { - $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; } /** @@ -377,7 +377,7 @@ class ClassLoader $subPath = $class; while (false !== $lastPos = strrpos($subPath, '\\')) { $subPath = substr($subPath, 0, $lastPos); - $search = $subPath.'\\'; + $search = $subPath . '\\'; if (isset($this->prefixDirsPsr4[$search])) { $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); foreach ($this->prefixDirsPsr4[$search] as $dir) { diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 2e234b96..7a6fd4c0 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -13,6 +13,9 @@ class ComposerAutoloaderInitDontChange } } + /** + * @return \Composer\Autoload\ClassLoader + */ public static function getLoader() { if (null !== self::$loader) { diff --git a/vendor/paragonie/random_compat/phpunit-autoload.php b/vendor/paragonie/random_compat/phpunit-autoload.php new file mode 100644 index 00000000..87b01aac --- /dev/null +++ b/vendor/paragonie/random_compat/phpunit-autoload.php @@ -0,0 +1,14 @@ +<?php + +require_once __DIR__ . '/psalm-autoload.php'; + +/** + * This is necessary for PHPUnit on PHP >= 5.3 + * + * Class PHPUnit_Framework_TestCase + */ +if (PHP_VERSION_ID >= 50300) { + if (!class_exists('PHPUnit_Framework_TestCase')) { + require_once __DIR__ . '/other/phpunit-shim.php'; + } +} From d65bf02d7819a530c3c2a88f6f9947651fe5258d Mon Sep 17 00:00:00 2001 From: El RIDO <elrido@gmx.net> Date: Mon, 5 Apr 2021 17:33:07 +0200 Subject: [PATCH 063/223] upgraded kjua --- CHANGELOG.md | 2 +- js/kjua-0.6.0.js | 2 -- js/kjua-0.9.0.js | 2 ++ tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 js/kjua-0.6.0.js create mode 100644 js/kjua-0.9.0.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 52a54ede..201fb81d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * **1.3.5 (2021-04-05)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan * ADDED: Make the project info configurable (#681) - * CHANGED: Upgrading libraries to: DOMpurify 2.2.7 + * CHANGED: Upgrading libraries to: DOMpurify 2.2.7, kjua 0.9.0 & random_compat 2.0.18 * CHANGED: Open all links in new window (#630) * FIXED: PDF display in Firefox (#630) * FIXED: Allow pasting into password input dialog (#630) diff --git a/js/kjua-0.6.0.js b/js/kjua-0.6.0.js deleted file mode 100644 index f70482d4..00000000 --- a/js/kjua-0.6.0.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! kjua v0.6.0 - https://larsjung.de/kjua/ */ -!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("kjua",[],r):"object"==typeof exports?exports.kjua=r():t.kjua=r()}("undefined"!=typeof self?self:this,function(){return function(e){var n={};function o(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=e,o.c=n,o.d=function(t,r,e){o.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(r,t){if(1&t&&(r=o(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var e=Object.create(null);if(o.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var n in r)o.d(e,n,function(t){return r[t]}.bind(null,n));return e},o.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(r,"a",r),r},o.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},o.p="",o(o.s=0)}([function(t,r,e){var n=e(1),a=n.create_canvas,u=n.canvas_to_img,f=n.dpr,c=e(3),l=e(4),s=e(6);t.exports=function(t){var r=Object.assign({},c,t),e=l(r.text,r.ecLevel,r.minVersion,r.quiet),n=r.ratio||f,o=a(r.size,n),i=o.getContext("2d");return i.scale(n,n),s(e,i,r),"image"===r.render?u(o):o}},function(u,t,r){(function(t){function n(t){return i.createElement(t)}function e(t,r){return t.getAttribute(r)}function o(t,r,e){return t.setAttribute(r,e)}var r=t.window,i=r.document,a=r.devicePixelRatio||1;u.exports={create_canvas:function(t,r){var e=n("canvas");return o(e,"width",t*r),o(e,"height",t*r),e.style.width="".concat(t,"px"),e.style.height="".concat(t,"px"),e},canvas_to_img:function(t){var r=n("img");return o(r,"crossorigin","anonymous"),o(r,"src",t.toDataURL("image/png")),o(r,"width",e(t,"width")),o(r,"height",e(t,"height")),r.style.width=t.style.width,r.style.height=t.style.height,r},dpr:a}}).call(this,r(2))},function(t,r){var e;e=function(){return this}();try{e=e||new Function("return this")()}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,r){t.exports={render:"image",crisp:!0,minVersion:1,ecLevel:"L",size:200,ratio:null,fill:"#333",back:"#fff",text:"no text",rounded:0,quiet:0,mode:"plain",mSize:30,mPosX:50,mPosY:50,label:"no label",fontname:"sans",fontcolor:"#333",image:null}},function(t,r,e){function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var u=/code length overflow/i,f=e(5);f.stringToBytes=f.stringToBytesFuncs["UTF-8"];t.exports=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"L",e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1,n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,o=function(t,r){for(var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1,o=e=Math.max(1,e);o<=40;o+=1)try{var n=function(){var e=f(o,r);e.addData(t),e.make();var n=e.getModuleCount();return{v:{text:t,level:r,version:o,moduleCount:n,isDark:function(t,r){return 0<=t&&t<n&&0<=r&&r<n&&e.isDark(t,r)}}}}();if("object"===a(n))return n.v}catch(t){if(!(o<40&&u.test(t)))throw new Error(t)}return null}(t,r,e);if(o){var i=o.isDark;o.moduleCount+=2*n,o.isDark=function(t,r){return i(t-n,r-n)}}return o}},function(t,r,e){var n,o,i,a=function(){function i(t,r){function a(t,r){l=function(t){for(var r=new Array(t),e=0;e<t;e+=1){r[e]=new Array(t);for(var n=0;n<t;n+=1)r[e][n]=null}return r}(s=4*u+17),e(0,0),e(s-7,0),e(0,s-7),i(),o(),v(t,r),7<=u&&g(t),null==n&&(n=p(u,f,c)),d(n,r)}var u=t,f=y[r],l=null,s=0,n=null,c=[],h={},e=function(t,r){for(var e=-1;e<=7;e+=1)if(!(t+e<=-1||s<=t+e))for(var n=-1;n<=7;n+=1)r+n<=-1||s<=r+n||(l[t+e][r+n]=0<=e&&e<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==e||6==e)||2<=e&&e<=4&&2<=n&&n<=4)},o=function(){for(var t=8;t<s-8;t+=1)null==l[t][6]&&(l[t][6]=t%2==0);for(var r=8;r<s-8;r+=1)null==l[6][r]&&(l[6][r]=r%2==0)},i=function(){for(var t=w.getPatternPosition(u),r=0;r<t.length;r+=1)for(var e=0;e<t.length;e+=1){var n=t[r],o=t[e];if(null==l[n][o])for(var i=-2;i<=2;i+=1)for(var a=-2;a<=2;a+=1)l[n+i][o+a]=-2==i||2==i||-2==a||2==a||0==i&&0==a}},g=function(t){for(var r=w.getBCHTypeNumber(u),e=0;e<18;e+=1){var n=!t&&1==(r>>e&1);l[Math.floor(e/3)][e%3+s-8-3]=n}for(e=0;e<18;e+=1){n=!t&&1==(r>>e&1);l[e%3+s-8-3][Math.floor(e/3)]=n}},v=function(t,r){for(var e=f<<3|r,n=w.getBCHTypeInfo(e),o=0;o<15;o+=1){var i=!t&&1==(n>>o&1);o<6?l[o][8]=i:o<8?l[o+1][8]=i:l[s-15+o][8]=i}for(o=0;o<15;o+=1){i=!t&&1==(n>>o&1);o<8?l[8][s-o-1]=i:o<9?l[8][15-o-1+1]=i:l[8][15-o-1]=i}l[s-8][8]=!t},d=function(t,r){for(var e=-1,n=s-1,o=7,i=0,a=w.getMaskFunction(r),u=s-1;0<u;u-=2)for(6==u&&(u-=1);;){for(var f=0;f<2;f+=1)if(null==l[n][u-f]){var c=!1;i<t.length&&(c=1==(t[i]>>>o&1)),a(n,u-f)&&(c=!c),l[n][u-f]=c,-1==(o-=1)&&(i+=1,o=7)}if((n+=e)<0||s<=n){n-=e,e=-e;break}}},p=function(t,r,e){for(var n=B.getRSBlocks(t,r),o=C(),i=0;i<e.length;i+=1){var a=e[i];o.put(a.getMode(),4),o.put(a.getLength(),w.getLengthInBits(a.getMode(),t)),a.write(o)}var u=0;for(i=0;i<n.length;i+=1)u+=n[i].dataCount;if(o.getLengthInBits()>8*u)throw"code length overflow. ("+o.getLengthInBits()+">"+8*u+")";for(o.getLengthInBits()+4<=8*u&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(!1);for(;!(o.getLengthInBits()>=8*u||(o.put(236,8),o.getLengthInBits()>=8*u));)o.put(17,8);return function(t,r){for(var e=0,n=0,o=0,i=new Array(r.length),a=new Array(r.length),u=0;u<r.length;u+=1){var f=r[u].dataCount,c=r[u].totalCount-f;n=Math.max(n,f),o=Math.max(o,c),i[u]=new Array(f);for(var l=0;l<i[u].length;l+=1)i[u][l]=255&t.getBuffer()[l+e];e+=f;var s=w.getErrorCorrectPolynomial(c),g=m(i[u],s.getLength()-1).mod(s);for(a[u]=new Array(s.getLength()-1),l=0;l<a[u].length;l+=1){var h=l+g.getLength()-a[u].length;a[u][l]=0<=h?g.getAt(h):0}}var v=0;for(l=0;l<r.length;l+=1)v+=r[l].totalCount;var d=new Array(v),p=0;for(l=0;l<n;l+=1)for(u=0;u<r.length;u+=1)l<i[u].length&&(d[p]=i[u][l],p+=1);for(l=0;l<o;l+=1)for(u=0;u<r.length;u+=1)l<a[u].length&&(d[p]=a[u][l],p+=1);return d}(o,n)};return h.addData=function(t,r){var e=null;switch(r=r||"Byte"){case"Numeric":e=x(t);break;case"Alphanumeric":e=A(t);break;case"Byte":e=M(t);break;case"Kanji":e=S(t);break;default:throw"mode:"+r}c.push(e),n=null},h.isDark=function(t,r){if(t<0||s<=t||r<0||s<=r)throw t+","+r;return l[t][r]},h.getModuleCount=function(){return s},h.make=function(){if(u<1){for(var t=1;t<40;t++){for(var r=B.getRSBlocks(t,f),e=C(),n=0;n<c.length;n++){var o=c[n];e.put(o.getMode(),4),e.put(o.getLength(),w.getLengthInBits(o.getMode(),t)),o.write(e)}var i=0;for(n=0;n<r.length;n++)i+=r[n].dataCount;if(e.getLengthInBits()<=8*i)break}u=t}a(!1,function(){for(var t=0,r=0,e=0;e<8;e+=1){a(!0,e);var n=w.getLostPoint(h);(0==e||n<t)&&(t=n,r=e)}return r}())},h.createTableTag=function(t,r){t=t||2;var e="";e+='<table style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: "+(r=void 0===r?4*t:r)+"px;",e+='">',e+="<tbody>";for(var n=0;n<h.getModuleCount();n+=1){e+="<tr>";for(var o=0;o<h.getModuleCount();o+=1)e+='<td style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: 0px;",e+=" width: "+t+"px;",e+=" height: "+t+"px;",e+=" background-color: ",e+=h.isDark(n,o)?"#000000":"#ffffff",e+=";",e+='"/>';e+="</tr>"}return e+="</tbody>",e+="</table>"},h.createSvgTag=function(t,r){var e={};"object"==typeof t&&(t=(e=t).cellSize,r=e.margin),t=t||2,r=void 0===r?4*t:r;var n,o,i,a,u=h.getModuleCount()*t+2*r,f="";for(a="l"+t+",0 0,"+t+" -"+t+",0 0,-"+t+"z ",f+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',f+=e.scalable?"":' width="'+u+'px" height="'+u+'px"',f+=' viewBox="0 0 '+u+" "+u+'" ',f+=' preserveAspectRatio="xMinYMin meet">',f+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',f+='<path d="',o=0;o<h.getModuleCount();o+=1)for(i=o*t+r,n=0;n<h.getModuleCount();n+=1)h.isDark(o,n)&&(f+="M"+(n*t+r)+","+i+a);return f+='" stroke="transparent" fill="black"/>',f+="</svg>"},h.createDataURL=function(o,t){o=o||2,t=void 0===t?4*o:t;var r=h.getModuleCount()*o+2*t,i=t,a=r-t;return D(r,r,function(t,r){if(i<=t&&t<a&&i<=r&&r<a){var e=Math.floor((t-i)/o),n=Math.floor((r-i)/o);return h.isDark(n,e)?0:1}return 1})},h.createImgTag=function(t,r,e){t=t||2,r=void 0===r?4*t:r;var n=h.getModuleCount()*t+2*r,o="";return o+="<img",o+=' src="',o+=h.createDataURL(t,r),o+='"',o+=' width="',o+=n,o+='"',o+=' height="',o+=n,o+='"',e&&(o+=' alt="',o+=e,o+='"'),o+="/>"},h.createASCII=function(t,r){if((t=t||1)<2)return function(t){t=void 0===t?2:t;var r,e,n,o,i,a=1*h.getModuleCount()+2*t,u=t,f=a-t,c={"██":"█","█ ":"▀"," █":"▄"," ":" "},l={"██":"▀","█ ":"▀"," █":" "," ":" "},s="";for(r=0;r<a;r+=2){for(n=Math.floor((r-u)/1),o=Math.floor((r+1-u)/1),e=0;e<a;e+=1)i="█",u<=e&&e<f&&u<=r&&r<f&&h.isDark(n,Math.floor((e-u)/1))&&(i=" "),u<=e&&e<f&&u<=r+1&&r+1<f&&h.isDark(o,Math.floor((e-u)/1))?i+=" ":i+="█",s+=t<1&&f<=r+1?l[i]:c[i];s+="\n"}return a%2&&0<t?s.substring(0,s.length-a-1)+Array(1+a).join("▀"):s.substring(0,s.length-1)}(r);t-=1,r=void 0===r?2*t:r;var e,n,o,i,a=h.getModuleCount()*t+2*r,u=r,f=a-r,c=Array(t+1).join("██"),l=Array(t+1).join(" "),s="",g="";for(e=0;e<a;e+=1){for(o=Math.floor((e-u)/t),g="",n=0;n<a;n+=1)i=1,u<=n&&n<f&&u<=e&&e<f&&h.isDark(o,Math.floor((n-u)/t))&&(i=0),g+=i?c:l;for(o=0;o<t;o+=1)s+=g+"\n"}return s.substring(0,s.length-1)},h.renderTo2dContext=function(t,r){r=r||2;for(var e=h.getModuleCount(),n=0;n<e;n++)for(var o=0;o<e;o++)t.fillStyle=h.isDark(n,o)?"black":"white",t.fillRect(n*r,o*r,r,r)},h}i.stringToBytes=(i.stringToBytesFuncs={default:function(t){for(var r=[],e=0;e<t.length;e+=1){var n=t.charCodeAt(e);r.push(255&n)}return r}}).default,i.createStringToBytes=function(u,f){var i=function(){function t(){var t=r.read();if(-1==t)throw"eof";return t}for(var r=L(u),e=0,n={};;){var o=r.read();if(-1==o)break;var i=t(),a=t()<<8|t();n[String.fromCharCode(o<<8|i)]=a,e+=1}if(e!=f)throw e+" != "+f;return n}(),a="?".charCodeAt(0);return function(t){for(var r=[],e=0;e<t.length;e+=1){var n=t.charCodeAt(e);if(n<128)r.push(n);else{var o=i[t.charAt(e)];"number"==typeof o?(255&o)==o?r.push(o):(r.push(o>>>8),r.push(255&o)):r.push(a)}}return r}};var a=1,u=2,o=4,f=8,y={L:1,M:0,Q:3,H:2},n=0,c=1,l=2,s=3,g=4,h=5,v=6,d=7,w=function(){function e(t){for(var r=0;0!=t;)r+=1,t>>>=1;return r}var r=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t={};return t.getBCHTypeInfo=function(t){for(var r=t<<10;0<=e(r)-e(1335);)r^=1335<<e(r)-e(1335);return 21522^(t<<10|r)},t.getBCHTypeNumber=function(t){for(var r=t<<12;0<=e(r)-e(7973);)r^=7973<<e(r)-e(7973);return t<<12|r},t.getPatternPosition=function(t){return r[t-1]},t.getMaskFunction=function(t){switch(t){case n:return function(t,r){return(t+r)%2==0};case c:return function(t,r){return t%2==0};case l:return function(t,r){return r%3==0};case s:return function(t,r){return(t+r)%3==0};case g:return function(t,r){return(Math.floor(t/2)+Math.floor(r/3))%2==0};case h:return function(t,r){return t*r%2+t*r%3==0};case v:return function(t,r){return(t*r%2+t*r%3)%2==0};case d:return function(t,r){return(t*r%3+(t+r)%2)%2==0};default:throw"bad maskPattern:"+t}},t.getErrorCorrectPolynomial=function(t){for(var r=m([1],0),e=0;e<t;e+=1)r=r.multiply(m([1,p.gexp(e)],0));return r},t.getLengthInBits=function(t,r){if(1<=r&&r<10)switch(t){case a:return 10;case u:return 9;case o:case f:return 8;default:throw"mode:"+t}else if(r<27)switch(t){case a:return 12;case u:return 11;case o:return 16;case f:return 10;default:throw"mode:"+t}else{if(!(r<41))throw"type:"+r;switch(t){case a:return 14;case u:return 13;case o:return 16;case f:return 12;default:throw"mode:"+t}}},t.getLostPoint=function(t){for(var r=t.getModuleCount(),e=0,n=0;n<r;n+=1)for(var o=0;o<r;o+=1){for(var i=0,a=t.isDark(n,o),u=-1;u<=1;u+=1)if(!(n+u<0||r<=n+u))for(var f=-1;f<=1;f+=1)o+f<0||r<=o+f||0==u&&0==f||a==t.isDark(n+u,o+f)&&(i+=1);5<i&&(e+=3+i-5)}for(n=0;n<r-1;n+=1)for(o=0;o<r-1;o+=1){var c=0;t.isDark(n,o)&&(c+=1),t.isDark(n+1,o)&&(c+=1),t.isDark(n,o+1)&&(c+=1),t.isDark(n+1,o+1)&&(c+=1),0!=c&&4!=c||(e+=3)}for(n=0;n<r;n+=1)for(o=0;o<r-6;o+=1)t.isDark(n,o)&&!t.isDark(n,o+1)&&t.isDark(n,o+2)&&t.isDark(n,o+3)&&t.isDark(n,o+4)&&!t.isDark(n,o+5)&&t.isDark(n,o+6)&&(e+=40);for(o=0;o<r;o+=1)for(n=0;n<r-6;n+=1)t.isDark(n,o)&&!t.isDark(n+1,o)&&t.isDark(n+2,o)&&t.isDark(n+3,o)&&t.isDark(n+4,o)&&!t.isDark(n+5,o)&&t.isDark(n+6,o)&&(e+=40);var l=0;for(o=0;o<r;o+=1)for(n=0;n<r;n+=1)t.isDark(n,o)&&(l+=1);return e+=10*(Math.abs(100*l/r/r-50)/5)},t}(),p=function(){for(var r=new Array(256),e=new Array(256),t=0;t<8;t+=1)r[t]=1<<t;for(t=8;t<256;t+=1)r[t]=r[t-4]^r[t-5]^r[t-6]^r[t-8];for(t=0;t<255;t+=1)e[r[t]]=t;var n={glog:function(t){if(t<1)throw"glog("+t+")";return e[t]},gexp:function(t){for(;t<0;)t+=255;for(;256<=t;)t-=255;return r[t]}};return n}();function m(n,o){if(void 0===n.length)throw n.length+"/"+o;var r=function(){for(var t=0;t<n.length&&0==n[t];)t+=1;for(var r=new Array(n.length-t+o),e=0;e<n.length-t;e+=1)r[e]=n[e+t];return r}(),i={getAt:function(t){return r[t]},getLength:function(){return r.length},multiply:function(t){for(var r=new Array(i.getLength()+t.getLength()-1),e=0;e<i.getLength();e+=1)for(var n=0;n<t.getLength();n+=1)r[e+n]^=p.gexp(p.glog(i.getAt(e))+p.glog(t.getAt(n)));return m(r,0)},mod:function(t){if(i.getLength()-t.getLength()<0)return i;for(var r=p.glog(i.getAt(0))-p.glog(t.getAt(0)),e=new Array(i.getLength()),n=0;n<i.getLength();n+=1)e[n]=i.getAt(n);for(n=0;n<t.getLength();n+=1)e[n]^=p.gexp(p.glog(t.getAt(n))+r);return m(e,0).mod(t)}};return i}function b(){var e=[],o={writeByte:function(t){e.push(255&t)},writeShort:function(t){o.writeByte(t),o.writeByte(t>>>8)},writeBytes:function(t,r,e){r=r||0,e=e||t.length;for(var n=0;n<e;n+=1)o.writeByte(t[n+r])},writeString:function(t){for(var r=0;r<t.length;r+=1)o.writeByte(t.charCodeAt(r))},toByteArray:function(){return e},toString:function(){var t="";t+="[";for(var r=0;r<e.length;r+=1)0<r&&(t+=","),t+=e[r];return t+="]"}};return o}var k,t,B=(k=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],(t={}).getRSBlocks=function(t,r){var e=function(t,r){switch(r){case y.L:return k[4*(t-1)+0];case y.M:return k[4*(t-1)+1];case y.Q:return k[4*(t-1)+2];case y.H:return k[4*(t-1)+3];default:return}}(t,r);if(void 0===e)throw"bad rs block @ typeNumber:"+t+"/errorCorrectionLevel:"+r;for(var n,o,i=e.length/3,a=[],u=0;u<i;u+=1)for(var f=e[3*u+0],c=e[3*u+1],l=e[3*u+2],s=0;s<f;s+=1)a.push((n=l,o=void 0,(o={}).totalCount=c,o.dataCount=n,o));return a},t),C=function(){var e=[],n=0,o={getBuffer:function(){return e},getAt:function(t){var r=Math.floor(t/8);return 1==(e[r]>>>7-t%8&1)},put:function(t,r){for(var e=0;e<r;e+=1)o.putBit(1==(t>>>r-e-1&1))},getLengthInBits:function(){return n},putBit:function(t){var r=Math.floor(n/8);e.length<=r&&e.push(0),t&&(e[r]|=128>>>n%8),n+=1}};return o},x=function(t){var r=a,n=t,e={getMode:function(){return r},getLength:function(t){return n.length},write:function(t){for(var r=n,e=0;e+2<r.length;)t.put(o(r.substring(e,e+3)),10),e+=3;e<r.length&&(r.length-e==1?t.put(o(r.substring(e,e+1)),4):r.length-e==2&&t.put(o(r.substring(e,e+2)),7))}},o=function(t){for(var r=0,e=0;e<t.length;e+=1)r=10*r+i(t.charAt(e));return r},i=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+t};return e},A=function(t){var r=u,n=t,e={getMode:function(){return r},getLength:function(t){return n.length},write:function(t){for(var r=n,e=0;e+1<r.length;)t.put(45*o(r.charAt(e))+o(r.charAt(e+1)),11),e+=2;e<r.length&&t.put(o(r.charAt(e)),6)}},o=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-"0".charCodeAt(0);if("A"<=t&&t<="Z")return t.charCodeAt(0)-"A".charCodeAt(0)+10;switch(t){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+t}};return e},M=function(t){var r=o,e=i.stringToBytes(t),n={getMode:function(){return r},getLength:function(t){return e.length},write:function(t){for(var r=0;r<e.length;r+=1)t.put(e[r],8)}};return n},S=function(t){var r=f,n=i.stringToBytesFuncs.SJIS;if(!n)throw"sjis not supported.";!function(t,r){var e=n("友");if(2!=e.length||38726!=(e[0]<<8|e[1]))throw"sjis not supported."}();var o=n(t),e={getMode:function(){return r},getLength:function(t){return~~(o.length/2)},write:function(t){for(var r=o,e=0;e+1<r.length;){var n=(255&r[e])<<8|255&r[e+1];if(33088<=n&&n<=40956)n-=33088;else{if(!(57408<=n&&n<=60351))throw"illegal char at "+(e+1)+"/"+n;n-=49472}n=192*(n>>>8&255)+(255&n),t.put(n,13),e+=2}if(e<r.length)throw"illegal char at "+(e+1)}};return e},L=function(t){var e=t,n=0,o=0,i=0,r={read:function(){for(;i<8;){if(n>=e.length){if(0==i)return-1;throw"unexpected end of file./"+i}var t=e.charAt(n);if(n+=1,"="==t)return i=0,-1;t.match(/^\s$/)||(o=o<<6|a(t.charCodeAt(0)),i+=6)}var r=o>>>i-8&255;return i-=8,r}},a=function(t){if(65<=t&&t<=90)return t-65;if(97<=t&&t<=122)return t-97+26;if(48<=t&&t<=57)return t-48+52;if(43==t)return 62;if(47==t)return 63;throw"c:"+t};return r},D=function(t,r,e){for(var n=function(t,r){var n=t,o=r,s=new Array(t*r),e={setPixel:function(t,r,e){s[r*n+t]=e},write:function(t){t.writeString("GIF87a"),t.writeShort(n),t.writeShort(o),t.writeByte(128),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(255),t.writeByte(255),t.writeByte(255),t.writeString(","),t.writeShort(0),t.writeShort(0),t.writeShort(n),t.writeShort(o),t.writeByte(0);var r=i(2);t.writeByte(2);for(var e=0;255<r.length-e;)t.writeByte(255),t.writeBytes(r,e,255),e+=255;t.writeByte(r.length-e),t.writeBytes(r,e,r.length-e),t.writeByte(0),t.writeString(";")}},i=function(t){for(var r=1<<t,e=1+(1<<t),n=t+1,o=g(),i=0;i<r;i+=1)o.add(String.fromCharCode(i));o.add(String.fromCharCode(r)),o.add(String.fromCharCode(e));var a=b(),u=function(t){var e=t,n=0,o=0,r={write:function(t,r){if(t>>>r!=0)throw"length over";for(;8<=n+r;)e.writeByte(255&(t<<n|o)),r-=8-n,t>>>=8-n,n=o=0;o|=t<<n,n+=r},flush:function(){0<n&&e.writeByte(o)}};return r}(a);u.write(r,n);var f=0,c=String.fromCharCode(s[f]);for(f+=1;f<s.length;){var l=String.fromCharCode(s[f]);f+=1,o.contains(c+l)?c+=l:(u.write(o.indexOf(c),n),o.size()<4095&&(o.size()==1<<n&&(n+=1),o.add(c+l)),c=l)}return u.write(o.indexOf(c),n),u.write(e,n),u.flush(),a.toByteArray()},g=function(){var r={},e=0,n={add:function(t){if(n.contains(t))throw"dup key:"+t;r[t]=e,e+=1},size:function(){return e},indexOf:function(t){return r[t]},contains:function(t){return void 0!==r[t]}};return n};return e}(t,r),o=0;o<r;o+=1)for(var i=0;i<t;i+=1)n.setPixel(i,o,e(i,o));var a=b();n.write(a);for(var u=function(){function e(t){a+=String.fromCharCode(r(63&t))}var n=0,o=0,i=0,a="",t={},r=function(t){if(t<0);else{if(t<26)return 65+t;if(t<52)return t-26+97;if(t<62)return t-52+48;if(62==t)return 43;if(63==t)return 47}throw"n:"+t};return t.writeByte=function(t){for(n=n<<8|255&t,o+=8,i+=1;6<=o;)e(n>>>o-6),o-=6},t.flush=function(){if(0<o&&(e(n<<6-o),o=n=0),i%3!=0)for(var t=3-i%3,r=0;r<t;r+=1)a+="="},t.toString=function(){return a},t}(),f=a.toByteArray(),c=0;c<f.length;c+=1)u.writeByte(f[c]);return u.flush(),"data:image/gif;base64,"+u};return i}();a.stringToBytesFuncs["UTF-8"]=function(t){return function(t){for(var r=[],e=0;e<t.length;e++){var n=t.charCodeAt(e);n<128?r.push(n):n<2048?r.push(192|n>>6,128|63&n):n<55296||57344<=n?r.push(224|n>>12,128|n>>6&63,128|63&n):(e++,n=65536+((1023&n)<<10|1023&t.charCodeAt(e)),r.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return r}(t)},o=[],void 0===(i="function"==typeof(n=function(){return a})?n.apply(r,o):n)||(t.exports=i)},function(t,r,e){function c(t,r,e,n,o,i){t.isDark(o,i)&&r.rect(i*n,o*n,n,n)}var l=e(7),n=e(8);t.exports=function(t,r,e){!function(t,r){t.fillStyle=r.back,t.fillRect(0,0,r.size,r.size)}(r,e),function(t,r,e){if(t){var n=0<e.rounded&&e.rounded<=100?l:c,o=t.moduleCount,i=e.size/o,a=0;e.crisp&&(i=Math.floor(i),a=Math.floor((e.size-i*o)/2)),r.translate(a,a),r.beginPath();for(var u=0;u<o;u+=1)for(var f=0;f<o;f+=1)n(t,r,e,i,u,f);r.fillStyle=e.fill,r.fill(),r.translate(-a,-a)}}(t,r,e),n(r,e)}},function(t,r){t.exports=function(t,r,e,n,o,i){var a=i*n,u=o*n,f=a+n,c=u+n,l=.005*e.rounded*n,s=t.isDark,g=o-1,h=o+1,v=i-1,d=i+1,p=s(o,i),y=s(g,v),w=s(g,i),m=s(g,d),b=s(o,d),k=s(h,d),B=s(h,i),C=s(h,v),x=s(o,v);r=function(t){return{c:t,m:function(){var t;return(t=this.c).moveTo.apply(t,arguments),this},l:function(){var t;return(t=this.c).lineTo.apply(t,arguments),this},a:function(){var t;return(t=this.c).arcTo.apply(t,arguments),this}}}(r),p?function(t,r,e,n,o,i,a,u,f,c){a?t.m(r+i,e):t.m(r,e),u?t.l(n-i,e).a(n,e,n,o,i):t.l(n,e),f?t.l(n,o-i).a(n,o,r,o,i):t.l(n,o),c?t.l(r+i,o).a(r,o,r,e,i):t.l(r,o),a?t.l(r,e+i).a(r,e,n,e,i):t.l(r,e)}(r,a,u,f,c,l,!w&&!x,!w&&!b,!B&&!b,!B&&!x):function(t,r,e,n,o,i,a,u,f,c){a&&t.m(r+i,e).l(r,e).l(r,e+i).a(r,e,r+i,e,i),u&&t.m(n-i,e).l(n,e).l(n,e+i).a(n,e,n-i,e,i),f&&t.m(n-i,o).l(n,o).l(n,o-i).a(n,o,n-i,o,i),c&&t.m(r+i,o).l(r,o).l(r,o-i).a(r,o,r+i,o,i)}(r,a,u,f,c,l,w&&x&&y,w&&b&&m,B&&b&&k,B&&x&&C)}},function(t,r){t.exports=function(t,r){var e=r.mode;"label"===e?function(t,r){var e=r.size,n="bold "+.01*r.mSize*e+"px "+r.fontname;t.strokeStyle=r.back,t.lineWidth=.01*r.mSize*e*.1,t.fillStyle=r.fontcolor,t.font=n;var o=t.measureText(r.label).width,i=.01*r.mSize,a=(1-o/e)*r.mPosX*.01*e,u=(1-i)*r.mPosY*.01*e+.75*r.mSize*.01*e;t.strokeText(r.label,a,u),t.fillText(r.label,a,u)}(t,r):"image"===e&&function(t,r){var e=r.size,n=r.image.naturalWidth||1,o=r.image.naturalHeight||1,i=.01*r.mSize,a=i*n/o,u=(1-a)*r.mPosX*.01*e,f=(1-i)*r.mPosY*.01*e,c=a*e,l=i*e;t.drawImage(r.image,u,f,c,l)}(t,r)}}])}); \ No newline at end of file diff --git a/js/kjua-0.9.0.js b/js/kjua-0.9.0.js new file mode 100644 index 00000000..bd1f4845 --- /dev/null +++ b/js/kjua-0.9.0.js @@ -0,0 +1,2 @@ +/*! kjua v0.9.0 - https://larsjung.de/kjua/ */ +!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("kjua",[],r):"object"==typeof exports?exports.kjua=r():t.kjua=r()}("undefined"!=typeof self?self:this,function(){return n={},o.m=e=[function(t,r,e){function n(t){var r=Object.assign({},o,t),e=i(r.text,r.ecLevel,r.minVersion,r.quiet);return"svg"===r.render?u(e,r):a(e,r,"image"===r.render)}var o=e(1),i=e(2),a=e(4),u=e(8);t.exports=n;try{jQuery.fn.kjua=function(e){return this.each(function(t,r){return r.appendChild(n(e))})}}catch(t){}},function(t,r){t.exports={render:"image",crisp:!0,minVersion:1,ecLevel:"L",size:200,ratio:null,fill:"#333",back:"#fff",text:"no text",rounded:0,quiet:0,mode:"plain",mSize:30,mPosX:50,mPosY:50,label:"no label",fontname:"sans",fontcolor:"#333",image:null}},function(t,r,e){function u(t){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var f=/code length overflow/i,c=e(3);c.stringToBytes=c.stringToBytesFuncs["UTF-8"];t.exports=function(t,r,e,n){var o,i=3<arguments.length&&void 0!==n?n:0,a=function(t,r,e){for(var n=2<arguments.length&&void 0!==e?e:1,o=n=Math.max(1,n);o<=40;o+=1)try{var i=function(){var e=c(o,r);e.addData(t),e.make();var n=e.getModuleCount();return{v:{text:t,level:r,version:o,module_count:n,is_dark:function(t,r){return 0<=t&&t<n&&0<=r&&r<n&&e.isDark(t,r)}}}}();if("object"===u(i))return i.v}catch(t){if(!(o<40&&f.test(t)))throw new Error(t)}return null}(0<arguments.length&&void 0!==t?t:"",1<arguments.length&&void 0!==r?r:"L",2<arguments.length&&void 0!==e?e:1);return a&&(o=a.is_dark,a.module_count+=2*i,a.is_dark=function(t,r){return o(t-i,r-i)}),a}},function(t,r,e){var n,o,i,a=function(){function i(t,r){function a(t,r){l=function(t){for(var r=new Array(t),e=0;e<t;e+=1){r[e]=new Array(t);for(var n=0;n<t;n+=1)r[e][n]=null}return r}(s=4*u+17),e(0,0),e(s-7,0),e(0,s-7),i(),o(),d(t,r),7<=u&&g(t),null==n&&(n=p(u,f,c)),v(n,r)}var u=t,f=w[r],l=null,s=0,n=null,c=[],h={},e=function(t,r){for(var e=-1;e<=7;e+=1)if(!(t+e<=-1||s<=t+e))for(var n=-1;n<=7;n+=1)r+n<=-1||s<=r+n||(l[t+e][r+n]=0<=e&&e<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==e||6==e)||2<=e&&e<=4&&2<=n&&n<=4)},o=function(){for(var t=8;t<s-8;t+=1)null==l[t][6]&&(l[t][6]=t%2==0);for(var r=8;r<s-8;r+=1)null==l[6][r]&&(l[6][r]=r%2==0)},i=function(){for(var t=m.getPatternPosition(u),r=0;r<t.length;r+=1)for(var e=0;e<t.length;e+=1){var n=t[r],o=t[e];if(null==l[n][o])for(var i=-2;i<=2;i+=1)for(var a=-2;a<=2;a+=1)l[n+i][o+a]=-2==i||2==i||-2==a||2==a||0==i&&0==a}},g=function(t){for(var r=m.getBCHTypeNumber(u),e=0;e<18;e+=1){var n=!t&&1==(r>>e&1);l[Math.floor(e/3)][e%3+s-8-3]=n}for(e=0;e<18;e+=1){n=!t&&1==(r>>e&1);l[e%3+s-8-3][Math.floor(e/3)]=n}},d=function(t,r){for(var e=f<<3|r,n=m.getBCHTypeInfo(e),o=0;o<15;o+=1){var i=!t&&1==(n>>o&1);o<6?l[o][8]=i:o<8?l[o+1][8]=i:l[s-15+o][8]=i}for(o=0;o<15;o+=1){i=!t&&1==(n>>o&1);o<8?l[8][s-o-1]=i:o<9?l[8][15-o-1+1]=i:l[8][15-o-1]=i}l[s-8][8]=!t},v=function(t,r){for(var e=-1,n=s-1,o=7,i=0,a=m.getMaskFunction(r),u=s-1;0<u;u-=2)for(6==u&&--u;;){for(var f,c=0;c<2;c+=1){null==l[n][u-c]&&(f=!1,i<t.length&&(f=1==(t[i]>>>o&1)),a(n,u-c)&&(f=!f),l[n][u-c]=f,-1==--o&&(i+=1,o=7))}if((n+=e)<0||s<=n){n-=e,e=-e;break}}},p=function(t,r,e){for(var n=S.getRSBlocks(t,r),o=M(),i=0;i<e.length;i+=1){var a=e[i];o.put(a.getMode(),4),o.put(a.getLength(),m.getLengthInBits(a.getMode(),t)),a.write(o)}for(var u=0,i=0;i<n.length;i+=1)u+=n[i].dataCount;if(o.getLengthInBits()>8*u)throw"code length overflow. ("+o.getLengthInBits()+">"+8*u+")";for(o.getLengthInBits()+4<=8*u&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(!1);for(;!(o.getLengthInBits()>=8*u||(o.put(236,8),o.getLengthInBits()>=8*u));)o.put(17,8);return function(t,r){for(var e=0,n=0,o=0,i=new Array(r.length),a=new Array(r.length),u=0;u<r.length;u+=1){var f=r[u].dataCount,c=r[u].totalCount-f,n=Math.max(n,f),o=Math.max(o,c);i[u]=new Array(f);for(var l=0;l<i[u].length;l+=1)i[u][l]=255&t.getBuffer()[l+e];e+=f;var s=m.getErrorCorrectPolynomial(c),g=b(i[u],s.getLength()-1).mod(s);a[u]=new Array(s.getLength()-1);for(l=0;l<a[u].length;l+=1){var h=l+g.getLength()-a[u].length;a[u][l]=0<=h?g.getAt(h):0}}for(var d=0,l=0;l<r.length;l+=1)d+=r[l].totalCount;for(var v=new Array(d),p=0,l=0;l<n;l+=1)for(u=0;u<r.length;u+=1)l<i[u].length&&(v[p]=i[u][l],p+=1);for(l=0;l<o;l+=1)for(u=0;u<r.length;u+=1)l<a[u].length&&(v[p]=a[u][l],p+=1);return v}(o,n)};h.addData=function(t,r){var e=null;switch(r=r||"Byte"){case"Numeric":e=A(t);break;case"Alphanumeric":e=L(t);break;case"Byte":e=D(t);break;case"Kanji":e=_(t);break;default:throw"mode:"+r}c.push(e),n=null},h.isDark=function(t,r){if(t<0||s<=t||r<0||s<=r)throw t+","+r;return l[t][r]},h.getModuleCount=function(){return s},h.make=function(){if(u<1){for(var t=1;t<40;t++){for(var r=S.getRSBlocks(t,f),e=M(),n=0;n<c.length;n++){var o=c[n];e.put(o.getMode(),4),e.put(o.getLength(),m.getLengthInBits(o.getMode(),t)),o.write(e)}for(var i=0,n=0;n<r.length;n++)i+=r[n].dataCount;if(e.getLengthInBits()<=8*i)break}u=t}a(!1,function(){for(var t=0,r=0,e=0;e<8;e+=1){a(!0,e);var n=m.getLostPoint(h);(0==e||n<t)&&(t=n,r=e)}return r}())},h.createTableTag=function(t,r){t=t||2;var e="";e+='<table style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: "+(r=void 0===r?4*t:r)+"px;",e+='">',e+="<tbody>";for(var n=0;n<h.getModuleCount();n+=1){e+="<tr>";for(var o=0;o<h.getModuleCount();o+=1)e+='<td style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: 0px;",e+=" width: "+t+"px;",e+=" height: "+t+"px;",e+=" background-color: ",e+=h.isDark(n,o)?"#000000":"#ffffff",e+=";",e+='"/>';e+="</tr>"}return e+="</tbody>",e+="</table>"},h.createSvgTag=function(t,r,e,n){var o={};"object"==typeof arguments[0]&&(t=(o=arguments[0]).cellSize,r=o.margin,e=o.alt,n=o.title),t=t||2,r=void 0===r?4*t:r,(e="string"==typeof e?{text:e}:e||{}).text=e.text||null,e.id=e.text?e.id||"qrcode-description":null,(n="string"==typeof n?{text:n}:n||{}).text=n.text||null,n.id=n.text?n.id||"qrcode-title":null;var i,a,u,f=h.getModuleCount()*t+2*r,c="",l="l"+t+",0 0,"+t+" -"+t+",0 0,-"+t+"z ";for(c+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',c+=o.scalable?"":' width="'+f+'px" height="'+f+'px"',c+=' viewBox="0 0 '+f+" "+f+'" ',c+=' preserveAspectRatio="xMinYMin meet"',c+=n.text||e.text?' role="img" aria-labelledby="'+y([n.id,e.id].join(" ").trim())+'"':"",c+=">",c+=n.text?'<title id="'+y(n.id)+'">'+y(n.text)+"":"",c+=e.text?''+y(e.text)+"":"",c+='',c+='":r+=">";break;case"&":r+="&";break;case'"':r+=""";break;default:r+=n}}return r};return h.createASCII=function(t,r){if((t=t||1)<2)return function(t){t=void 0===t?2:t;for(var r,e,n,o,i=+h.getModuleCount()+2*t,a=t,u=i-t,f={"██":"█","█ ":"▀"," █":"▄"," ":" "},c={"██":"▀","█ ":"▀"," █":" "," ":" "},l="",s=0;s>>8),r.push(255&n)):r.push(a)}return r}};var r,t,a=1,u=2,o=4,f=8,w={L:1,M:0,Q:3,H:2},e=0,n=1,c=2,l=3,s=4,g=5,h=6,d=7,m=(r=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],(t={}).getBCHTypeInfo=function(t){for(var r=t<<10;0<=v(r)-v(1335);)r^=1335<>>=1;return r}var p=function(){for(var r=new Array(256),e=new Array(256),t=0;t<8;t+=1)r[t]=1<>>8)},writeBytes:function(t,r,e){r=r||0,e=e||t.length;for(var n=0;n>>o-6),o-=6},t.flush=function(){if(0>>r!=0)throw"length over";for(;8<=u+r;)a.writeByte(255&(t<>>=8-u,u=f=0;f|=t<>>7-t%8&1)},put:function(t,r){for(var e=0;e>>r-e-1&1))},getLengthInBits:function(){return n},putBit:function(t){var r=Math.floor(n/8);e.length<=r&&e.push(0),t&&(e[r]|=128>>>n%8),n+=1}};return o},A=function(t){var r=a,n=t,e={getMode:function(){return r},getLength:function(t){return n.length},write:function(t){for(var r=n,e=0;e+2>>8&255)+(255&n),t.put(n,13),e+=2}if(e=e.length){if(0==i)return-1;throw"unexpected end of file./"+i}var t=e.charAt(n);if(n+=1,"="==t)return i=0,-1;t.match(/^\s$/)||(o=o<<6|a(t.charCodeAt(0)),i+=6)}var r=o>>>i-8&255;return i-=8,r}},a=function(t){if(65<=t&&t<=90)return t-65;if(97<=t&&t<=122)return t-97+26;if(48<=t&&t<=57)return t-48+52;if(43==t)return 62;if(47==t)return 63;throw"c:"+t};return r},P=function(t,r,e){for(var n=k(t,r),o=0;o>6,128|63&n):n<55296||57344<=n?r.push(224|n>>12,128|n>>6&63,128|63&n):(e++,n=65536+((1023&n)<<10|1023&t.charCodeAt(e)),r.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return r}(t)},o=[],void 0===(i="function"==typeof(n=function(){return a})?n.apply(r,o):n)||(t.exports=i)},function(t,r,e){function c(t,r,e,n,o,i){t.is_dark(o,i)&&r.rect(i*n,o*n,n,n)}function a(t,r,e){var n,o;n=r,(o=e).back&&(n.fillStyle=o.back,n.fillRect(0,0,o.size,o.size)),function(t,r,e){if(t){var n=0 - + - + Date: Tue, 6 Apr 2021 06:27:12 +0200 Subject: [PATCH 064/223] fix display of indonesian label in drop-down --- i18n/languages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/languages.json b/i18n/languages.json index 6a83544b..a2aff4a9 100644 --- a/i18n/languages.json +++ b/i18n/languages.json @@ -63,10 +63,10 @@ "ho": ["Hiri Motu", "Hiri Motu"], "hu": ["magyar", "Hungarian"], "ia": ["Interlingua", "Interlingua"], + "id": ["bahasa Indonesia","Indonesian"], "ie": ["Interlingue", "Interlingue"], "ga": ["Gaeilge", "Irish"], "ig": ["Asụsụ Igbo", "Igbo"], - "in": ["bahasa Indonesia","Indonesian"], "ik": ["Iñupiaq", "Inupiaq"], "io": ["Ido", "Ido"], "is": ["Íslenska", "Icelandic"], From 553417194cda90149e1d35da5b0830412ba51607 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Tue, 6 Apr 2021 20:07:13 +0200 Subject: [PATCH 065/223] New translations en.json (Estonian) --- i18n/et.json | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 i18n/et.json diff --git a/i18n/et.json b/i18n/et.json new file mode 100644 index 00000000..295f5129 --- /dev/null +++ b/i18n/et.json @@ -0,0 +1,188 @@ +{ + "PrivateBin": "PrivateBin", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.", + "More information on the project page.": "More information on the project page.", + "Because ignorance is bliss": "Because ignorance is bliss", + "en": "en", + "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", + "%s requires php %s or above to work. Sorry.": "%s requires php %s or above to work. Sorry.", + "%s requires configuration section [%s] to be present in configuration file.": "%s requires configuration section [%s] to be present in configuration file.", + "Please wait %d seconds between each post.": [ + "Please wait %d second between each post. (singular)", + "Please wait %d seconds between each post. (1st plural)", + "Please wait %d seconds between each post. (2nd plural)", + "Please wait %d seconds between each post. (3rd plural)" + ], + "Paste is limited to %s of encrypted data.": "Paste is limited to %s of encrypted data.", + "Invalid data.": "Invalid data.", + "You are unlucky. Try again.": "You are unlucky. Try again.", + "Error saving comment. Sorry.": "Error saving comment. Sorry.", + "Error saving paste. Sorry.": "Error saving paste. Sorry.", + "Invalid paste ID.": "Invalid paste ID.", + "Paste is not of burn-after-reading type.": "Paste is not of burn-after-reading type.", + "Wrong deletion token. Paste was not deleted.": "Wrong deletion token. Paste was not deleted.", + "Paste was properly deleted.": "Paste was properly deleted.", + "JavaScript is required for %s to work. Sorry for the inconvenience.": "JavaScript is required for %s to work. Sorry for the inconvenience.", + "%s requires a modern browser to work.": "%s requires a modern browser to work.", + "New": "New", + "Send": "Send", + "Clone": "Clone", + "Raw text": "Raw text", + "Expires": "Expires", + "Burn after reading": "Burn after reading", + "Open discussion": "Open discussion", + "Password (recommended)": "Password (recommended)", + "Discussion": "Discussion", + "Toggle navigation": "Toggle navigation", + "%d seconds": [ + "%d second (singular)", + "%d seconds (1st plural)", + "%d seconds (2nd plural)", + "%d seconds (3rd plural)" + ], + "%d minutes": [ + "%d minute (singular)", + "%d minutes (1st plural)", + "%d minutes (2nd plural)", + "%d minutes (3rd plural)" + ], + "%d hours": [ + "%d hour (singular)", + "%d hours (1st plural)", + "%d hours (2nd plural)", + "%d hours (3rd plural)" + ], + "%d days": [ + "%d day (singular)", + "%d days (1st plural)", + "%d days (2nd plural)", + "%d days (3rd plural)" + ], + "%d weeks": [ + "%d week (singular)", + "%d weeks (1st plural)", + "%d weeks (2nd plural)", + "%d weeks (3rd plural)" + ], + "%d months": [ + "%d month (singular)", + "%d months (1st plural)", + "%d months (2nd plural)", + "%d months (3rd plural)" + ], + "%d years": [ + "%d year (singular)", + "%d years (1st plural)", + "%d years (2nd plural)", + "%d years (3rd plural)" + ], + "Never": "Never", + "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.", + "This document will expire in %d seconds.": [ + "This document will expire in %d second. (singular)", + "This document will expire in %d seconds. (1st plural)", + "This document will expire in %d seconds. (2nd plural)", + "This document will expire in %d seconds. (3rd plural)" + ], + "This document will expire in %d minutes.": [ + "This document will expire in %d minute. (singular)", + "This document will expire in %d minutes. (1st plural)", + "This document will expire in %d minutes. (2nd plural)", + "This document will expire in %d minutes. (3rd plural)" + ], + "This document will expire in %d hours.": [ + "This document will expire in %d hour. (singular)", + "This document will expire in %d hours. (1st plural)", + "This document will expire in %d hours. (2nd plural)", + "This document will expire in %d hours. (3rd plural)" + ], + "This document will expire in %d days.": [ + "This document will expire in %d day. (singular)", + "This document will expire in %d days. (1st plural)", + "This document will expire in %d days. (2nd plural)", + "This document will expire in %d days. (3rd plural)" + ], + "This document will expire in %d months.": [ + "This document will expire in %d month. (singular)", + "This document will expire in %d months. (1st plural)", + "This document will expire in %d months. (2nd plural)", + "This document will expire in %d months. (3rd plural)" + ], + "Please enter the password for this paste:": "Please enter the password for this paste:", + "Could not decrypt data (Wrong key?)": "Could not decrypt data (Wrong key?)", + "Could not delete the paste, it was not stored in burn after reading mode.": "Could not delete the paste, it was not stored in burn after reading mode.", + "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.", + "Could not decrypt comment; Wrong key?": "Could not decrypt comment; Wrong key?", + "Reply": "Reply", + "Anonymous": "Anonymous", + "Avatar generated from IP address": "Avatar generated from IP address", + "Add comment": "Add comment", + "Optional nickname…": "Optional nickname…", + "Post comment": "Post comment", + "Sending comment…": "Sending comment…", + "Comment posted.": "Comment posted.", + "Could not refresh display: %s": "Could not refresh display: %s", + "unknown status": "unknown status", + "server error or not responding": "server error or not responding", + "Could not post comment: %s": "Could not post comment: %s", + "Sending paste…": "Sending paste…", + "Your paste is %s (Hit [Ctrl]+[c] to copy)": "Your paste is %s (Hit [Ctrl]+[c] to copy)", + "Delete data": "Delete data", + "Could not create paste: %s": "Could not create paste: %s", + "Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)": "Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)", + "B": "B", + "KiB": "KiB", + "MiB": "MiB", + "GiB": "GiB", + "TiB": "TiB", + "PiB": "PiB", + "EiB": "EiB", + "ZiB": "ZiB", + "YiB": "YiB", + "Format": "Format", + "Plain Text": "Plain Text", + "Source Code": "Source Code", + "Markdown": "Markdown", + "Download attachment": "Download attachment", + "Cloned: '%s'": "Cloned: '%s'", + "The cloned file '%s' was attached to this paste.": "The cloned file '%s' was attached to this paste.", + "Attach a file": "Attach a file", + "alternatively drag & drop a file or paste an image from the clipboard": "alternatively drag & drop a file or paste an image from the clipboard", + "File too large, to display a preview. Please download the attachment.": "File too large, to display a preview. Please download the attachment.", + "Remove attachment": "Remove attachment", + "Your browser does not support uploading encrypted files. Please use a newer browser.": "Your browser does not support uploading encrypted files. Please use a newer browser.", + "Invalid attachment.": "Invalid attachment.", + "Options": "Options", + "Shorten URL": "Shorten URL", + "Editor": "Editor", + "Preview": "Preview", + "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.": "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.", + "Decrypt": "Decrypt", + "Enter password": "Enter password", + "Loading…": "Loading…", + "Decrypting paste…": "Decrypting paste…", + "Preparing new paste…": "Preparing new paste…", + "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "In case this message never disappears please have a look at this FAQ for information to troubleshoot.", + "+++ no paste text +++": "+++ no paste text +++", + "Could not get paste data: %s": "Could not get paste data: %s", + "QR code": "QR code", + "This website is using an insecure HTTP connection! Please use it only for testing.": "This website is using an insecure HTTP connection! Please use it only for testing.", + "For more information see this FAQ entry.": "For more information see this FAQ entry.", + "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.": "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.", + "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.": "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.", + "waiting on user to provide a password": "waiting on user to provide a password", + "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.": "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.", + "Retry": "Retry", + "Showing raw text…": "Showing raw text…", + "Notice:": "Notice:", + "This link will expire after %s.": "This link will expire after %s.", + "This link can only be accessed once, do not use back or refresh button in your browser.": "This link can only be accessed once, do not use back or refresh button in your browser.", + "Link:": "Link:", + "Recipient may become aware of your timezone, convert time to UTC?": "Recipient may become aware of your timezone, convert time to UTC?", + "Use Current Timezone": "Use Current Timezone", + "Convert To UTC": "Convert To UTC", + "Close": "Close", + "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." +} From 587822838a94bd4f7a038af4305deb919245ae86 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Wed, 7 Apr 2021 09:18:03 +0200 Subject: [PATCH 066/223] New translations en.json (Chinese Simplified) --- i18n/zh.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i18n/zh.json b/i18n/zh.json index 67a456f9..2e1dc12b 100644 --- a/i18n/zh.json +++ b/i18n/zh.json @@ -111,7 +111,7 @@ "Please enter the password for this paste:": "请输入这份粘贴内容的密码:", "Could not decrypt data (Wrong key?)": "无法解密数据(密钥错误?)", "Could not delete the paste, it was not stored in burn after reading mode.": "无法删除此粘贴内容,它没有以阅后即焚模式保存。", - "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "注意啦!!!不要关闭窗口,否则你再也见不到这条消息了。", + "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "看!仔!细!了!不要关闭窗口,否则你再也见不到这条消息了。", "Could not decrypt comment; Wrong key?": "无法解密评论; 密钥错误?", "Reply": "回复", "Anonymous": "匿名", @@ -162,7 +162,7 @@ "Loading…": "载入中…", "Decrypting paste…": "正在解密", "Preparing new paste…": "正在准备新的粘贴内容", - "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "如果这个消息一直存在,请参考 这里的 参考文档(英文版)进行故障排除。", + "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "如果这个消息一直存在,请参考 这里的 FAQ (英文版)进行故障排除。", "+++ no paste text +++": "+++ 没有粘贴内容 +++", "Could not get paste data: %s": "无法获取粘贴数据:%s", "QR code": "二维码", @@ -184,5 +184,5 @@ "Close": "关闭", "Encrypted note on PrivateBin": "PrivateBin上的加密笔记", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "访问这个链接来查看该笔记。 将这个URL发送给任何人即可允许其访问该笔记。", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL 缩短可能会暴露您在 URL 中的解密密钥。" } From f5fa37b5f28ac554a50c60d8afcfb337c827315f Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Thu, 8 Apr 2021 20:55:45 +0200 Subject: [PATCH 067/223] New translations en.json (Estonian) --- i18n/et.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/i18n/et.json b/i18n/et.json index 295f5129..490d97ee 100644 --- a/i18n/et.json +++ b/i18n/et.json @@ -1,9 +1,9 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.", - "More information on the project page.": "More information on the project page.", - "Because ignorance is bliss": "Because ignorance is bliss", - "en": "en", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s on minimalistlik, avatud lähtekoodiga online pastebin, kus serveril pole kleebitud andmete kohta teadmist. Andmed krüpteeritakse/dekrüpteeritakse %sbrauseris%s kasutades 256-bitist AES-i.", + "More information on the project page.": "Lisateave projekti lehel.", + "Because ignorance is bliss": "Kuna teadmatus on õndsus", + "en": "et", "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", "%s requires php %s or above to work. Sorry.": "%s requires php %s or above to work. Sorry.", "%s requires configuration section [%s] to be present in configuration file.": "%s requires configuration section [%s] to be present in configuration file.", From e50f3eb31102c4df9f29120f63d2a87f861bd610 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Thu, 8 Apr 2021 22:00:09 +0200 Subject: [PATCH 068/223] New translations en.json (Estonian) --- i18n/et.json | 228 +++++++++++++++++++++++++-------------------------- 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/i18n/et.json b/i18n/et.json index 490d97ee..d5b9aa46 100644 --- a/i18n/et.json +++ b/i18n/et.json @@ -4,132 +4,132 @@ "More information on the project page.": "Lisateave projekti lehel.", "Because ignorance is bliss": "Kuna teadmatus on õndsus", "en": "et", - "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", - "%s requires php %s or above to work. Sorry.": "%s requires php %s or above to work. Sorry.", + "Paste does not exist, has expired or has been deleted.": "Kleebet ei eksisteeri, on aegunud või on kustutatud.", + "%s requires php %s or above to work. Sorry.": "%s vajab php %s-d või kõrgemat, et töötada. Vabandame.", "%s requires configuration section [%s] to be present in configuration file.": "%s requires configuration section [%s] to be present in configuration file.", "Please wait %d seconds between each post.": [ - "Please wait %d second between each post. (singular)", - "Please wait %d seconds between each post. (1st plural)", - "Please wait %d seconds between each post. (2nd plural)", - "Please wait %d seconds between each post. (3rd plural)" + "Palun oota %d sekund iga postituse vahel.", + "Palun oota %d sekundit iga postituse vahel.", + "Palun oota %d sekundit iga postituse vahel.", + "Palun oota %d sekundit iga postituse vahel." ], - "Paste is limited to %s of encrypted data.": "Paste is limited to %s of encrypted data.", - "Invalid data.": "Invalid data.", - "You are unlucky. Try again.": "You are unlucky. Try again.", - "Error saving comment. Sorry.": "Error saving comment. Sorry.", - "Error saving paste. Sorry.": "Error saving paste. Sorry.", - "Invalid paste ID.": "Invalid paste ID.", + "Paste is limited to %s of encrypted data.": "Kleepe limiit on %s krüpteeritud andmeid.", + "Invalid data.": "Valed andmed.", + "You are unlucky. Try again.": "Sul ei vea. Proovi uuesti.", + "Error saving comment. Sorry.": "Viga kommentaari salvestamisel. Vabandame.", + "Error saving paste. Sorry.": "Viga kleepe salvestamisel. Vabandame.", + "Invalid paste ID.": "Vale kleepe ID.", "Paste is not of burn-after-reading type.": "Paste is not of burn-after-reading type.", - "Wrong deletion token. Paste was not deleted.": "Wrong deletion token. Paste was not deleted.", - "Paste was properly deleted.": "Paste was properly deleted.", - "JavaScript is required for %s to work. Sorry for the inconvenience.": "JavaScript is required for %s to work. Sorry for the inconvenience.", - "%s requires a modern browser to work.": "%s requires a modern browser to work.", - "New": "New", - "Send": "Send", - "Clone": "Clone", - "Raw text": "Raw text", - "Expires": "Expires", - "Burn after reading": "Burn after reading", - "Open discussion": "Open discussion", - "Password (recommended)": "Password (recommended)", - "Discussion": "Discussion", + "Wrong deletion token. Paste was not deleted.": "Vale kustutamiskood. Kleebet ei kustutatud.", + "Paste was properly deleted.": "Kleebe kustutati korralikult.", + "JavaScript is required for %s to work. Sorry for the inconvenience.": "JavaScript on vajalik %s'i töötamiseks. Vabandame ebamugavuste pärast.", + "%s requires a modern browser to work.": "%s vajab töötamiseks kaasaegset brauserit.", + "New": "Uus", + "Send": "Saada", + "Clone": "Klooni", + "Raw text": "Lähtetekst", + "Expires": "Aegub", + "Burn after reading": "Põleta pärast lugemist", + "Open discussion": "Avatud arutelu", + "Password (recommended)": "Parool (soovitatav)", + "Discussion": "Arutelu", "Toggle navigation": "Toggle navigation", "%d seconds": [ - "%d second (singular)", - "%d seconds (1st plural)", - "%d seconds (2nd plural)", - "%d seconds (3rd plural)" + "%d sekund", + "%d sekundit", + "%d sekundit", + "%d sekundit" ], "%d minutes": [ - "%d minute (singular)", - "%d minutes (1st plural)", - "%d minutes (2nd plural)", - "%d minutes (3rd plural)" + "%d minut", + "%d minutit", + "%d minutit", + "%d minutit" ], "%d hours": [ - "%d hour (singular)", - "%d hours (1st plural)", - "%d hours (2nd plural)", - "%d hours (3rd plural)" + "%d tund", + "%d tundi", + "%d tundi", + "%d tundi" ], "%d days": [ - "%d day (singular)", - "%d days (1st plural)", - "%d days (2nd plural)", - "%d days (3rd plural)" + "%d päev", + "%d päeva", + "%d päeva", + "%d päeva" ], "%d weeks": [ - "%d week (singular)", - "%d weeks (1st plural)", - "%d weeks (2nd plural)", - "%d weeks (3rd plural)" + "%d nädal", + "%d nädalat", + "%d nädalat", + "%d nädalat" ], "%d months": [ - "%d month (singular)", - "%d months (1st plural)", - "%d months (2nd plural)", - "%d months (3rd plural)" + "%d kuu", + "%d kuud", + "%d kuud", + "%d kuud" ], "%d years": [ - "%d year (singular)", - "%d years (1st plural)", - "%d years (2nd plural)", - "%d years (3rd plural)" + "%d aasta", + "%d aastat", + "%d aastat", + "%d aastat" ], - "Never": "Never", - "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.", + "Never": "Mitte kunagi", + "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "Märge: See on testimisteenus: Andmeid võidakse igal ajal kustutada. Kiisupojad hukkuvad, kui seda teenust kuritarvitad.", "This document will expire in %d seconds.": [ - "This document will expire in %d second. (singular)", - "This document will expire in %d seconds. (1st plural)", - "This document will expire in %d seconds. (2nd plural)", - "This document will expire in %d seconds. (3rd plural)" + "See dokument aegub %d sekundi pärast.", + "See dokument aegub %d sekundi pärast.", + "See dokument aegub %d sekundi pärast.", + "See dokument aegub %d sekundi pärast." ], "This document will expire in %d minutes.": [ - "This document will expire in %d minute. (singular)", - "This document will expire in %d minutes. (1st plural)", - "This document will expire in %d minutes. (2nd plural)", - "This document will expire in %d minutes. (3rd plural)" + "See dokument aegub %d minuti pärast.", + "See dokument aegub %d minuti pärast.", + "See dokument aegub %d minuti pärast.", + "See dokument aegub %d minuti pärast." ], "This document will expire in %d hours.": [ - "This document will expire in %d hour. (singular)", - "This document will expire in %d hours. (1st plural)", - "This document will expire in %d hours. (2nd plural)", - "This document will expire in %d hours. (3rd plural)" + "See dokument aegub %d tunni pärast.", + "See dokument aegub %d tunni pärast.", + "See dokument aegub %d tunni pärast.", + "See dokument aegub %d tunni pärast." ], "This document will expire in %d days.": [ - "This document will expire in %d day. (singular)", - "This document will expire in %d days. (1st plural)", - "This document will expire in %d days. (2nd plural)", - "This document will expire in %d days. (3rd plural)" + "See dokument aegub %d päeva pärast.", + "See dokument aegub %d päeva pärast.", + "See dokument aegub %d päeva pärast.", + "See dokument aegub %d päeva pärast." ], "This document will expire in %d months.": [ - "This document will expire in %d month. (singular)", - "This document will expire in %d months. (1st plural)", - "This document will expire in %d months. (2nd plural)", - "This document will expire in %d months. (3rd plural)" + "See dokument aegub %d kuu pärast.", + "See dokument aegub %d kuu pärast.", + "See dokument aegub %d kuu pärast.", + "See dokument aegub %d kuu pärast." ], - "Please enter the password for this paste:": "Please enter the password for this paste:", + "Please enter the password for this paste:": "Palun sisesta selle kleepe parool:", "Could not decrypt data (Wrong key?)": "Could not decrypt data (Wrong key?)", "Could not delete the paste, it was not stored in burn after reading mode.": "Could not delete the paste, it was not stored in burn after reading mode.", "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.", "Could not decrypt comment; Wrong key?": "Could not decrypt comment; Wrong key?", - "Reply": "Reply", - "Anonymous": "Anonymous", + "Reply": "Vasta", + "Anonymous": "Anonüümne", "Avatar generated from IP address": "Avatar generated from IP address", - "Add comment": "Add comment", - "Optional nickname…": "Optional nickname…", - "Post comment": "Post comment", - "Sending comment…": "Sending comment…", - "Comment posted.": "Comment posted.", + "Add comment": "Lisa kommentaar", + "Optional nickname…": "Valikuline hüüdnimi…", + "Post comment": "Postita kommentaar", + "Sending comment…": "Kommentaari saatmine…", + "Comment posted.": "Kommentaar postitatud.", "Could not refresh display: %s": "Could not refresh display: %s", "unknown status": "unknown status", - "server error or not responding": "server error or not responding", - "Could not post comment: %s": "Could not post comment: %s", - "Sending paste…": "Sending paste…", - "Your paste is %s (Hit [Ctrl]+[c] to copy)": "Your paste is %s (Hit [Ctrl]+[c] to copy)", - "Delete data": "Delete data", - "Could not create paste: %s": "Could not create paste: %s", - "Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)": "Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)", + "server error or not responding": "serveri viga või ei vasta", + "Could not post comment: %s": "Ei suutnud kommentaari postitada: %s", + "Sending paste…": "Kleepe saatmine…", + "Your paste is %s (Hit [Ctrl]+[c] to copy)": "Sinu kleebe on %s (Kopeerimiseks vajuta [Ctrl]+[c])", + "Delete data": "Kustuta andmed", + "Could not create paste: %s": "Ei suutnud kleebet luua: %s", + "Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)": "Ei suutnud kleebet dekrüpteerida: Dekrüpteerimisvõti on URL-ist puudu (Kas kasutasid ümbersuunajat või URL-i lühendajat, mis eemaldab osa URL-ist?)", "B": "B", "KiB": "KiB", "MiB": "MiB", @@ -139,49 +139,49 @@ "EiB": "EiB", "ZiB": "ZiB", "YiB": "YiB", - "Format": "Format", - "Plain Text": "Plain Text", - "Source Code": "Source Code", + "Format": "Formaat", + "Plain Text": "Lihttekst", + "Source Code": "Lähtekood", "Markdown": "Markdown", - "Download attachment": "Download attachment", - "Cloned: '%s'": "Cloned: '%s'", + "Download attachment": "Laadi manus alla", + "Cloned: '%s'": "Kloonitud: '%s'", "The cloned file '%s' was attached to this paste.": "The cloned file '%s' was attached to this paste.", - "Attach a file": "Attach a file", - "alternatively drag & drop a file or paste an image from the clipboard": "alternatively drag & drop a file or paste an image from the clipboard", - "File too large, to display a preview. Please download the attachment.": "File too large, to display a preview. Please download the attachment.", - "Remove attachment": "Remove attachment", - "Your browser does not support uploading encrypted files. Please use a newer browser.": "Your browser does not support uploading encrypted files. Please use a newer browser.", - "Invalid attachment.": "Invalid attachment.", - "Options": "Options", - "Shorten URL": "Shorten URL", - "Editor": "Editor", - "Preview": "Preview", + "Attach a file": "Manusta fail", + "alternatively drag & drop a file or paste an image from the clipboard": "teise võimalusena lohista fail või kleebi pilt lõikelaualt", + "File too large, to display a preview. Please download the attachment.": "Fail on eelvaate kuvamiseks liiga suur. Palun laadi manus alla.", + "Remove attachment": "Eemalda manus", + "Your browser does not support uploading encrypted files. Please use a newer browser.": "Sinu brauser ei toeta krüpteeritud failide üleslaadimist. Palun kasuta uuemat brauserit.", + "Invalid attachment.": "Sobimatu manus.", + "Options": "Valikud", + "Shorten URL": "Lühenda URL-i", + "Editor": "Toimetaja", + "Preview": "Eelvaade", "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.": "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.", - "Decrypt": "Decrypt", - "Enter password": "Enter password", - "Loading…": "Loading…", - "Decrypting paste…": "Decrypting paste…", - "Preparing new paste…": "Preparing new paste…", + "Decrypt": "Dekrüpteeri", + "Enter password": "Sisesta parool", + "Loading…": "Laadimine…", + "Decrypting paste…": "Kleepe dekrüpteerimine…", + "Preparing new paste…": "Uue kleepe ettevalmistamine…", "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "In case this message never disappears please have a look at this FAQ for information to troubleshoot.", "+++ no paste text +++": "+++ no paste text +++", "Could not get paste data: %s": "Could not get paste data: %s", - "QR code": "QR code", + "QR code": "QR kood", "This website is using an insecure HTTP connection! Please use it only for testing.": "This website is using an insecure HTTP connection! Please use it only for testing.", "For more information see this FAQ entry.": "For more information see this FAQ entry.", "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.": "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.", "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.": "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.", "waiting on user to provide a password": "waiting on user to provide a password", "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.": "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.", - "Retry": "Retry", + "Retry": "Proovi uuesti", "Showing raw text…": "Showing raw text…", - "Notice:": "Notice:", + "Notice:": "Teade:", "This link will expire after %s.": "This link will expire after %s.", "This link can only be accessed once, do not use back or refresh button in your browser.": "This link can only be accessed once, do not use back or refresh button in your browser.", "Link:": "Link:", "Recipient may become aware of your timezone, convert time to UTC?": "Recipient may become aware of your timezone, convert time to UTC?", "Use Current Timezone": "Use Current Timezone", "Convert To UTC": "Convert To UTC", - "Close": "Close", + "Close": "Sulge", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." From 727166e945ac5cb2d8cce7b5b0fd605d38a7ab6a Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Thu, 8 Apr 2021 23:05:35 +0200 Subject: [PATCH 069/223] New translations en.json (Estonian) --- i18n/et.json | 66 ++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/i18n/et.json b/i18n/et.json index d5b9aa46..877c732e 100644 --- a/i18n/et.json +++ b/i18n/et.json @@ -5,8 +5,8 @@ "Because ignorance is bliss": "Kuna teadmatus on õndsus", "en": "et", "Paste does not exist, has expired or has been deleted.": "Kleebet ei eksisteeri, on aegunud või on kustutatud.", - "%s requires php %s or above to work. Sorry.": "%s vajab php %s-d või kõrgemat, et töötada. Vabandame.", - "%s requires configuration section [%s] to be present in configuration file.": "%s requires configuration section [%s] to be present in configuration file.", + "%s requires php %s or above to work. Sorry.": "%s vajab, et oleks php %s või kõrgem, et töötada. Vabandame.", + "%s requires configuration section [%s] to be present in configuration file.": "%s vajab, et [%s] seadistamise jaotis oleks olemas konfiguratsioonifailis.", "Please wait %d seconds between each post.": [ "Palun oota %d sekund iga postituse vahel.", "Palun oota %d sekundit iga postituse vahel.", @@ -19,7 +19,7 @@ "Error saving comment. Sorry.": "Viga kommentaari salvestamisel. Vabandame.", "Error saving paste. Sorry.": "Viga kleepe salvestamisel. Vabandame.", "Invalid paste ID.": "Vale kleepe ID.", - "Paste is not of burn-after-reading type.": "Paste is not of burn-after-reading type.", + "Paste is not of burn-after-reading type.": "Kleebe ei ole põleta-pärast-lugemist tüüpi.", "Wrong deletion token. Paste was not deleted.": "Vale kustutamiskood. Kleebet ei kustutatud.", "Paste was properly deleted.": "Kleebe kustutati korralikult.", "JavaScript is required for %s to work. Sorry for the inconvenience.": "JavaScript on vajalik %s'i töötamiseks. Vabandame ebamugavuste pärast.", @@ -33,7 +33,7 @@ "Open discussion": "Avatud arutelu", "Password (recommended)": "Parool (soovitatav)", "Discussion": "Arutelu", - "Toggle navigation": "Toggle navigation", + "Toggle navigation": "Näita menüüd", "%d seconds": [ "%d sekund", "%d sekundit", @@ -77,7 +77,7 @@ "%d aastat" ], "Never": "Mitte kunagi", - "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "Märge: See on testimisteenus: Andmeid võidakse igal ajal kustutada. Kiisupojad hukkuvad, kui seda teenust kuritarvitad.", + "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "Märge: See on testimisteenus: Andmeid võidakse igal ajal kustutada. Kiisupojad hukuvad, kui seda teenust kuritarvitad.", "This document will expire in %d seconds.": [ "See dokument aegub %d sekundi pärast.", "See dokument aegub %d sekundi pärast.", @@ -109,20 +109,20 @@ "See dokument aegub %d kuu pärast." ], "Please enter the password for this paste:": "Palun sisesta selle kleepe parool:", - "Could not decrypt data (Wrong key?)": "Could not decrypt data (Wrong key?)", - "Could not delete the paste, it was not stored in burn after reading mode.": "Could not delete the paste, it was not stored in burn after reading mode.", - "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.", - "Could not decrypt comment; Wrong key?": "Could not decrypt comment; Wrong key?", + "Could not decrypt data (Wrong key?)": "Ei suutnud andmeid dekrüpteerida (Vale võti?)", + "Could not delete the paste, it was not stored in burn after reading mode.": "Ei suutnud kleebet kustutada, seda ei salvestatud põleta pärast lugemist režiimis.", + "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "AINULT SINU SILMADELE. Ära sulge seda akent, seda sõnumit ei saa enam kuvada.", + "Could not decrypt comment; Wrong key?": "Ei suutnud kommentaari dekrüpteerida; Vale võti?", "Reply": "Vasta", "Anonymous": "Anonüümne", - "Avatar generated from IP address": "Avatar generated from IP address", + "Avatar generated from IP address": "Avatar genereeritud IP aadressi põhjal", "Add comment": "Lisa kommentaar", "Optional nickname…": "Valikuline hüüdnimi…", "Post comment": "Postita kommentaar", "Sending comment…": "Kommentaari saatmine…", "Comment posted.": "Kommentaar postitatud.", - "Could not refresh display: %s": "Could not refresh display: %s", - "unknown status": "unknown status", + "Could not refresh display: %s": "Ei suutnud kuva värskendada: %s", + "unknown status": "tundmatu staatus", "server error or not responding": "serveri viga või ei vasta", "Could not post comment: %s": "Ei suutnud kommentaari postitada: %s", "Sending paste…": "Kleepe saatmine…", @@ -145,7 +145,7 @@ "Markdown": "Markdown", "Download attachment": "Laadi manus alla", "Cloned: '%s'": "Kloonitud: '%s'", - "The cloned file '%s' was attached to this paste.": "The cloned file '%s' was attached to this paste.", + "The cloned file '%s' was attached to this paste.": "Kloonitud fail '%s' manustati sellele kleepele.", "Attach a file": "Manusta fail", "alternatively drag & drop a file or paste an image from the clipboard": "teise võimalusena lohista fail või kleebi pilt lõikelaualt", "File too large, to display a preview. Please download the attachment.": "Fail on eelvaate kuvamiseks liiga suur. Palun laadi manus alla.", @@ -153,36 +153,36 @@ "Your browser does not support uploading encrypted files. Please use a newer browser.": "Sinu brauser ei toeta krüpteeritud failide üleslaadimist. Palun kasuta uuemat brauserit.", "Invalid attachment.": "Sobimatu manus.", "Options": "Valikud", - "Shorten URL": "Lühenda URL-i", + "Shorten URL": "Lühenda URL", "Editor": "Toimetaja", "Preview": "Eelvaade", - "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.": "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.", + "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.": "%s vajab, et PATH lõppeks järgmisega: \"%s\". Palun uuenda PATH-i oma index.php failis.", "Decrypt": "Dekrüpteeri", "Enter password": "Sisesta parool", "Loading…": "Laadimine…", "Decrypting paste…": "Kleepe dekrüpteerimine…", "Preparing new paste…": "Uue kleepe ettevalmistamine…", - "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "In case this message never disappears please have a look at this FAQ for information to troubleshoot.", - "+++ no paste text +++": "+++ no paste text +++", - "Could not get paste data: %s": "Could not get paste data: %s", + "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "Kui see sõnum ei kao, palun vaata seda KKK-d, et saada tõrkeotsinguks teavet..", + "+++ no paste text +++": "+++ kleepe tekst puudub +++", + "Could not get paste data: %s": "Ei suutnud saada kleepe andmeid: %s", "QR code": "QR kood", - "This website is using an insecure HTTP connection! Please use it only for testing.": "This website is using an insecure HTTP connection! Please use it only for testing.", - "For more information see this FAQ entry.": "For more information see this FAQ entry.", - "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.": "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.", - "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.": "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.", - "waiting on user to provide a password": "waiting on user to provide a password", - "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.": "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.", + "This website is using an insecure HTTP connection! Please use it only for testing.": "See veebisait kasutab ebaturvalist HTTP ühendust! Palun kasuta seda ainult katsetamiseks.", + "For more information see this FAQ entry.": "Lisateabe saamiseks vaata seda KKK sissekannet.", + "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.": "Sinu brauser võib vajada HTTPS ühendust, et toetada WebCrypto API-d. Proovi üle minna HTTPS-ile.", + "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.": "Sinu brauser ei toeta WebAssembly't, mida kasutatakse zlib tihendamiseks. Sa saad luua tihendamata dokumente, kuid ei saa lugeda tihendatuid.", + "waiting on user to provide a password": "ootan parooli sisestamist kasutajalt", + "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.": "Ei suutnud andmeid dekrüpteerida. Kas sisestasid vale parooli? Proovi uuesti üleval asuva nupuga.", "Retry": "Proovi uuesti", - "Showing raw text…": "Showing raw text…", + "Showing raw text…": "Lähteteksti näitamine…", "Notice:": "Teade:", - "This link will expire after %s.": "This link will expire after %s.", - "This link can only be accessed once, do not use back or refresh button in your browser.": "This link can only be accessed once, do not use back or refresh button in your browser.", + "This link will expire after %s.": "See link aegub: %s.", + "This link can only be accessed once, do not use back or refresh button in your browser.": "Sellele lingile saab vaid üks kord ligi pääseda, ära kasuta tagasi või värskenda nuppe sinu brauseris.", "Link:": "Link:", - "Recipient may become aware of your timezone, convert time to UTC?": "Recipient may become aware of your timezone, convert time to UTC?", - "Use Current Timezone": "Use Current Timezone", - "Convert To UTC": "Convert To UTC", + "Recipient may become aware of your timezone, convert time to UTC?": "Saaja võib saada teada sinu ajavööndi, kas teisendada aeg UTC-ks?", + "Use Current Timezone": "Kasuta praegust ajavööndit", + "Convert To UTC": "Teisenda UTC-ks", "Close": "Sulge", - "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "Encrypted note on PrivateBin": "Krüpteeritud kiri PrivateBin-is", + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kirja nägemiseks külasta seda linki. Teistele URL-i andmine lubab ka neil ligi pääseda kirjale.", + "URL shortener may expose your decrypt key in URL.": "URL-i lühendaja võib paljastada sinu dekrüpteerimisvõtme URL-is." } From 1ff8637c237e7b645e78a7a9239a720c544d5257 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sat, 10 Apr 2021 15:45:21 +0200 Subject: [PATCH 070/223] New translations en.json (Lithuanian) --- i18n/lt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/lt.json b/i18n/lt.json index f973f4f6..afbf1119 100644 --- a/i18n/lt.json +++ b/i18n/lt.json @@ -184,5 +184,5 @@ "Close": "Užverti", "Encrypted note on PrivateBin": "Šifruoti užrašai ties PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Norėdami matyti užrašus, aplankykite šį tinklalapį. Pasidalinus šiuo URL adresu su kitais žmonėmis, jiems taip pat bus leidžiama prieiga prie šių užrašų.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL trumpinimo įrankis gali atskleisti URL adrese jūsų iššifravimo raktą." } From ab250d8686195d65a680fb1cde81e4ccdc64be0d Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sat, 10 Apr 2021 16:52:48 +0200 Subject: [PATCH 071/223] New translations en.json (Lithuanian) --- i18n/lt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/lt.json b/i18n/lt.json index afbf1119..7ef45bf4 100644 --- a/i18n/lt.json +++ b/i18n/lt.json @@ -1,7 +1,7 @@ { "PrivateBin": "PrivateBin", "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s yra minimalistinis, atvirojo kodo internetinis įdėjimų dėklas, kurį naudojant, serveris nieko nenutuokia apie įdėtus duomenis. Duomenys yra šifruojami/iššifruojami %snaršyklėje%s naudojant 256 bitų AES.", - "More information on the project page.": "Daugiau informacijos rasite projeketo puslapyje.", + "More information on the project page.": "Daugiau informacijos rasite projekto puslapyje.", "Because ignorance is bliss": "Nes nežinojimas yra palaima", "en": "lt", "Paste does not exist, has expired or has been deleted.": "Įdėjimo nėra, jis nebegalioja arba buvo ištrintas.", From 175d14224eeb5f43108d2bd4a6442ade2290b70e Mon Sep 17 00:00:00 2001 From: El RIDO Date: Fri, 16 Apr 2021 18:27:12 +0200 Subject: [PATCH 072/223] set plurals for and credit Estonian translation --- CHANGELOG.md | 1 + CREDITS.md | 1 + js/privatebin.js | 6 +++--- lib/I18n.php | 4 ++-- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 201fb81d..a67fdc19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # PrivateBin version history * **1.4 (not yet released)** + * ADDED: Translation for Estonian * **1.3.5 (2021-04-05)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan * ADDED: Make the project info configurable (#681) diff --git a/CREDITS.md b/CREDITS.md index 8b24f167..1aabf6f1 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -50,3 +50,4 @@ Sébastien Sauvage - original idea and main developer * Moo - Lithuanian * whenwesober - Indonesian * retiolus - Catalan +* sarnane - Estonian diff --git a/js/privatebin.js b/js/privatebin.js index 42cdd961..e549dd61 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -601,7 +601,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { * @prop {string[]} * @readonly */ - const supportedLanguages = ['bg', 'cs', 'de', 'es', 'fr', 'he', 'hu', 'it', 'lt', 'no', 'nl', 'pl', 'pt', 'oc', 'ru', 'sl', 'uk', 'zh']; + const supportedLanguages = ['bg', 'ca', 'cs', 'de', 'es', 'et', 'fr', 'he', 'hu', 'id', 'it', 'lt', 'no', 'nl', 'pl', 'pt', 'oc', 'ru', 'sl', 'uk', 'zh']; /** * built in language @@ -767,7 +767,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * per language functions to use to determine the plural form * - * @see {@link http://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html} + * @see {@link https://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html} * @name I18n.getPluralForm * @function * @param {int} n @@ -795,7 +795,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { return n % 10 === 1 && n % 100 !== 11 ? 0 : (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2); case 'sl': return n % 100 === 1 ? 1 : (n % 100 === 2 ? 2 : (n % 100 === 3 || n % 100 === 4 ? 3 : 0)); - // bg, ca, de, en, es, hu, it, nl, no, pt + // bg, ca, de, en, es, et, hu, it, nl, no, pt default: return n !== 1 ? 1 : 0; } diff --git a/lib/I18n.php b/lib/I18n.php index ea7d07f9..50bf0ccf 100644 --- a/lib/I18n.php +++ b/lib/I18n.php @@ -305,7 +305,7 @@ class I18n /** * determines the plural form to use based on current language and given number * - * From: http://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html + * From: https://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html * * @access protected * @static @@ -334,7 +334,7 @@ class I18n return $n % 10 == 1 && $n % 100 != 11 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2); case 'sl': return $n % 100 == 1 ? 1 : ($n % 100 == 2 ? 2 : ($n % 100 == 3 || $n % 100 == 4 ? 3 : 0)); - // bg, ca, de, en, es, hu, it, nl, no, pt + // bg, ca, de, en, es, et, hu, it, nl, no, pt default: return $n != 1 ? 1 : 0; } diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index a86faf31..ffea8720 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index 6dd4331f..e58617d1 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> - + From 9e6eb50cede0bb27c4fa9a8e2d7d11961708be46 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Fri, 16 Apr 2021 19:19:11 +0200 Subject: [PATCH 073/223] adding new security headers, fixes #765 --- CHANGELOG.md | 1 + lib/Controller.php | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a67fdc19..7276c84e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * **1.4 (not yet released)** * ADDED: Translation for Estonian + * ADDED: new HTTP headers improving security (#765) * **1.3.5 (2021-04-05)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan * ADDED: Make the project info configurable (#681) diff --git a/lib/Controller.php b/lib/Controller.php index 38fc09d9..bc23a52a 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -346,10 +346,13 @@ class Controller header('Last-Modified: ' . $time); header('Vary: Accept'); header('Content-Security-Policy: ' . $this->_conf->getKey('cspheader')); + header('Cross-Origin-Resource-Policy: same-origin'); + header('Cross-Origin-Embedder-Policy: require-corp'); + header('Cross-Origin-Opener-Policy: same-origin'); header('Referrer-Policy: no-referrer'); - header('X-Xss-Protection: 1; mode=block'); - header('X-Frame-Options: DENY'); header('X-Content-Type-Options: nosniff'); + header('X-Frame-Options: deny'); + header('X-XSS-Protection: 1; mode=block'); // label all the expiration options $expire = array(); From ed663513372385754b37c57f0a7bee41b1c79a08 Mon Sep 17 00:00:00 2001 From: Christian Pierre MOMON Date: Wed, 14 Apr 2021 03:11:58 +0200 Subject: [PATCH 074/223] Added download feature (#5318). --- css/privatebin.css | 4 ++++ js/privatebin.js | 41 +++++++++++++++++++++++++++++++++++++++++ tpl/bootstrap.php | 5 ++++- tpl/page.php | 2 +- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/css/privatebin.css b/css/privatebin.css index 8b4e6a0a..f852d396 100644 --- a/css/privatebin.css +++ b/css/privatebin.css @@ -249,6 +249,10 @@ button img { padding: 1px 0 1px 0; } +#downloadtextbutton img { + padding: 1px 0 1px 0; +} + #remainingtime, #password { color: #94a3b4; display: inline; diff --git a/js/privatebin.js b/js/privatebin.js index e549dd61..50908856 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -3525,6 +3525,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { $password, $passwordInput, $rawTextButton, + $downloadTextButton, $qrCodeLink, $emailLink, $sendButton, @@ -3666,6 +3667,30 @@ jQuery.PrivateBin = (function($, RawDeflate) { newDoc.close(); } + /** + * download text + * + * @name TopNav.downloadText + * @private + * @function + */ + function downloadText() + { + var filename='paste.txt'; + var text = PasteViewer.getText(); + + var element = document.createElement('a'); + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); + element.setAttribute('download', filename); + + element.style.display = 'none'; + document.body.appendChild(element); + + element.click(); + + document.body.removeChild(element); + } + /** * saves the language in a cookie and reloads the page * @@ -3892,6 +3917,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { $newButton.removeClass('hidden'); $cloneButton.removeClass('hidden'); $rawTextButton.removeClass('hidden'); + $downloadTextButton.removeClass('hidden'); $qrCodeLink.removeClass('hidden'); viewButtonsDisplayed = true; @@ -3912,6 +3938,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { $cloneButton.addClass('hidden'); $newButton.addClass('hidden'); $rawTextButton.addClass('hidden'); + $downloadTextButton.addClass('hidden'); $qrCodeLink.addClass('hidden'); me.hideEmailButton(); @@ -4073,6 +4100,17 @@ jQuery.PrivateBin = (function($, RawDeflate) { $rawTextButton.addClass('hidden'); }; + /** + * only hides the download text button + * + * @name TopNav.hideRawButton + * @function + */ + me.hideDownloadButton = function() + { + $downloadTextButton.addClass('hidden'); + }; + /** * only hides the qr code button * @@ -4334,6 +4372,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { $password = $('#password'); $passwordInput = $('#passwordinput'); $rawTextButton = $('#rawtextbutton'); + $downloadTextButton = $('#downloadtextbutton'); $retryButton = $('#retrybutton'); $sendButton = $('#sendbutton'); $qrCodeLink = $('#qrcodelink'); @@ -4351,6 +4390,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { $sendButton.click(PasteEncrypter.sendPaste); $cloneButton.click(Controller.clonePaste); $rawTextButton.click(rawText); + $downloadTextButton.click(downloadText); $retryButton.click(clickRetryButton); $fileRemoveButton.click(removeAttachment); $qrCodeLink.click(displayQrCode); @@ -4689,6 +4729,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { TopNav.showEmailButton(); TopNav.hideRawButton(); + TopNav.hideDownloadButton(); Editor.hide(); // parse and show text diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index ffea8720..c43ddbf2 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> - + @@ -212,6 +212,9 @@ endif; + diff --git a/tpl/page.php b/tpl/page.php index e58617d1..096a9e60 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> - + From 1dc8b24665bfe65ef6696468235f5698e4195899 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Fri, 16 Apr 2021 20:15:12 +0200 Subject: [PATCH 075/223] transmit cookie only over HTTPS, fixes #472 --- CHANGELOG.md | 1 + js/privatebin.js | 2 +- lib/Controller.php | 4 ++-- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7276c84e..00f5f21c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * **1.4 (not yet released)** * ADDED: Translation for Estonian * ADDED: new HTTP headers improving security (#765) + * CHANGED: Language selection cookie only transmitted over HTTPS (#472) * **1.3.5 (2021-04-05)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan * ADDED: Make the project info configurable (#681) diff --git a/js/privatebin.js b/js/privatebin.js index e549dd61..05199701 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -3676,7 +3676,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { */ function setLanguage(event) { - document.cookie = 'lang=' + $(event.target).data('lang'); + document.cookie = 'lang=' + $(event.target).data('lang') + ';secure'; UiHelper.reloadHome(); } diff --git a/lib/Controller.php b/lib/Controller.php index bc23a52a..5b81cd89 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -170,7 +170,7 @@ class Controller // force default language, if language selection is disabled and a default is set if (!$this->_conf->getKey('languageselection') && strlen($lang) == 2) { $_COOKIE['lang'] = $lang; - setcookie('lang', $lang); + setcookie('lang', $lang, 0, '', '', true); } } @@ -367,7 +367,7 @@ class Controller $languageselection = ''; if ($this->_conf->getKey('languageselection')) { $languageselection = I18n::getLanguage(); - setcookie('lang', $languageselection); + setcookie('lang', $languageselection, 0, '', '', true); } $page = new View; diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index ffea8720..f8f94446 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index e58617d1..a2272326 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> - + From 6f3bb25b092cf33160d1a8d2071f7ca4e5cedcaa Mon Sep 17 00:00:00 2001 From: El RIDO Date: Fri, 16 Apr 2021 20:25:50 +0200 Subject: [PATCH 076/223] disable Google FloC --- lib/Controller.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Controller.php b/lib/Controller.php index bc23a52a..bfa29b1d 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -349,6 +349,7 @@ class Controller header('Cross-Origin-Resource-Policy: same-origin'); header('Cross-Origin-Embedder-Policy: require-corp'); header('Cross-Origin-Opener-Policy: same-origin'); + header('Permissions-Policy: interest-cohort=()'); header('Referrer-Policy: no-referrer'); header('X-Content-Type-Options: nosniff'); header('X-Frame-Options: deny'); From fd7d05e8624b9a8293496ace80ed437ccd02f88d Mon Sep 17 00:00:00 2001 From: rugk Date: Fri, 16 Apr 2021 22:03:02 +0200 Subject: [PATCH 077/223] Add base URL as default CSP restriction This follows an [HTTP Observatory recommendation](https://observatory.mozilla.org/analyze/privatebin.net): > Restricts use of the tag by using base-uri 'none', base-uri 'self', or specific origins. Given we don't use that anywhere, this safe should be safe. (not tested practically though) --- cfg/conf.sample.php | 2 +- lib/Configuration.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php index e958c88d..570503ce 100644 --- a/cfg/conf.sample.php +++ b/cfg/conf.sample.php @@ -87,7 +87,7 @@ languageselection = false ; async functions and display an error if not and for Chrome to enable ; webassembly support (used for zlib compression). You can remove it if Chrome ; doesn't need to be supported and old browsers don't need to be warned. -; cspheader = "default-src 'none'; manifest-src 'self'; connect-src * blob:; script-src 'self' 'unsafe-eval' resource:; style-src 'self'; font-src 'self'; img-src 'self' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads" +; cspheader = "default-src 'none'; base-uri 'self'; manifest-src 'self'; connect-src * blob:; script-src 'self' 'unsafe-eval' resource:; style-src 'self'; font-src 'self'; img-src 'self' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads" ; stay compatible with PrivateBin Alpha 0.19, less secure ; if enabled will use base64.js version 1.7 instead of 2.1.9 and sha1 instead of diff --git a/lib/Configuration.php b/lib/Configuration.php index 2a326caf..741ab7c9 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -55,7 +55,7 @@ class Configuration 'urlshortener' => '', 'qrcode' => true, 'icon' => 'identicon', - 'cspheader' => 'default-src \'none\'; manifest-src \'self\'; connect-src * blob:; script-src \'self\' \'unsafe-eval\' resource:; style-src \'self\'; font-src \'self\'; img-src \'self\' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads', + 'cspheader' => 'default-src \'none\'; base-uri \'self\'; manifest-src \'self\'; connect-src * blob:; script-src \'self\' \'unsafe-eval\' resource:; style-src \'self\'; font-src \'self\'; img-src \'self\' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads', 'zerobincompatibility' => false, 'httpwarning' => true, 'compression' => 'zlib', @@ -265,3 +265,4 @@ class Configuration return $this->_configuration[$section]; } } + From 7b7a32c0a734b53ca2c7276410759390ea308189 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 17 Apr 2021 08:20:08 +0200 Subject: [PATCH 078/223] apply StyleCI recommendation --- lib/Configuration.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Configuration.php b/lib/Configuration.php index 741ab7c9..426cd158 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -265,4 +265,3 @@ class Configuration return $this->_configuration[$section]; } } - From 5f4200c721be070162981878dff30ade1bcde89f Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 17 Apr 2021 08:39:35 +0200 Subject: [PATCH 079/223] document change --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00f5f21c..b3278931 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * **1.4 (not yet released)** * ADDED: Translation for Estonian * ADDED: new HTTP headers improving security (#765) + * ADDED: Opt-out of federated learning of cohorts (FLoC) (#776) * CHANGED: Language selection cookie only transmitted over HTTPS (#472) * **1.3.5 (2021-04-05)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan From 9683c591bb77f57444ea6425cc37da09950a8662 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 17 Apr 2021 08:48:12 +0200 Subject: [PATCH 080/223] document change --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3278931..8e416b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * **1.4 (not yet released)** * ADDED: Translation for Estonian * ADDED: new HTTP headers improving security (#765) + * ADDED: Download button for paste text (#774) * ADDED: Opt-out of federated learning of cohorts (FLoC) (#776) * CHANGED: Language selection cookie only transmitted over HTTPS (#472) * **1.3.5 (2021-04-05)** From 853a4f386fa9a870cb2aa3616d43b61d0f10ec5f Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 17 Apr 2021 08:51:25 +0200 Subject: [PATCH 081/223] fix indentation --- js/privatebin.js | 24 ++++++++++++------------ tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 0fe0e1dd..9cf569f4 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -3525,7 +3525,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { $password, $passwordInput, $rawTextButton, - $downloadTextButton, + $downloadTextButton, $qrCodeLink, $emailLink, $sendButton, @@ -3676,20 +3676,20 @@ jQuery.PrivateBin = (function($, RawDeflate) { */ function downloadText() { - var filename='paste.txt'; - var text = PasteViewer.getText(); + var filename='paste.txt'; + var text = PasteViewer.getText(); - var element = document.createElement('a'); - element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); - element.setAttribute('download', filename); + var element = document.createElement('a'); + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); + element.setAttribute('download', filename); - element.style.display = 'none'; - document.body.appendChild(element); + element.style.display = 'none'; + document.body.appendChild(element); - element.click(); + element.click(); - document.body.removeChild(element); - } + document.body.removeChild(element); + } /** * saves the language in a cookie and reloads the page @@ -4729,7 +4729,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { TopNav.showEmailButton(); TopNav.hideRawButton(); - TopNav.hideDownloadButton(); + TopNav.hideDownloadButton(); Editor.hide(); // parse and show text diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 38cedc17..ae4d1e7d 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index 832e6da1..724c2721 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> - + From bc114522592f0c3ed2d366363ad264437cf904aa Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 17 Apr 2021 09:08:11 +0200 Subject: [PATCH 082/223] make filename unique per paste ID --- js/privatebin.js | 2 +- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 9cf569f4..6218700a 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -3676,7 +3676,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { */ function downloadText() { - var filename='paste.txt'; + var filename='paste-' + Model.getPasteId() + '.txt'; var text = PasteViewer.getText(); var element = document.createElement('a'); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index ae4d1e7d..fd715c41 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index 724c2721..53a81713 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> - + From 3181cfe58add27674e9e893f01b2a0fbaf2e6d4e Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 17 Apr 2021 09:15:00 +0200 Subject: [PATCH 083/223] translate download button, add it to page template --- i18n/ar.json | 3 ++- i18n/bg.json | 3 ++- i18n/ca.json | 3 ++- i18n/cs.json | 3 ++- i18n/de.json | 3 ++- i18n/el.json | 3 ++- i18n/en.json | 3 ++- i18n/es.json | 3 ++- i18n/et.json | 3 ++- i18n/fr.json | 3 ++- i18n/he.json | 3 ++- i18n/hi.json | 3 ++- i18n/hu.json | 3 ++- i18n/id.json | 3 ++- i18n/it.json | 3 ++- i18n/ja.json | 3 ++- i18n/ku.json | 3 ++- i18n/la.json | 3 ++- i18n/lt.json | 3 ++- i18n/nl.json | 3 ++- i18n/no.json | 3 ++- i18n/oc.json | 3 ++- i18n/pl.json | 3 ++- i18n/pt.json | 3 ++- i18n/ru.json | 3 ++- i18n/sl.json | 3 ++- i18n/sv.json | 3 ++- i18n/tr.json | 3 ++- i18n/uk.json | 3 ++- i18n/zh.json | 3 ++- tpl/bootstrap.php | 2 +- tpl/page.php | 1 + 32 files changed, 62 insertions(+), 31 deletions(-) diff --git a/i18n/ar.json b/i18n/ar.json index 8b8e1aef..894b87b7 100644 --- a/i18n/ar.json +++ b/i18n/ar.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/bg.json b/i18n/bg.json index 8ddd1f54..1385ab11 100644 --- a/i18n/bg.json +++ b/i18n/bg.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/ca.json b/i18n/ca.json index a4e6d3fd..d81499ca 100644 --- a/i18n/ca.json +++ b/i18n/ca.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/cs.json b/i18n/cs.json index 1a6249ad..956d1dbd 100644 --- a/i18n/cs.json +++ b/i18n/cs.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/de.json b/i18n/de.json index dd8a48a7..7cecba77 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -184,5 +184,6 @@ "Close": "Schliessen", "Encrypted note on PrivateBin": "Verschlüsselte Notiz auf PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besuche diese Verknüpfung um das Dokument zu sehen. Wird die URL an eine andere Person gegeben, so kann diese Person ebenfalls auf dieses Dokument zugreifen.", - "URL shortener may expose your decrypt key in URL.": "Der URL-Verkürzer kann den Schlüssel in der URL enthüllen." + "URL shortener may expose your decrypt key in URL.": "Der URL-Verkürzer kann den Schlüssel in der URL enthüllen.", + "Download": "Download" } diff --git a/i18n/el.json b/i18n/el.json index 6fd45e41..54f21a2a 100644 --- a/i18n/el.json +++ b/i18n/el.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/en.json b/i18n/en.json index 295f5129..e38b40e6 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/es.json b/i18n/es.json index 4e93e669..307a8559 100644 --- a/i18n/es.json +++ b/i18n/es.json @@ -184,5 +184,6 @@ "Close": "Cerrar", "Encrypted note on PrivateBin": "Nota cifrada en PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visite este enlace para ver la nota. Dar la URL a cualquier persona también les permite acceder a la nota.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/et.json b/i18n/et.json index 877c732e..0b4d5cfe 100644 --- a/i18n/et.json +++ b/i18n/et.json @@ -184,5 +184,6 @@ "Close": "Sulge", "Encrypted note on PrivateBin": "Krüpteeritud kiri PrivateBin-is", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kirja nägemiseks külasta seda linki. Teistele URL-i andmine lubab ka neil ligi pääseda kirjale.", - "URL shortener may expose your decrypt key in URL.": "URL-i lühendaja võib paljastada sinu dekrüpteerimisvõtme URL-is." + "URL shortener may expose your decrypt key in URL.": "URL-i lühendaja võib paljastada sinu dekrüpteerimisvõtme URL-is.", + "Download": "Download" } diff --git a/i18n/fr.json b/i18n/fr.json index 409d4499..bc53fe12 100644 --- a/i18n/fr.json +++ b/i18n/fr.json @@ -184,5 +184,6 @@ "Close": "Fermer", "Encrypted note on PrivateBin": "Message chiffré sur PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visiter ce lien pour voir la note. Donner l'URL à une autre personne lui permet également d'accéder à la note.", - "URL shortener may expose your decrypt key in URL.": "Raccourcir l'URL peut exposer votre clé de déchiffrement dans l'URL." + "URL shortener may expose your decrypt key in URL.": "Raccourcir l'URL peut exposer votre clé de déchiffrement dans l'URL.", + "Download": "Download" } diff --git a/i18n/he.json b/i18n/he.json index 206587b5..eb2d5121 100644 --- a/i18n/he.json +++ b/i18n/he.json @@ -184,5 +184,6 @@ "Close": "סגירה", "Encrypted note on PrivateBin": "הערה מוצפנת ב־PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "נא לבקר בקישור כדי לצפות בהערה. מסירת הקישור לאנשים כלשהם תאפשר גם להם לגשת להערה.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/hi.json b/i18n/hi.json index a248e828..4df9ce02 100644 --- a/i18n/hi.json +++ b/i18n/hi.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/hu.json b/i18n/hu.json index b8708367..a619b3f5 100644 --- a/i18n/hu.json +++ b/i18n/hu.json @@ -184,5 +184,6 @@ "Close": "Bezárás", "Encrypted note on PrivateBin": "Titkosított jegyzet a PrivateBinen", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Látogasd meg ezt a hivatkozást a bejegyzés megtekintéséhez. Ha mások számára is megadod ezt a linket, azzal hozzáférnek ők is.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/id.json b/i18n/id.json index 248121d1..1547ace2 100644 --- a/i18n/id.json +++ b/i18n/id.json @@ -184,5 +184,6 @@ "Close": "Tutup", "Encrypted note on PrivateBin": "Catatan ter-ekrip di PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kunjungi tautan ini untuk melihat catatan. Memberikan alamat URL pada siapapun juga, akan mengizinkan mereka untuk mengakses catatan, so pasti gitu loh Kaka.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/it.json b/i18n/it.json index 81b11a83..2613579a 100644 --- a/i18n/it.json +++ b/i18n/it.json @@ -184,5 +184,6 @@ "Close": "Chiudi", "Encrypted note on PrivateBin": "Nota crittografata su PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visita questo collegamento per vedere la nota. Dare l'URL a chiunque consente anche a loro di accedere alla nota.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/ja.json b/i18n/ja.json index bf4f7cad..ed6971d6 100644 --- a/i18n/ja.json +++ b/i18n/ja.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/ku.json b/i18n/ku.json index 0ff29acb..0e8c2997 100644 --- a/i18n/ku.json +++ b/i18n/ku.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/la.json b/i18n/la.json index 4d648cb9..11d062b7 100644 --- a/i18n/la.json +++ b/i18n/la.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/lt.json b/i18n/lt.json index 7ef45bf4..31f7906f 100644 --- a/i18n/lt.json +++ b/i18n/lt.json @@ -184,5 +184,6 @@ "Close": "Užverti", "Encrypted note on PrivateBin": "Šifruoti užrašai ties PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Norėdami matyti užrašus, aplankykite šį tinklalapį. Pasidalinus šiuo URL adresu su kitais žmonėmis, jiems taip pat bus leidžiama prieiga prie šių užrašų.", - "URL shortener may expose your decrypt key in URL.": "URL trumpinimo įrankis gali atskleisti URL adrese jūsų iššifravimo raktą." + "URL shortener may expose your decrypt key in URL.": "URL trumpinimo įrankis gali atskleisti URL adrese jūsų iššifravimo raktą.", + "Download": "Download" } diff --git a/i18n/nl.json b/i18n/nl.json index 54586ffb..8e51dfc3 100644 --- a/i18n/nl.json +++ b/i18n/nl.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/no.json b/i18n/no.json index ac6e369c..e8d95361 100644 --- a/i18n/no.json +++ b/i18n/no.json @@ -184,5 +184,6 @@ "Close": "Steng", "Encrypted note on PrivateBin": "Kryptert notat på PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besøk denne lenken for å se notatet. Hvis lenken deles med andre, vil de også kunne se notatet.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/oc.json b/i18n/oc.json index 49e3ddec..1d445b11 100644 --- a/i18n/oc.json +++ b/i18n/oc.json @@ -184,5 +184,6 @@ "Close": "Tampar", "Encrypted note on PrivateBin": "Nòtas chifradas sus PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visitatz aqueste ligam per veire la nòta. Fornir lo ligam a qualqu’un mai li permet tanben d’accedir a la nòta.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/pl.json b/i18n/pl.json index c18ad227..8fde350b 100644 --- a/i18n/pl.json +++ b/i18n/pl.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/pt.json b/i18n/pt.json index 60492078..f83f778f 100644 --- a/i18n/pt.json +++ b/i18n/pt.json @@ -184,5 +184,6 @@ "Close": "Fechar", "Encrypted note on PrivateBin": "Nota criptografada no PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visite esse link para ver a nota. Dar a URL para qualquer um permite que eles também acessem a nota.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/ru.json b/i18n/ru.json index b697f700..03c4945f 100644 --- a/i18n/ru.json +++ b/i18n/ru.json @@ -184,5 +184,6 @@ "Close": "Закрыть", "Encrypted note on PrivateBin": "Зашифрованная запись на PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Посетите эту ссылку чтобы просмотреть запись. Передача ссылки кому либо позволит им получить доступ к записи тоже.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/sl.json b/i18n/sl.json index 51b9caa4..bac6f983 100644 --- a/i18n/sl.json +++ b/i18n/sl.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/sv.json b/i18n/sv.json index e0859497..a586a4f6 100644 --- a/i18n/sv.json +++ b/i18n/sv.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/tr.json b/i18n/tr.json index daedf8f8..11562751 100644 --- a/i18n/tr.json +++ b/i18n/tr.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/uk.json b/i18n/uk.json index 2808c712..3afa64de 100644 --- a/i18n/uk.json +++ b/i18n/uk.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Download": "Download" } diff --git a/i18n/zh.json b/i18n/zh.json index 2e1dc12b..65d795e9 100644 --- a/i18n/zh.json +++ b/i18n/zh.json @@ -184,5 +184,6 @@ "Close": "关闭", "Encrypted note on PrivateBin": "PrivateBin上的加密笔记", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "访问这个链接来查看该笔记。 将这个URL发送给任何人即可允许其访问该笔记。", - "URL shortener may expose your decrypt key in URL.": "URL 缩短可能会暴露您在 URL 中的解密密钥。" + "URL shortener may expose your decrypt key in URL.": "URL 缩短可能会暴露您在 URL 中的解密密钥。", + "Download": "Download" } diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index fd715c41..65757891 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -213,7 +213,7 @@ endif; + Date: Sun, 18 Apr 2021 01:03:48 +0200 Subject: [PATCH 084/223] New translations en.json (Indonesian) --- i18n/id.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/id.json b/i18n/id.json index 248121d1..a7c01b3b 100644 --- a/i18n/id.json +++ b/i18n/id.json @@ -184,5 +184,5 @@ "Close": "Tutup", "Encrypted note on PrivateBin": "Catatan ter-ekrip di PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kunjungi tautan ini untuk melihat catatan. Memberikan alamat URL pada siapapun juga, akan mengizinkan mereka untuk mengakses catatan, so pasti gitu loh Kaka.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "Pemendek URL mungkin akan menampakkan kunci dekrip Anda dalam URL." } From 0e78534e48aa0ec2075f910a847719e965247f5b Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 18 Apr 2021 09:07:57 +0200 Subject: [PATCH 085/223] re-label "Download" button to "Save paste" --- i18n/ar.json | 2 +- i18n/bg.json | 2 +- i18n/ca.json | 2 +- i18n/cs.json | 2 +- i18n/de.json | 2 +- i18n/el.json | 2 +- i18n/en.json | 2 +- i18n/es.json | 2 +- i18n/et.json | 2 +- i18n/fr.json | 2 +- i18n/he.json | 2 +- i18n/hi.json | 2 +- i18n/hu.json | 2 +- i18n/id.json | 2 +- i18n/it.json | 2 +- i18n/ja.json | 2 +- i18n/ku.json | 2 +- i18n/la.json | 2 +- i18n/lt.json | 2 +- i18n/nl.json | 2 +- i18n/no.json | 2 +- i18n/oc.json | 2 +- i18n/pl.json | 2 +- i18n/pt.json | 2 +- i18n/ru.json | 2 +- i18n/sl.json | 2 +- i18n/sv.json | 2 +- i18n/tr.json | 2 +- i18n/uk.json | 2 +- i18n/zh.json | 2 +- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/i18n/ar.json b/i18n/ar.json index 894b87b7..ddca0d62 100644 --- a/i18n/ar.json +++ b/i18n/ar.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/bg.json b/i18n/bg.json index 1385ab11..4a025389 100644 --- a/i18n/bg.json +++ b/i18n/bg.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/ca.json b/i18n/ca.json index d81499ca..a6936bed 100644 --- a/i18n/ca.json +++ b/i18n/ca.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/cs.json b/i18n/cs.json index 956d1dbd..34ef19a8 100644 --- a/i18n/cs.json +++ b/i18n/cs.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/de.json b/i18n/de.json index 7cecba77..b0991d8a 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Verschlüsselte Notiz auf PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besuche diese Verknüpfung um das Dokument zu sehen. Wird die URL an eine andere Person gegeben, so kann diese Person ebenfalls auf dieses Dokument zugreifen.", "URL shortener may expose your decrypt key in URL.": "Der URL-Verkürzer kann den Schlüssel in der URL enthüllen.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/el.json b/i18n/el.json index 54f21a2a..6e33978d 100644 --- a/i18n/el.json +++ b/i18n/el.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/en.json b/i18n/en.json index e38b40e6..a96bab5d 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/es.json b/i18n/es.json index 307a8559..73f60556 100644 --- a/i18n/es.json +++ b/i18n/es.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Nota cifrada en PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visite este enlace para ver la nota. Dar la URL a cualquier persona también les permite acceder a la nota.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/et.json b/i18n/et.json index 0b4d5cfe..b364df26 100644 --- a/i18n/et.json +++ b/i18n/et.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Krüpteeritud kiri PrivateBin-is", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kirja nägemiseks külasta seda linki. Teistele URL-i andmine lubab ka neil ligi pääseda kirjale.", "URL shortener may expose your decrypt key in URL.": "URL-i lühendaja võib paljastada sinu dekrüpteerimisvõtme URL-is.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/fr.json b/i18n/fr.json index bc53fe12..03d60856 100644 --- a/i18n/fr.json +++ b/i18n/fr.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Message chiffré sur PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visiter ce lien pour voir la note. Donner l'URL à une autre personne lui permet également d'accéder à la note.", "URL shortener may expose your decrypt key in URL.": "Raccourcir l'URL peut exposer votre clé de déchiffrement dans l'URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/he.json b/i18n/he.json index eb2d5121..046874e2 100644 --- a/i18n/he.json +++ b/i18n/he.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "הערה מוצפנת ב־PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "נא לבקר בקישור כדי לצפות בהערה. מסירת הקישור לאנשים כלשהם תאפשר גם להם לגשת להערה.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/hi.json b/i18n/hi.json index 4df9ce02..0cd2787a 100644 --- a/i18n/hi.json +++ b/i18n/hi.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/hu.json b/i18n/hu.json index a619b3f5..1cff1a6f 100644 --- a/i18n/hu.json +++ b/i18n/hu.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Titkosított jegyzet a PrivateBinen", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Látogasd meg ezt a hivatkozást a bejegyzés megtekintéséhez. Ha mások számára is megadod ezt a linket, azzal hozzáférnek ők is.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/id.json b/i18n/id.json index 1547ace2..1924f81e 100644 --- a/i18n/id.json +++ b/i18n/id.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Catatan ter-ekrip di PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kunjungi tautan ini untuk melihat catatan. Memberikan alamat URL pada siapapun juga, akan mengizinkan mereka untuk mengakses catatan, so pasti gitu loh Kaka.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/it.json b/i18n/it.json index 2613579a..bda7a1d5 100644 --- a/i18n/it.json +++ b/i18n/it.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Nota crittografata su PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visita questo collegamento per vedere la nota. Dare l'URL a chiunque consente anche a loro di accedere alla nota.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/ja.json b/i18n/ja.json index ed6971d6..807a38c0 100644 --- a/i18n/ja.json +++ b/i18n/ja.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/ku.json b/i18n/ku.json index 0e8c2997..ae72ebd8 100644 --- a/i18n/ku.json +++ b/i18n/ku.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/la.json b/i18n/la.json index 11d062b7..2098982d 100644 --- a/i18n/la.json +++ b/i18n/la.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/lt.json b/i18n/lt.json index 31f7906f..bc287bc5 100644 --- a/i18n/lt.json +++ b/i18n/lt.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Šifruoti užrašai ties PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Norėdami matyti užrašus, aplankykite šį tinklalapį. Pasidalinus šiuo URL adresu su kitais žmonėmis, jiems taip pat bus leidžiama prieiga prie šių užrašų.", "URL shortener may expose your decrypt key in URL.": "URL trumpinimo įrankis gali atskleisti URL adrese jūsų iššifravimo raktą.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/nl.json b/i18n/nl.json index 8e51dfc3..65c4e37c 100644 --- a/i18n/nl.json +++ b/i18n/nl.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/no.json b/i18n/no.json index e8d95361..62764bf0 100644 --- a/i18n/no.json +++ b/i18n/no.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Kryptert notat på PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besøk denne lenken for å se notatet. Hvis lenken deles med andre, vil de også kunne se notatet.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/oc.json b/i18n/oc.json index 1d445b11..a3106864 100644 --- a/i18n/oc.json +++ b/i18n/oc.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Nòtas chifradas sus PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visitatz aqueste ligam per veire la nòta. Fornir lo ligam a qualqu’un mai li permet tanben d’accedir a la nòta.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/pl.json b/i18n/pl.json index 8fde350b..4b4a67be 100644 --- a/i18n/pl.json +++ b/i18n/pl.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/pt.json b/i18n/pt.json index f83f778f..0f6c1333 100644 --- a/i18n/pt.json +++ b/i18n/pt.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Nota criptografada no PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visite esse link para ver a nota. Dar a URL para qualquer um permite que eles também acessem a nota.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/ru.json b/i18n/ru.json index 03c4945f..1c990431 100644 --- a/i18n/ru.json +++ b/i18n/ru.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Зашифрованная запись на PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Посетите эту ссылку чтобы просмотреть запись. Передача ссылки кому либо позволит им получить доступ к записи тоже.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/sl.json b/i18n/sl.json index bac6f983..c4bb0cb7 100644 --- a/i18n/sl.json +++ b/i18n/sl.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/sv.json b/i18n/sv.json index a586a4f6..f2286e02 100644 --- a/i18n/sv.json +++ b/i18n/sv.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/tr.json b/i18n/tr.json index 11562751..edb89db5 100644 --- a/i18n/tr.json +++ b/i18n/tr.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/uk.json b/i18n/uk.json index 3afa64de..1916a244 100644 --- a/i18n/uk.json +++ b/i18n/uk.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/i18n/zh.json b/i18n/zh.json index 65d795e9..417dc52c 100644 --- a/i18n/zh.json +++ b/i18n/zh.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "PrivateBin上的加密笔记", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "访问这个链接来查看该笔记。 将这个URL发送给任何人即可允许其访问该笔记。", "URL shortener may expose your decrypt key in URL.": "URL 缩短可能会暴露您在 URL 中的解密密钥。", - "Download": "Download" + "Save paste": "Save paste" } diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 65757891..1e4eae00 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -213,7 +213,7 @@ endif; - + Date: Sun, 18 Apr 2021 14:14:46 +0200 Subject: [PATCH 086/223] feat: add form-action CSP restriction This follows a suggestion from HTTP Observatory: > Restricts where
contents may be submitted by using form-action 'none', form-action 'self', or specific URIs Fixes #778 --- cfg/conf.sample.php | 2 +- lib/Configuration.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php index 570503ce..5f8fef16 100644 --- a/cfg/conf.sample.php +++ b/cfg/conf.sample.php @@ -87,7 +87,7 @@ languageselection = false ; async functions and display an error if not and for Chrome to enable ; webassembly support (used for zlib compression). You can remove it if Chrome ; doesn't need to be supported and old browsers don't need to be warned. -; cspheader = "default-src 'none'; base-uri 'self'; manifest-src 'self'; connect-src * blob:; script-src 'self' 'unsafe-eval' resource:; style-src 'self'; font-src 'self'; img-src 'self' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads" +; cspheader = "default-src 'none'; base-uri 'self'; form-action 'self'; manifest-src 'self'; connect-src * blob:; script-src 'self' 'unsafe-eval' resource:; style-src 'self'; font-src 'self'; img-src 'self' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads" ; stay compatible with PrivateBin Alpha 0.19, less secure ; if enabled will use base64.js version 1.7 instead of 2.1.9 and sha1 instead of diff --git a/lib/Configuration.php b/lib/Configuration.php index 426cd158..113f6bd3 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -55,7 +55,7 @@ class Configuration 'urlshortener' => '', 'qrcode' => true, 'icon' => 'identicon', - 'cspheader' => 'default-src \'none\'; base-uri \'self\'; manifest-src \'self\'; connect-src * blob:; script-src \'self\' \'unsafe-eval\' resource:; style-src \'self\'; font-src \'self\'; img-src \'self\' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads', + 'cspheader' => 'default-src \'none\'; base-uri \'self\'; form-action \'self\'; manifest-src \'self\'; connect-src * blob:; script-src \'self\' \'unsafe-eval\' resource:; style-src \'self\'; font-src \'self\'; img-src \'self\' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads', 'zerobincompatibility' => false, 'httpwarning' => true, 'compression' => 'zlib', From 3ca01024fd63512daea82110fa5db4c7379a2f27 Mon Sep 17 00:00:00 2001 From: rugk Date: Sun, 18 Apr 2021 14:16:39 +0200 Subject: [PATCH 087/223] feat: disallow form submission alltogether Following the tests and HTTP Observatory, I think we can disable forms altogether. Fixes https://github.com/PrivateBin/PrivateBin/issues/778 --- cfg/conf.sample.php | 2 +- lib/Configuration.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php index 5f8fef16..a7b76a11 100644 --- a/cfg/conf.sample.php +++ b/cfg/conf.sample.php @@ -87,7 +87,7 @@ languageselection = false ; async functions and display an error if not and for Chrome to enable ; webassembly support (used for zlib compression). You can remove it if Chrome ; doesn't need to be supported and old browsers don't need to be warned. -; cspheader = "default-src 'none'; base-uri 'self'; form-action 'self'; manifest-src 'self'; connect-src * blob:; script-src 'self' 'unsafe-eval' resource:; style-src 'self'; font-src 'self'; img-src 'self' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads" +; cspheader = "default-src 'none'; base-uri 'self'; form-action 'none'; manifest-src 'self'; connect-src * blob:; script-src 'self' 'unsafe-eval' resource:; style-src 'self'; font-src 'self'; img-src 'self' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-popups allow-modals allow-downloads" ; stay compatible with PrivateBin Alpha 0.19, less secure ; if enabled will use base64.js version 1.7 instead of 2.1.9 and sha1 instead of diff --git a/lib/Configuration.php b/lib/Configuration.php index 113f6bd3..a99c3f9e 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -55,7 +55,7 @@ class Configuration 'urlshortener' => '', 'qrcode' => true, 'icon' => 'identicon', - 'cspheader' => 'default-src \'none\'; base-uri \'self\'; form-action \'self\'; manifest-src \'self\'; connect-src * blob:; script-src \'self\' \'unsafe-eval\' resource:; style-src \'self\'; font-src \'self\'; img-src \'self\' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads', + 'cspheader' => 'default-src \'none\'; base-uri \'self\'; form-action \'none\'; manifest-src \'self\'; connect-src * blob:; script-src \'self\' \'unsafe-eval\' resource:; style-src \'self\'; font-src \'self\'; img-src \'self\' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-popups allow-modals allow-downloads', 'zerobincompatibility' => false, 'httpwarning' => true, 'compression' => 'zlib', From 4b2f2920a2b2dd08af58d38fd0e58b97c3956b86 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:03:57 +0200 Subject: [PATCH 088/223] New translations en.json (Indonesian) --- i18n/id.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/id.json b/i18n/id.json index a7c01b3b..b28af88c 100644 --- a/i18n/id.json +++ b/i18n/id.json @@ -184,5 +184,6 @@ "Close": "Tutup", "Encrypted note on PrivateBin": "Catatan ter-ekrip di PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kunjungi tautan ini untuk melihat catatan. Memberikan alamat URL pada siapapun juga, akan mengizinkan mereka untuk mengakses catatan, so pasti gitu loh Kaka.", - "URL shortener may expose your decrypt key in URL.": "Pemendek URL mungkin akan menampakkan kunci dekrip Anda dalam URL." + "URL shortener may expose your decrypt key in URL.": "Pemendek URL mungkin akan menampakkan kunci dekrip Anda dalam URL.", + "Save paste": "Save paste" } From dac5bd1d93fa1c969b3ae24d40ef9bd6b7b59cb7 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:03:59 +0200 Subject: [PATCH 089/223] New translations en.json (Dutch) --- i18n/nl.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/nl.json b/i18n/nl.json index 54586ffb..65c4e37c 100644 --- a/i18n/nl.json +++ b/i18n/nl.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From db402baa14e125d06c160341affbd477d088b920 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:00 +0200 Subject: [PATCH 090/223] New translations en.json (Occitan) --- i18n/oc.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/oc.json b/i18n/oc.json index 49e3ddec..a3106864 100644 --- a/i18n/oc.json +++ b/i18n/oc.json @@ -184,5 +184,6 @@ "Close": "Tampar", "Encrypted note on PrivateBin": "Nòtas chifradas sus PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visitatz aqueste ligam per veire la nòta. Fornir lo ligam a qualqu’un mai li permet tanben d’accedir a la nòta.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 478f806e9c897bd50a995f34a050e02e33bfd90a Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:01 +0200 Subject: [PATCH 091/223] New translations en.json (Latin) --- i18n/la.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/la.json b/i18n/la.json index 4d648cb9..2098982d 100644 --- a/i18n/la.json +++ b/i18n/la.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From bd83415c825a8c7ead351c6fd27736666ee87c5c Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:02 +0200 Subject: [PATCH 092/223] New translations en.json (Hindi) --- i18n/hi.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/hi.json b/i18n/hi.json index a248e828..0cd2787a 100644 --- a/i18n/hi.json +++ b/i18n/hi.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From c0207d00a2f7b6b42197e5eef32eab621cf7d32c Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:04 +0200 Subject: [PATCH 093/223] New translations en.json (Chinese Simplified) --- i18n/zh.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/zh.json b/i18n/zh.json index 2e1dc12b..417dc52c 100644 --- a/i18n/zh.json +++ b/i18n/zh.json @@ -184,5 +184,6 @@ "Close": "关闭", "Encrypted note on PrivateBin": "PrivateBin上的加密笔记", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "访问这个链接来查看该笔记。 将这个URL发送给任何人即可允许其访问该笔记。", - "URL shortener may expose your decrypt key in URL.": "URL 缩短可能会暴露您在 URL 中的解密密钥。" + "URL shortener may expose your decrypt key in URL.": "URL 缩短可能会暴露您在 URL 中的解密密钥。", + "Save paste": "Save paste" } From dd4633ff8f8422e8eda9aee121b018a144127ea7 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:05 +0200 Subject: [PATCH 094/223] New translations en.json (Ukrainian) --- i18n/uk.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/uk.json b/i18n/uk.json index 2808c712..1916a244 100644 --- a/i18n/uk.json +++ b/i18n/uk.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 9bd04c55c94b090fb01087fbc5f0a0e459ec96e9 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:06 +0200 Subject: [PATCH 095/223] New translations en.json (Turkish) --- i18n/tr.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/tr.json b/i18n/tr.json index daedf8f8..edb89db5 100644 --- a/i18n/tr.json +++ b/i18n/tr.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 45b3ec4ac6207ff6bccb08664c0f8a8e0cd66ba2 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:07 +0200 Subject: [PATCH 096/223] New translations en.json (Swedish) --- i18n/sv.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/sv.json b/i18n/sv.json index e0859497..f2286e02 100644 --- a/i18n/sv.json +++ b/i18n/sv.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 56d993ca8297bd678087a2adc7ceb22a399aa7f9 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:08 +0200 Subject: [PATCH 097/223] New translations en.json (Slovenian) --- i18n/sl.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/sl.json b/i18n/sl.json index 51b9caa4..c4bb0cb7 100644 --- a/i18n/sl.json +++ b/i18n/sl.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From c7a86ebd5cb45a13207776a97e117d180680fcf6 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:09 +0200 Subject: [PATCH 098/223] New translations en.json (Russian) --- i18n/ru.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/ru.json b/i18n/ru.json index b697f700..1c990431 100644 --- a/i18n/ru.json +++ b/i18n/ru.json @@ -184,5 +184,6 @@ "Close": "Закрыть", "Encrypted note on PrivateBin": "Зашифрованная запись на PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Посетите эту ссылку чтобы просмотреть запись. Передача ссылки кому либо позволит им получить доступ к записи тоже.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 39867d81513f0de129e894b98b5307b03b28941a Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:10 +0200 Subject: [PATCH 099/223] New translations en.json (Portuguese) --- i18n/pt.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/pt.json b/i18n/pt.json index 60492078..0f6c1333 100644 --- a/i18n/pt.json +++ b/i18n/pt.json @@ -184,5 +184,6 @@ "Close": "Fechar", "Encrypted note on PrivateBin": "Nota criptografada no PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visite esse link para ver a nota. Dar a URL para qualquer um permite que eles também acessem a nota.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 3e4def20690d45b30b226e29c8825fc0d4af80b1 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:11 +0200 Subject: [PATCH 100/223] New translations en.json (Polish) --- i18n/pl.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/pl.json b/i18n/pl.json index c18ad227..4b4a67be 100644 --- a/i18n/pl.json +++ b/i18n/pl.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 0887f567ab21380e7758c69298114fe6b85d233c Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:12 +0200 Subject: [PATCH 101/223] New translations en.json (Norwegian) --- i18n/no.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/no.json b/i18n/no.json index ac6e369c..62764bf0 100644 --- a/i18n/no.json +++ b/i18n/no.json @@ -184,5 +184,6 @@ "Close": "Steng", "Encrypted note on PrivateBin": "Kryptert notat på PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besøk denne lenken for å se notatet. Hvis lenken deles med andre, vil de også kunne se notatet.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 48916d5df7f6cb809f6ba59f6e83bb8393601b8d Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:13 +0200 Subject: [PATCH 102/223] New translations en.json (Lithuanian) --- i18n/lt.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/lt.json b/i18n/lt.json index 7ef45bf4..bc287bc5 100644 --- a/i18n/lt.json +++ b/i18n/lt.json @@ -184,5 +184,6 @@ "Close": "Užverti", "Encrypted note on PrivateBin": "Šifruoti užrašai ties PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Norėdami matyti užrašus, aplankykite šį tinklalapį. Pasidalinus šiuo URL adresu su kitais žmonėmis, jiems taip pat bus leidžiama prieiga prie šių užrašų.", - "URL shortener may expose your decrypt key in URL.": "URL trumpinimo įrankis gali atskleisti URL adrese jūsų iššifravimo raktą." + "URL shortener may expose your decrypt key in URL.": "URL trumpinimo įrankis gali atskleisti URL adrese jūsų iššifravimo raktą.", + "Save paste": "Save paste" } From 2bc7e8e38f5feb75948e53066ef5f48bb2e9f51b Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:14 +0200 Subject: [PATCH 103/223] New translations en.json (Catalan) --- i18n/ca.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/ca.json b/i18n/ca.json index a4e6d3fd..a6936bed 100644 --- a/i18n/ca.json +++ b/i18n/ca.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 6b5e7c1b49b951f527f20f72a9a9811fafa41048 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:15 +0200 Subject: [PATCH 104/223] New translations en.json (Kurdish) --- i18n/ku.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/ku.json b/i18n/ku.json index 0ff29acb..ae72ebd8 100644 --- a/i18n/ku.json +++ b/i18n/ku.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 492cdc99269ed47233a3b6ee2b49c6e7946b14b3 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:17 +0200 Subject: [PATCH 105/223] New translations en.json (Japanese) --- i18n/ja.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/ja.json b/i18n/ja.json index bf4f7cad..807a38c0 100644 --- a/i18n/ja.json +++ b/i18n/ja.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 926fab30e9ebd45682576e4c94ec188e65737c44 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:18 +0200 Subject: [PATCH 106/223] New translations en.json (Italian) --- i18n/it.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/it.json b/i18n/it.json index 81b11a83..bda7a1d5 100644 --- a/i18n/it.json +++ b/i18n/it.json @@ -184,5 +184,6 @@ "Close": "Chiudi", "Encrypted note on PrivateBin": "Nota crittografata su PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visita questo collegamento per vedere la nota. Dare l'URL a chiunque consente anche a loro di accedere alla nota.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 4514f1f3a459573a21cce0a01ee7f8360febd3ce Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:19 +0200 Subject: [PATCH 107/223] New translations en.json (Hungarian) --- i18n/hu.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/hu.json b/i18n/hu.json index b8708367..1cff1a6f 100644 --- a/i18n/hu.json +++ b/i18n/hu.json @@ -184,5 +184,6 @@ "Close": "Bezárás", "Encrypted note on PrivateBin": "Titkosított jegyzet a PrivateBinen", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Látogasd meg ezt a hivatkozást a bejegyzés megtekintéséhez. Ha mások számára is megadod ezt a linket, azzal hozzáférnek ők is.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From db0db4ebffddb188a657a2060f089916a6d97a2f Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:20 +0200 Subject: [PATCH 108/223] New translations en.json (Hebrew) --- i18n/he.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/he.json b/i18n/he.json index 206587b5..046874e2 100644 --- a/i18n/he.json +++ b/i18n/he.json @@ -184,5 +184,6 @@ "Close": "סגירה", "Encrypted note on PrivateBin": "הערה מוצפנת ב־PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "נא לבקר בקישור כדי לצפות בהערה. מסירת הקישור לאנשים כלשהם תאפשר גם להם לגשת להערה.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 67fd327df425d8b79a66aba66d111062e5d1e141 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:21 +0200 Subject: [PATCH 109/223] New translations en.json (Greek) --- i18n/el.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/el.json b/i18n/el.json index 6fd45e41..6e33978d 100644 --- a/i18n/el.json +++ b/i18n/el.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 982a4f957c0bde89fe1ea6d2f4360859821dfe9f Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:22 +0200 Subject: [PATCH 110/223] New translations en.json (German) --- i18n/de.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/de.json b/i18n/de.json index dd8a48a7..b0991d8a 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -184,5 +184,6 @@ "Close": "Schliessen", "Encrypted note on PrivateBin": "Verschlüsselte Notiz auf PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besuche diese Verknüpfung um das Dokument zu sehen. Wird die URL an eine andere Person gegeben, so kann diese Person ebenfalls auf dieses Dokument zugreifen.", - "URL shortener may expose your decrypt key in URL.": "Der URL-Verkürzer kann den Schlüssel in der URL enthüllen." + "URL shortener may expose your decrypt key in URL.": "Der URL-Verkürzer kann den Schlüssel in der URL enthüllen.", + "Save paste": "Save paste" } From 63d20330b4ea28a3dae42d805ffabfd482c18c21 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:23 +0200 Subject: [PATCH 111/223] New translations en.json (Czech) --- i18n/cs.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/cs.json b/i18n/cs.json index 1a6249ad..34ef19a8 100644 --- a/i18n/cs.json +++ b/i18n/cs.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 4a73afa057441e6e74c2d5e4fbb9452a56e71302 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:24 +0200 Subject: [PATCH 112/223] New translations en.json (Bulgarian) --- i18n/bg.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/bg.json b/i18n/bg.json index 8ddd1f54..4a025389 100644 --- a/i18n/bg.json +++ b/i18n/bg.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From cd1b0e0a50607d2239b5e6113cd254f3694027a8 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:25 +0200 Subject: [PATCH 113/223] New translations en.json (Arabic) --- i18n/ar.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/ar.json b/i18n/ar.json index 8b8e1aef..ddca0d62 100644 --- a/i18n/ar.json +++ b/i18n/ar.json @@ -184,5 +184,6 @@ "Close": "Close", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 14ff704b28c6619e5a1b66a5f17085f81aeaa74d Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:26 +0200 Subject: [PATCH 114/223] New translations en.json (Spanish) --- i18n/es.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/es.json b/i18n/es.json index 4e93e669..73f60556 100644 --- a/i18n/es.json +++ b/i18n/es.json @@ -184,5 +184,6 @@ "Close": "Cerrar", "Encrypted note on PrivateBin": "Nota cifrada en PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visite este enlace para ver la nota. Dar la URL a cualquier persona también les permite acceder a la nota.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL." + "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", + "Save paste": "Save paste" } From 30228cc33c68d985fc1a7cab6a4476abfad814f9 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:27 +0200 Subject: [PATCH 115/223] New translations en.json (French) --- i18n/fr.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/fr.json b/i18n/fr.json index 409d4499..03d60856 100644 --- a/i18n/fr.json +++ b/i18n/fr.json @@ -184,5 +184,6 @@ "Close": "Fermer", "Encrypted note on PrivateBin": "Message chiffré sur PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visiter ce lien pour voir la note. Donner l'URL à une autre personne lui permet également d'accéder à la note.", - "URL shortener may expose your decrypt key in URL.": "Raccourcir l'URL peut exposer votre clé de déchiffrement dans l'URL." + "URL shortener may expose your decrypt key in URL.": "Raccourcir l'URL peut exposer votre clé de déchiffrement dans l'URL.", + "Save paste": "Save paste" } From 993abd746e0b774b868e22ce3452b2a5c9e52403 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:04:28 +0200 Subject: [PATCH 116/223] New translations en.json (Estonian) --- i18n/et.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i18n/et.json b/i18n/et.json index 877c732e..b364df26 100644 --- a/i18n/et.json +++ b/i18n/et.json @@ -184,5 +184,6 @@ "Close": "Sulge", "Encrypted note on PrivateBin": "Krüpteeritud kiri PrivateBin-is", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kirja nägemiseks külasta seda linki. Teistele URL-i andmine lubab ka neil ligi pääseda kirjale.", - "URL shortener may expose your decrypt key in URL.": "URL-i lühendaja võib paljastada sinu dekrüpteerimisvõtme URL-is." + "URL shortener may expose your decrypt key in URL.": "URL-i lühendaja võib paljastada sinu dekrüpteerimisvõtme URL-is.", + "Save paste": "Save paste" } From fcb6422663954797d7344f045c30a45002b0d98a Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 18 Apr 2021 21:05:32 +0200 Subject: [PATCH 117/223] re-adding CSP directive sandbox allow-forms, it is needed for the password input form to work on the JS side --- cfg/conf.sample.php | 2 +- lib/Configuration.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php index a7b76a11..ceddad62 100644 --- a/cfg/conf.sample.php +++ b/cfg/conf.sample.php @@ -87,7 +87,7 @@ languageselection = false ; async functions and display an error if not and for Chrome to enable ; webassembly support (used for zlib compression). You can remove it if Chrome ; doesn't need to be supported and old browsers don't need to be warned. -; cspheader = "default-src 'none'; base-uri 'self'; form-action 'none'; manifest-src 'self'; connect-src * blob:; script-src 'self' 'unsafe-eval' resource:; style-src 'self'; font-src 'self'; img-src 'self' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-popups allow-modals allow-downloads" +; cspheader = "default-src 'none'; base-uri 'self'; form-action 'none'; manifest-src 'self'; connect-src * blob:; script-src 'self' 'unsafe-eval' resource:; style-src 'self'; font-src 'self'; img-src 'self' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads" ; stay compatible with PrivateBin Alpha 0.19, less secure ; if enabled will use base64.js version 1.7 instead of 2.1.9 and sha1 instead of diff --git a/lib/Configuration.php b/lib/Configuration.php index a99c3f9e..e509d983 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -55,7 +55,7 @@ class Configuration 'urlshortener' => '', 'qrcode' => true, 'icon' => 'identicon', - 'cspheader' => 'default-src \'none\'; base-uri \'self\'; form-action \'none\'; manifest-src \'self\'; connect-src * blob:; script-src \'self\' \'unsafe-eval\' resource:; style-src \'self\'; font-src \'self\'; img-src \'self\' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-popups allow-modals allow-downloads', + 'cspheader' => 'default-src \'none\'; base-uri \'self\'; form-action \'none\'; manifest-src \'self\'; connect-src * blob:; script-src \'self\' \'unsafe-eval\' resource:; style-src \'self\'; font-src \'self\'; img-src \'self\' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads', 'zerobincompatibility' => false, 'httpwarning' => true, 'compression' => 'zlib', From 010f9db274f53e9ea4ed618128223abfac4c78ed Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 22:00:35 +0200 Subject: [PATCH 118/223] New translations en.json (French) --- i18n/fr.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/fr.json b/i18n/fr.json index 03d60856..0e14d799 100644 --- a/i18n/fr.json +++ b/i18n/fr.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Message chiffré sur PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visiter ce lien pour voir la note. Donner l'URL à une autre personne lui permet également d'accéder à la note.", "URL shortener may expose your decrypt key in URL.": "Raccourcir l'URL peut exposer votre clé de déchiffrement dans l'URL.", - "Save paste": "Save paste" + "Save paste": "Sauver le paste" } From 53e23b7422d08d9e5755fa6c83e995eaf639b866 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 22:00:36 +0200 Subject: [PATCH 119/223] New translations en.json (Spanish) --- i18n/es.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i18n/es.json b/i18n/es.json index 73f60556..5aa2b380 100644 --- a/i18n/es.json +++ b/i18n/es.json @@ -184,6 +184,6 @@ "Close": "Cerrar", "Encrypted note on PrivateBin": "Nota cifrada en PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visite este enlace para ver la nota. Dar la URL a cualquier persona también les permite acceder a la nota.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Save paste": "Save paste" + "URL shortener may expose your decrypt key in URL.": "El acortador de URL puede exponer su clave de descifrado en el URL.", + "Save paste": "Guardar \"paste\"" } From d0c6ab224fb91ae2a65609b65b1f2e0c888e978b Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 22:00:37 +0200 Subject: [PATCH 120/223] New translations en.json (German) --- i18n/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/de.json b/i18n/de.json index b0991d8a..7bc38d14 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Verschlüsselte Notiz auf PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besuche diese Verknüpfung um das Dokument zu sehen. Wird die URL an eine andere Person gegeben, so kann diese Person ebenfalls auf dieses Dokument zugreifen.", "URL shortener may expose your decrypt key in URL.": "Der URL-Verkürzer kann den Schlüssel in der URL enthüllen.", - "Save paste": "Save paste" + "Save paste": "Text speichern" } From 1b8351fef9d744b42bdf64d88f2436028adf18ff Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 18 Apr 2021 22:00:38 +0200 Subject: [PATCH 121/223] New translations en.json (Italian) --- i18n/it.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i18n/it.json b/i18n/it.json index bda7a1d5..659816e4 100644 --- a/i18n/it.json +++ b/i18n/it.json @@ -184,6 +184,6 @@ "Close": "Chiudi", "Encrypted note on PrivateBin": "Nota crittografata su PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visita questo collegamento per vedere la nota. Dare l'URL a chiunque consente anche a loro di accedere alla nota.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Save paste": "Save paste" + "URL shortener may expose your decrypt key in URL.": "URL shortener può esporre la tua chiave decrittografata nell'URL.", + "Save paste": "Salva il messagio" } From b47b8cf05088fe28e3424d7555219e9fe7e5481a Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Tue, 20 Apr 2021 12:05:08 +0200 Subject: [PATCH 122/223] New translations en.json (Russian) --- i18n/ru.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i18n/ru.json b/i18n/ru.json index 1c990431..b6f95867 100644 --- a/i18n/ru.json +++ b/i18n/ru.json @@ -184,6 +184,6 @@ "Close": "Закрыть", "Encrypted note on PrivateBin": "Зашифрованная запись на PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Посетите эту ссылку чтобы просмотреть запись. Передача ссылки кому либо позволит им получить доступ к записи тоже.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Save paste": "Save paste" + "URL shortener may expose your decrypt key in URL.": "Сервис сокращения ссылок может получить ваш ключ расшифровки из ссылки.", + "Save paste": "Сохранить запись" } From 4c329be95f808321b99867c2d22f410ad22a860c Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Tue, 20 Apr 2021 18:54:09 +0200 Subject: [PATCH 123/223] New translations en.json (Norwegian) --- i18n/no.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i18n/no.json b/i18n/no.json index 62764bf0..b0ca95a0 100644 --- a/i18n/no.json +++ b/i18n/no.json @@ -184,6 +184,6 @@ "Close": "Steng", "Encrypted note on PrivateBin": "Kryptert notat på PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Besøk denne lenken for å se notatet. Hvis lenken deles med andre, vil de også kunne se notatet.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Save paste": "Save paste" + "URL shortener may expose your decrypt key in URL.": "URL forkorter kan avsløre dekrypteringsnøkkelen.", + "Save paste": "Lagre utklipp" } From 4d3a2ae946c77ead9820e43bce6870a4c587a065 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Thu, 22 Apr 2021 03:46:58 +0200 Subject: [PATCH 124/223] New translations en.json (Chinese Simplified) --- i18n/zh.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/zh.json b/i18n/zh.json index 417dc52c..4156e54f 100644 --- a/i18n/zh.json +++ b/i18n/zh.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "PrivateBin上的加密笔记", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "访问这个链接来查看该笔记。 将这个URL发送给任何人即可允许其访问该笔记。", "URL shortener may expose your decrypt key in URL.": "URL 缩短可能会暴露您在 URL 中的解密密钥。", - "Save paste": "Save paste" + "Save paste": "保存内容" } From 0a9cd0545365e67101b2ae245e03716032f2ee02 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Wed, 28 Apr 2021 13:52:52 +0200 Subject: [PATCH 125/223] New translations en.json (Estonian) --- i18n/et.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/et.json b/i18n/et.json index b364df26..9ab2840c 100644 --- a/i18n/et.json +++ b/i18n/et.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Krüpteeritud kiri PrivateBin-is", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kirja nägemiseks külasta seda linki. Teistele URL-i andmine lubab ka neil ligi pääseda kirjale.", "URL shortener may expose your decrypt key in URL.": "URL-i lühendaja võib paljastada sinu dekrüpteerimisvõtme URL-is.", - "Save paste": "Save paste" + "Save paste": "Salvesta kleebe" } From 17c1284ccfc104692d4b9a4e62fa1ee57cf32f7f Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Mon, 3 May 2021 16:32:06 +0200 Subject: [PATCH 126/223] New translations en.json (Chinese Simplified) --- i18n/zh.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/i18n/zh.json b/i18n/zh.json index 4156e54f..06428d89 100644 --- a/i18n/zh.json +++ b/i18n/zh.json @@ -1,12 +1,12 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s是一个极简、开源、对粘贴内容毫不知情的在线粘贴板,数据%s在浏览器内%s进行AES-256加密。", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s是一个极简、开源、对粘贴内容毫不知情的在线粘贴板,数据%s在浏览器内%s进行AES-256加密和解密。", "More information on the project page.": "更多信息请查看项目主页。", "Because ignorance is bliss": "因为无知是福", "en": "zh", - "Paste does not exist, has expired or has been deleted.": "粘贴内容不存在,已过期或已被删除。", - "%s requires php %s or above to work. Sorry.": "%s需要PHP %s及以上版本来工作,抱歉。", - "%s requires configuration section [%s] to be present in configuration file.": "%s需要设置配置文件中 [%s] 部分。", + "Paste does not exist, has expired or has been deleted.": "粘贴内容不存在、已过期或已被删除。", + "%s requires php %s or above to work. Sorry.": "抱歉,%s需要PHP %s及以上版本才能运行。", + "%s requires configuration section [%s] to be present in configuration file.": "%s需要设置配置文件中的 [%s] 部分。", "Please wait %d seconds between each post.": [ "每 %d 秒只能粘贴一次。", "每 %d 秒只能粘贴一次。", From e6def62581e8a04e7c255b709c5b05d49f52b53e Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Mon, 3 May 2021 17:39:47 +0200 Subject: [PATCH 127/223] New translations en.json (Chinese Simplified) --- i18n/zh.json | 58 ++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/i18n/zh.json b/i18n/zh.json index 06428d89..2ab63bf4 100644 --- a/i18n/zh.json +++ b/i18n/zh.json @@ -1,29 +1,29 @@ { "PrivateBin": "PrivateBin", - "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s是一个极简、开源、对粘贴内容毫不知情的在线粘贴板,数据%s在浏览器内%s进行AES-256加密和解密。", + "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s 是一个极简、开源、对粘贴内容毫不知情的在线粘贴板,数据%s在浏览器内%s进行 AES-256 加密和解密。", "More information on the project page.": "更多信息请查看项目主页。", "Because ignorance is bliss": "因为无知是福", "en": "zh", "Paste does not exist, has expired or has been deleted.": "粘贴内容不存在、已过期或已被删除。", - "%s requires php %s or above to work. Sorry.": "抱歉,%s需要PHP %s及以上版本才能运行。", - "%s requires configuration section [%s] to be present in configuration file.": "%s需要设置配置文件中的 [%s] 部分。", + "%s requires php %s or above to work. Sorry.": "抱歉,%s 需要 PHP %s 及以上版本才能运行。", + "%s requires configuration section [%s] to be present in configuration file.": "%s 需要设置配置文件中的 [%s] 部分。", "Please wait %d seconds between each post.": [ "每 %d 秒只能粘贴一次。", "每 %d 秒只能粘贴一次。", "每 %d 秒只能粘贴一次。", "每 %d 秒只能粘贴一次。" ], - "Paste is limited to %s of encrypted data.": "粘贴受限于 %s 加密数据。", + "Paste is limited to %s of encrypted data.": "对于加密数据,上限为 %s。", "Invalid data.": "无效的数据。", "You are unlucky. Try again.": "请再试一次。", "Error saving comment. Sorry.": "保存评论时出现错误,抱歉。", "Error saving paste. Sorry.": "保存粘贴内容时出现错误,抱歉。", - "Invalid paste ID.": "无效的ID。", + "Invalid paste ID.": "无效的 ID。", "Paste is not of burn-after-reading type.": "粘贴内容不是阅后即焚类型。", "Wrong deletion token. Paste was not deleted.": "错误的删除token,粘贴内容没有被删除。", "Paste was properly deleted.": "粘贴内容已被正确删除。", - "JavaScript is required for %s to work. Sorry for the inconvenience.": "%s需要JavaScript来进行加解密。 给你带来的不便敬请谅解。", - "%s requires a modern browser to work.": "%s需要在现代浏览器上工作。", + "JavaScript is required for %s to work. Sorry for the inconvenience.": "%s 需要 JavaScript 来进行加解密。 给你带来的不便敬请谅解。", + "%s requires a modern browser to work.": "%s 需要在现代浏览器上工作。", "New": "新建", "Send": "送出", "Clone": "复制", @@ -112,7 +112,7 @@ "Could not decrypt data (Wrong key?)": "无法解密数据(密钥错误?)", "Could not delete the paste, it was not stored in burn after reading mode.": "无法删除此粘贴内容,它没有以阅后即焚模式保存。", "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "看!仔!细!了!不要关闭窗口,否则你再也见不到这条消息了。", - "Could not decrypt comment; Wrong key?": "无法解密评论; 密钥错误?", + "Could not decrypt comment; Wrong key?": "无法解密评论;密钥错误?", "Reply": "回复", "Anonymous": "匿名", "Avatar generated from IP address": "由IP生成的头像", @@ -126,7 +126,7 @@ "server error or not responding": "服务器错误或无回应", "Could not post comment: %s": "无法发送评论: %s", "Sending paste…": "粘贴内容提交中…", - "Your paste is %s (Hit [Ctrl]+[c] to copy)": "您粘贴内容的链接是%s (按下 [Ctrl]+[c] 以复制)", + "Your paste is %s (Hit [Ctrl]+[c] to copy)": "您粘贴内容的链接是 %s (按下 [Ctrl]+[C] 以复制)", "Delete data": "删除数据", "Could not create paste: %s": "无法创建粘贴:%s", "Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)": "无法解密粘贴:URL中缺失解密密钥(是否使用了重定向或者短链接导致密钥丢失?)", @@ -144,46 +144,46 @@ "Source Code": "源代码", "Markdown": "Markdown", "Download attachment": "下载附件", - "Cloned: '%s'": "副本: '%s'", - "The cloned file '%s' was attached to this paste.": "副本 '%s' 已附加到此粘贴内容。", + "Cloned: '%s'": "副本:“%s”", + "The cloned file '%s' was attached to this paste.": "副本“%s”已附加到此粘贴内容。", "Attach a file": "添加一个附件", "alternatively drag & drop a file or paste an image from the clipboard": "拖放文件或从剪贴板粘贴图片", - "File too large, to display a preview. Please download the attachment.": "文件过大。要显示预览,请下载附件。", + "File too large, to display a preview. Please download the attachment.": "文件过大,无法显示预览。请下载附件。", "Remove attachment": "移除附件", - "Your browser does not support uploading encrypted files. Please use a newer browser.": "您的浏览器不支持上传加密的文件,请使用更新的浏览器。", + "Your browser does not support uploading encrypted files. Please use a newer browser.": "您的浏览器不支持上传加密的文件,请使用新版本的浏览器。", "Invalid attachment.": "无效的附件", "Options": "选项", "Shorten URL": "缩短链接", "Editor": "编辑", "Preview": "预览", - "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.": "%s 的 PATH 变量必须结束于 \"%s\"。 请修改你的 index.php 中的 PATH 变量。", + "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.": "%s 的 PATH 变量必须结束于“%s”。 请修改你的 index.php 中的 PATH 变量。", "Decrypt": "解密", "Enter password": "输入密码", "Loading…": "载入中…", "Decrypting paste…": "正在解密", "Preparing new paste…": "正在准备新的粘贴内容", - "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "如果这个消息一直存在,请参考 这里的 FAQ (英文版)进行故障排除。", - "+++ no paste text +++": "+++ 没有粘贴内容 +++", + "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "如果此消息一直存在,请参考 这里的 FAQ(英文版)排除故障。", + "+++ no paste text +++": "+++ 无粘贴内容 +++", "Could not get paste data: %s": "无法获取粘贴数据:%s", "QR code": "二维码", - "This website is using an insecure HTTP connection! Please use it only for testing.": "该网站使用了不安全的HTTP连接! 请仅将其用于测试。", - "For more information see this FAQ entry.": "有关更多信息,请参阅此常见问题解答。", - "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.": "您的浏览器可能需要HTTPS连接才能支持WebCrypto API。 尝试切换到HTTPS 。", - "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.": "您的浏览器不支持用于zlib压缩的WebAssembly。 您可以创建未压缩的文档,但不能读取压缩的文档。", + "This website is using an insecure HTTP connection! Please use it only for testing.": "该网站使用了不安全的 HTTP 连接!请仅将其用于测试。", + "For more information see this FAQ entry.": "有关更多信息,请参阅此常见问题解答。", + "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.": "您的浏览器可能需要 HTTPS 连接才能支持 WebCrypto API。 尝试切换到 HTTPS。", + "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.": "您的浏览器不支持用于 zlib 压缩的 WebAssembly。 您可以创建未压缩的文档,但不能读取压缩的文档。", "waiting on user to provide a password": "请输入密码", - "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.": "无法解密数据。 您输入了错误的密码吗? 点顶部的按钮重试。", + "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.": "无法解密数据。您是否输入了错误的密码?按顶部的按钮重试。", "Retry": "重试", "Showing raw text…": "显示原始文字…", - "Notice:": "注意:", + "Notice:": "注意:", "This link will expire after %s.": "这个链接将会在 %s 过期。", - "This link can only be accessed once, do not use back or refresh button in your browser.": "这个链接只能被访问一次,请勿使用浏览器中的返回和刷新按钮。", - "Link:": "链接地址:", - "Recipient may become aware of your timezone, convert time to UTC?": "收件人可能会知道您的时区,将时间转换为UTC?", + "This link can only be accessed once, do not use back or refresh button in your browser.": "此链接只能被访问一次,请勿使用浏览器中的返回和刷新按钮。", + "Link:": "链接:", + "Recipient may become aware of your timezone, convert time to UTC?": "收件人可能会知道您的时区,将时间转换为 UTC?", "Use Current Timezone": "使用当前时区", - "Convert To UTC": "转换为UTC", + "Convert To UTC": "转换为 UTC", "Close": "关闭", - "Encrypted note on PrivateBin": "PrivateBin上的加密笔记", - "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "访问这个链接来查看该笔记。 将这个URL发送给任何人即可允许其访问该笔记。", - "URL shortener may expose your decrypt key in URL.": "URL 缩短可能会暴露您在 URL 中的解密密钥。", + "Encrypted note on PrivateBin": "PrivateBin 上的加密笔记", + "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "访问此链接来查看该笔记。将此 URL 发送给任何人即可允许其访问该笔记。", + "URL shortener may expose your decrypt key in URL.": "短链接服务可能会暴露您在 URL 中的解密密钥。", "Save paste": "保存内容" } From 377d7d565bad82e2d987c61beec59dd42ef965b2 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Tue, 4 May 2021 00:29:57 +0200 Subject: [PATCH 128/223] New translations en.json (Indonesian) --- i18n/id.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/id.json b/i18n/id.json index b28af88c..ea2c80ac 100644 --- a/i18n/id.json +++ b/i18n/id.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Catatan ter-ekrip di PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Kunjungi tautan ini untuk melihat catatan. Memberikan alamat URL pada siapapun juga, akan mengizinkan mereka untuk mengakses catatan, so pasti gitu loh Kaka.", "URL shortener may expose your decrypt key in URL.": "Pemendek URL mungkin akan menampakkan kunci dekrip Anda dalam URL.", - "Save paste": "Save paste" + "Save paste": "Simpan paste" } From 3f92d4c0388ae49bfb95c24727f08dedc7d6e2cf Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Tue, 4 May 2021 01:30:38 +0200 Subject: [PATCH 129/223] New translations en.json (Indonesian) --- i18n/id.json | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/i18n/id.json b/i18n/id.json index ea2c80ac..c580ca6d 100644 --- a/i18n/id.json +++ b/i18n/id.json @@ -9,9 +9,9 @@ "%s requires configuration section [%s] to be present in configuration file.": "%s membutuhkan bagian konfigurasi [%s] untuk ada di file konfigurasi.", "Please wait %d seconds between each post.": [ "Silahkan menunggu %d detik antara masing-masing postingan. (tunggal)", - "Silahkan menunggu %d detik antara masing-masing postingan. (jamak ke-1)", - "Silahkan menunggu %d detik antara masing-masing postingan. (jamak ke-2)", - "Silahkan menunggu %d detik antara masing-masing postingan. (jamak ke-3)" + "Silahkan menunggu %d detik antara masing-masing postingan.", + "Silahkan menunggu %d detik antara masing-masing postingan.", + "Silahkan menunggu %d detik antara masing-masing postingan." ], "Paste is limited to %s of encrypted data.": "Paste dibatasi sampai %s dari data yang dienskripsi.", "Invalid data.": "Data tidak valid.", @@ -36,27 +36,27 @@ "Toggle navigation": "Alihkan navigasi", "%d seconds": [ "%d detik (tunggal)", - "%d detik (jamak ke-1)", - "%d detik (jamak ke-2)", - "%d detik (jamak ke-3)" + "%d detik", + "%d detik", + "%d detik" ], "%d minutes": [ "%d menit (tunggal)", - "%d menit (jamak ke-1)", - "%d menit (jamak ke-2)", - "%d menit (jamak ke-3)" + "%d menit", + "%d menit", + "%d menit" ], "%d hours": [ "%d jam (tunggal)", - "%d jam (jamak ke-1)", - "%d jam (jamak ke-2)", - "%d jam (jamak ke-3)" + "%d jam", + "%d jam", + "%d jam" ], "%d days": [ "%d hari (tunggal)", - "%d hari (jamak ke-1)", - "%d hari (jamak ke-2)", - "%d hari (jamak ke-3)" + "%d hari", + "%d hari", + "%d hari" ], "%d weeks": [ "%d minggu (tunggal)", From 7d82c82fd98b4496dac88154b5ed034f5b5276db Mon Sep 17 00:00:00 2001 From: LinQhost Managed hosting Date: Tue, 4 May 2021 10:29:25 +0200 Subject: [PATCH 130/223] Make it possible to exempt ips from the rate-limiter --- cfg/conf.sample.php | 4 ++ composer.json | 5 ++- composer.lock | 70 +++++++++++++++++++++++++++++- lib/Configuration.php | 1 + lib/Persistence/TrafficLimiter.php | 51 ++++++++++++++++++++++ 5 files changed, 128 insertions(+), 3 deletions(-) diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php index e958c88d..0837645b 100644 --- a/cfg/conf.sample.php +++ b/cfg/conf.sample.php @@ -135,6 +135,10 @@ markdown = "Markdown" ; Set this to 0 to disable rate limiting. limit = 10 +; Set ips (v4|v6) which should be exempted for the rate-limit. CIDR also supported. Needed to be comma separated. +; Unset for enabling and invalid values will be ignored +; eg: exemptedIp = '1.2.3.4,10.10.10/24' + ; (optional) if your website runs behind a reverse proxy or load balancer, ; set the HTTP header containing the visitors IP address, i.e. X_FORWARDED_FOR ; header = "X_FORWARDED_FOR" diff --git a/composer.json b/composer.json index 899c863f..ff79af99 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "require" : { "php" : "^5.6.0 || ^7.0 || ^8.0", "paragonie/random_compat" : "2.0.19", - "yzalis/identicon" : "2.0.0" + "yzalis/identicon" : "2.0.0", + "mlocati/ip-lib": "^1.14" }, "require-dev" : { "phpunit/phpunit" : "^4.6 || ^5.0" @@ -39,4 +40,4 @@ "config" : { "autoloader-suffix" : "DontChange" } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 80d2276f..66a9c8a6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,76 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9d110873bf15a6abd66734e8a818134c", + "content-hash": "8138b0e4bb3fcaab9ca4c02bbe35d891", "packages": [ + { + "name": "mlocati/ip-lib", + "version": "1.14.0", + "source": { + "type": "git", + "url": "https://github.com/mlocati/ip-lib.git", + "reference": "882bc0e115970a536b13bcfa59f312783fce08c8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mlocati/ip-lib/zipball/882bc0e115970a536b13bcfa59f312783fce08c8", + "reference": "882bc0e115970a536b13bcfa59f312783fce08c8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "ext-pdo_sqlite": "*", + "phpunit/dbunit": "^1.4 || ^2 || ^3 || ^4", + "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "IPLib\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michele Locati", + "email": "mlocati@gmail.com", + "homepage": "https://github.com/mlocati", + "role": "Author" + } + ], + "description": "Handle IPv4, IPv6 addresses and ranges", + "homepage": "https://github.com/mlocati/ip-lib", + "keywords": [ + "IP", + "address", + "addresses", + "ipv4", + "ipv6", + "manage", + "managing", + "matching", + "network", + "networking", + "range", + "subnet" + ], + "funding": [ + { + "url": "https://github.com/sponsors/mlocati", + "type": "github" + }, + { + "url": "https://paypal.me/mlocati", + "type": "other" + } + ], + "time": "2020-12-31T11:30:02+00:00" + }, { "name": "paragonie/random_compat", "version": "v2.0.19", diff --git a/lib/Configuration.php b/lib/Configuration.php index 2a326caf..133059d3 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -82,6 +82,7 @@ class Configuration 'limit' => 10, 'header' => null, 'dir' => 'data', + 'exemptedIp' => null, ), 'purge' => array( 'limit' => 300, diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index a16cd0b3..31f107ff 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -1,4 +1,5 @@ getKey('limit', 'traffic')); self::setPath($conf->getKey('dir', 'traffic')); + self::setExemptedIp($conf->getKey('exemptedIp', 'traffic')); + if (($option = $conf->getKey('header', 'traffic')) !== null) { $httpHeader = 'HTTP_' . $option; if (array_key_exists($httpHeader, $_SERVER) && !empty($_SERVER[$httpHeader])) { @@ -99,6 +124,32 @@ class TrafficLimiter extends AbstractPersistence if (self::$_limit < 1) { return true; } + + // Check if $_ipKey is exempted from ratelimiting + if (!is_null(self::$_exemptedIp)) { + $exIp_array = explode(",", self::$_exemptedIp); + foreach ($exIp_array as $ipRange) { + // Match $_ipKey to $ipRange and if it matches it will return with a true + $address = \IPLib\Factory::addressFromString($_SERVER[self::$_ipKey]); + $range = \IPLib\Factory::rangeFromString(trim($ipRange)); + // If $range is null something went wrong (possible invalid ip given in config) + if ($range == null) { + $contained = false; + } else { + // Ip-lib does throws and exception when something goes wrong, if so we want to catch it and set contained to false + try { + $contained = $address->matches($range); + } catch (Exception $e) { + // If something is wrong with matching the ip, we set $contained to false + $contained = false; + } + } + // Matches return true! + if ($contained == true) { + return true; + } + } + } $file = 'traffic_limiter.php'; if (self::_exists($file)) { From b21efd8336c12f39bcf07e5ba9d0387ceee9955d Mon Sep 17 00:00:00 2001 From: rodehoed Date: Tue, 4 May 2021 11:01:46 +0200 Subject: [PATCH 131/223] Code quality --- lib/Persistence/TrafficLimiter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 31f107ff..46eddc45 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -62,11 +62,11 @@ class TrafficLimiter extends AbstractPersistence } /** - * set a list of ip(ranges) as array + * set a list of ip(ranges) as string * * @access public * @static - * @param array $exemptedIps + * @param string $exemptedIps */ public static function setExemptedIp($exemptedIp) { @@ -139,7 +139,7 @@ class TrafficLimiter extends AbstractPersistence // Ip-lib does throws and exception when something goes wrong, if so we want to catch it and set contained to false try { $contained = $address->matches($range); - } catch (Exception $e) { + } catch (\Exception $e) { // If something is wrong with matching the ip, we set $contained to false $contained = false; } From 805eb288d92be1716214156af50b69dbf88a0afd Mon Sep 17 00:00:00 2001 From: rodehoed Date: Tue, 4 May 2021 11:14:11 +0200 Subject: [PATCH 132/223] QA --- lib/Persistence/TrafficLimiter.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 46eddc45..06916c59 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -82,7 +82,6 @@ class TrafficLimiter extends AbstractPersistence */ public static function setConfiguration(Configuration $conf) { - self::setLimit($conf->getKey('limit', 'traffic')); self::setPath($conf->getKey('dir', 'traffic')); self::setExemptedIp($conf->getKey('exemptedIp', 'traffic')); @@ -127,11 +126,11 @@ class TrafficLimiter extends AbstractPersistence // Check if $_ipKey is exempted from ratelimiting if (!is_null(self::$_exemptedIp)) { - $exIp_array = explode(",", self::$_exemptedIp); + $exIp_array = explode(',', self::$_exemptedIp); foreach ($exIp_array as $ipRange) { // Match $_ipKey to $ipRange and if it matches it will return with a true $address = \IPLib\Factory::addressFromString($_SERVER[self::$_ipKey]); - $range = \IPLib\Factory::rangeFromString(trim($ipRange)); + $range = \IPLib\Factory::rangeFromString(trim($ipRange)); // If $range is null something went wrong (possible invalid ip given in config) if ($range == null) { $contained = false; From c3ad4a4b4d48946e89785171b83093f3527d5cf5 Mon Sep 17 00:00:00 2001 From: rodehoed Date: Tue, 4 May 2021 11:18:06 +0200 Subject: [PATCH 133/223] QA --- lib/Persistence/TrafficLimiter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 06916c59..005fa5f2 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -30,7 +30,7 @@ class TrafficLimiter extends AbstractPersistence * @var int */ private static $_limit = 10; - + /** * listed ips are exempted from limits, defaults to null * From 4296b43832a59862e7d4abf56e48475ead37c80e Mon Sep 17 00:00:00 2001 From: rodehoed Date: Tue, 4 May 2021 11:19:34 +0200 Subject: [PATCH 134/223] QA --- lib/Persistence/TrafficLimiter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 005fa5f2..ba0ac33e 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -123,7 +123,7 @@ class TrafficLimiter extends AbstractPersistence if (self::$_limit < 1) { return true; } - + // Check if $_ipKey is exempted from ratelimiting if (!is_null(self::$_exemptedIp)) { $exIp_array = explode(',', self::$_exemptedIp); From a806a6455eb4591e55ab6e6e90a4d64aa729f95d Mon Sep 17 00:00:00 2001 From: rodehoed Date: Tue, 4 May 2021 11:20:24 +0200 Subject: [PATCH 135/223] QA --- lib/Configuration.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Configuration.php b/lib/Configuration.php index 133059d3..da62a1d0 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -79,9 +79,9 @@ class Configuration 'markdown' => 'Markdown', ), 'traffic' => array( - 'limit' => 10, - 'header' => null, - 'dir' => 'data', + 'limit' => 10, + 'header' => null, + 'dir' => 'data', 'exemptedIp' => null, ), 'purge' => array( From 12aa325494fb3cca04c4ece52b317ab043036171 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Tue, 4 May 2021 13:39:44 +0200 Subject: [PATCH 136/223] New translations en.json (Russian) --- i18n/ru.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/ru.json b/i18n/ru.json index b6f95867..a9112330 100644 --- a/i18n/ru.json +++ b/i18n/ru.json @@ -77,7 +77,7 @@ "%d лет" ], "Never": "Никогда", - "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "Примечание: Этот сервис тестовый: Данные могут быть удалены в любое время. Котята умрут, если вы будете злоупотреблять серсисом.", + "Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.": "Примечание: Этот сервис тестовый: Данные могут быть удалены в любое время. Котята умрут, если вы будете злоупотреблять сервисом.", "This document will expire in %d seconds.": [ "Документ будет удален через %d секунду.", "Документ будет удален через %d секунды.", From 2b0ebdb6c70b68c2127129dc45aebeac7083d0df Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Tue, 4 May 2021 19:43:08 +0200 Subject: [PATCH 137/223] New translations en.json (Turkish) --- i18n/tr.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/i18n/tr.json b/i18n/tr.json index edb89db5..a543575d 100644 --- a/i18n/tr.json +++ b/i18n/tr.json @@ -14,8 +14,8 @@ "Please wait %d seconds between each post. (3rd plural)" ], "Paste is limited to %s of encrypted data.": "Paste is limited to %s of encrypted data.", - "Invalid data.": "Invalid data.", - "You are unlucky. Try again.": "You are unlucky. Try again.", + "Invalid data.": "Geçersiz veri.", + "You are unlucky. Try again.": "Lütfen tekrar deneyiniz.", "Error saving comment. Sorry.": "Error saving comment. Sorry.", "Error saving paste. Sorry.": "Error saving paste. Sorry.", "Invalid paste ID.": "Invalid paste ID.", @@ -24,8 +24,8 @@ "Paste was properly deleted.": "Paste was properly deleted.", "JavaScript is required for %s to work. Sorry for the inconvenience.": "JavaScript is required for %s to work. Sorry for the inconvenience.", "%s requires a modern browser to work.": "%s requires a modern browser to work.", - "New": "New", - "Send": "Send", + "New": "Yeni", + "Send": "Gönder", "Clone": "Clone", "Raw text": "Raw text", "Expires": "Expires", From e572e9c79c5258d7167fdfa797619f2831575ba2 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Tue, 4 May 2021 20:48:34 +0200 Subject: [PATCH 138/223] New translations en.json (Turkish) --- i18n/tr.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/i18n/tr.json b/i18n/tr.json index a543575d..5f3c6c0a 100644 --- a/i18n/tr.json +++ b/i18n/tr.json @@ -1,8 +1,8 @@ { "PrivateBin": "PrivateBin", "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.": "%s is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted %sin the browser%s using 256 bits AES.", - "More information on the project page.": "More information on the project page.", - "Because ignorance is bliss": "Because ignorance is bliss", + "More information on the project page.": "Daha fazla bilgi için proje sayfası'na göz atabilirsiniz.", + "Because ignorance is bliss": "Çünkü, cehalet mutluluktur", "en": "tr", "Paste does not exist, has expired or has been deleted.": "Paste does not exist, has expired or has been deleted.", "%s requires php %s or above to work. Sorry.": "%s requires php %s or above to work. Sorry.", @@ -59,8 +59,8 @@ "%d days (3rd plural)" ], "%d weeks": [ - "%d week (singular)", - "%d weeks (1st plural)", + "%d hafta (tekil)", + "%d haftalar (çoğul)", "%d weeks (2nd plural)", "%d weeks (3rd plural)" ], From 89bdc92451184420bea4cc6b42282f2875676c93 Mon Sep 17 00:00:00 2001 From: Rodehoed Date: Thu, 6 May 2021 12:13:03 +0200 Subject: [PATCH 139/223] Put the ip-matching function in a private function --- lib/Persistence/TrafficLimiter.php | 54 ++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index ba0ac33e..cbe6adf3 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -107,6 +107,39 @@ class TrafficLimiter extends AbstractPersistence return hash_hmac($algo, $_SERVER[self::$_ipKey], ServerSalt::get()); } + /** + * Validate $_ipKey against configured ipranges. If matched ratelimiter will ignore ip + * + * @access private + * @static + * @param string $algo + * @return string + */ + private static function matchIp($ipRange = null) + { + // Match $_ipKey to $ipRange and if it matches it will return with a true + $address = \IPLib\Factory::addressFromString($_SERVER[self::$_ipKey]); + $range = \IPLib\Factory::rangeFromString(trim($ipRange)); + // If $range is null something went wrong (possible invalid ip given in config) + if ($range == null) { + return false; + } else { + // Ip-lib does throws and exception when something goes wrong, if so we want to catch it and set contained to false + try { + $contained = $address->matches($range); + } catch (\Exception $e) { + // If something is wrong with matching the ip, we set $contained to false + return false; + } + } + // Matches return true! + if ($contained === true) { + return true; + } else { + return false; + } + } + /** * traffic limiter * @@ -123,28 +156,13 @@ class TrafficLimiter extends AbstractPersistence if (self::$_limit < 1) { return true; } - + error_reporting(-1); // Check if $_ipKey is exempted from ratelimiting if (!is_null(self::$_exemptedIp)) { $exIp_array = explode(',', self::$_exemptedIp); foreach ($exIp_array as $ipRange) { - // Match $_ipKey to $ipRange and if it matches it will return with a true - $address = \IPLib\Factory::addressFromString($_SERVER[self::$_ipKey]); - $range = \IPLib\Factory::rangeFromString(trim($ipRange)); - // If $range is null something went wrong (possible invalid ip given in config) - if ($range == null) { - $contained = false; - } else { - // Ip-lib does throws and exception when something goes wrong, if so we want to catch it and set contained to false - try { - $contained = $address->matches($range); - } catch (\Exception $e) { - // If something is wrong with matching the ip, we set $contained to false - $contained = false; - } - } - // Matches return true! - if ($contained == true) { + if (self::matchIp($ipRange) === true) + { return true; } } From 502bb5fa15b12a232c720bf787ef45f898196934 Mon Sep 17 00:00:00 2001 From: Rodehoed Date: Thu, 6 May 2021 12:18:44 +0200 Subject: [PATCH 140/223] Put the ip-matching function in a private function --- lib/Persistence/TrafficLimiter.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index cbe6adf3..39755404 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -112,8 +112,8 @@ class TrafficLimiter extends AbstractPersistence * * @access private * @static - * @param string $algo - * @return string + * @param string $ipRange + * @return bool */ private static function matchIp($ipRange = null) { @@ -156,13 +156,12 @@ class TrafficLimiter extends AbstractPersistence if (self::$_limit < 1) { return true; } - error_reporting(-1); + // Check if $_ipKey is exempted from ratelimiting if (!is_null(self::$_exemptedIp)) { $exIp_array = explode(',', self::$_exemptedIp); foreach ($exIp_array as $ipRange) { - if (self::matchIp($ipRange) === true) - { + if (self::matchIp($ipRange) === true) { return true; } } From f339c0b1c0120ae0c3c22c450fb8a753db5f6317 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sun, 9 May 2021 14:11:14 +0200 Subject: [PATCH 141/223] New translations en.json (Indonesian) --- i18n/id.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/i18n/id.json b/i18n/id.json index c580ca6d..e58900a9 100644 --- a/i18n/id.json +++ b/i18n/id.json @@ -8,7 +8,7 @@ "%s requires php %s or above to work. Sorry.": "%s memerlukan php %s atau versi diatasnya untuk dapat dijalankan. Maaf.", "%s requires configuration section [%s] to be present in configuration file.": "%s membutuhkan bagian konfigurasi [%s] untuk ada di file konfigurasi.", "Please wait %d seconds between each post.": [ - "Silahkan menunggu %d detik antara masing-masing postingan. (tunggal)", + "Silahkan menunggu %d detik antara masing-masing postingan.", "Silahkan menunggu %d detik antara masing-masing postingan.", "Silahkan menunggu %d detik antara masing-masing postingan.", "Silahkan menunggu %d detik antara masing-masing postingan." @@ -35,31 +35,31 @@ "Discussion": "Diskusi", "Toggle navigation": "Alihkan navigasi", "%d seconds": [ - "%d detik (tunggal)", + "%d detik", "%d detik", "%d detik", "%d detik" ], "%d minutes": [ - "%d menit (tunggal)", + "%d menit", "%d menit", "%d menit", "%d menit" ], "%d hours": [ - "%d jam (tunggal)", + "%d jam", "%d jam", "%d jam", "%d jam" ], "%d days": [ - "%d hari (tunggal)", + "%d hari", "%d hari", "%d hari", "%d hari" ], "%d weeks": [ - "%d minggu (tunggal)", + "%d minggu", "%d minggu", "%d minggu", "%d minggu" From 5812a6bb68189415866f4ab4728d2497de7d5795 Mon Sep 17 00:00:00 2001 From: rodehoed <6515395+rodehoed@users.noreply.github.com> Date: Wed, 19 May 2021 08:47:35 +0200 Subject: [PATCH 142/223] Optimized the canPass() functions --- lib/Persistence/TrafficLimiter.php | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 39755404..34584b52 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -120,24 +120,18 @@ class TrafficLimiter extends AbstractPersistence // Match $_ipKey to $ipRange and if it matches it will return with a true $address = \IPLib\Factory::addressFromString($_SERVER[self::$_ipKey]); $range = \IPLib\Factory::rangeFromString(trim($ipRange)); - // If $range is null something went wrong (possible invalid ip given in config) - if ($range == null) { - return false; - } else { - // Ip-lib does throws and exception when something goes wrong, if so we want to catch it and set contained to false - try { - $contained = $address->matches($range); - } catch (\Exception $e) { - // If something is wrong with matching the ip, we set $contained to false - return false; - } - } - // Matches return true! - if ($contained === true) { - return true; - } else { - return false; + + // If $range is null something went wrong (possible invalid ip given in config). It's here becaue matches($range) does not accepts null vallue + if ($range == null) return false; + + // Ip-lib does throws and exception when something goes wrong, if so we want to catch it and set contained to false + try { + return $address->matches($range); + } catch (\Exception $e) { + // If something is wrong with matching the ip, we do nothing } + + return false; } /** From af5a14afc31474572e076c498cba47cb418a35de Mon Sep 17 00:00:00 2001 From: rodehoed <6515395+rodehoed@users.noreply.github.com> Date: Wed, 19 May 2021 09:01:45 +0200 Subject: [PATCH 143/223] Optimized the canPass() functions --- lib/Persistence/TrafficLimiter.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 34584b52..af6e4979 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -122,7 +122,9 @@ class TrafficLimiter extends AbstractPersistence $range = \IPLib\Factory::rangeFromString(trim($ipRange)); // If $range is null something went wrong (possible invalid ip given in config). It's here becaue matches($range) does not accepts null vallue - if ($range == null) return false; + if ($range == null) { + return false; + } // Ip-lib does throws and exception when something goes wrong, if so we want to catch it and set contained to false try { From 89f6f0051dd56b7a9390e70df03271fe3d1f1353 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 22 May 2021 09:21:01 +0200 Subject: [PATCH 144/223] imported mlocati/ip-lib version 1.14.0 --- composer.json | 4 +- composer.lock | 12 +- vendor/composer/autoload_classmap.php | 14 + vendor/composer/autoload_psr4.php | 1 + vendor/composer/autoload_static.php | 19 + vendor/mlocati/ip-lib/ip-lib.php | 13 + .../ip-lib/src/Address/AddressInterface.php | 125 ++++ .../ip-lib/src/Address/AssignedRange.php | 138 +++++ vendor/mlocati/ip-lib/src/Address/IPv4.php | 465 ++++++++++++++ vendor/mlocati/ip-lib/src/Address/IPv6.php | 568 ++++++++++++++++++ vendor/mlocati/ip-lib/src/Address/Type.php | 42 ++ vendor/mlocati/ip-lib/src/Factory.php | 205 +++++++ .../ip-lib/src/Range/AbstractRange.php | 95 +++ vendor/mlocati/ip-lib/src/Range/Pattern.php | 275 +++++++++ .../ip-lib/src/Range/RangeInterface.php | 120 ++++ vendor/mlocati/ip-lib/src/Range/Single.php | 226 +++++++ vendor/mlocati/ip-lib/src/Range/Subnet.php | 305 ++++++++++ vendor/mlocati/ip-lib/src/Range/Type.php | 150 +++++ .../mlocati/ip-lib/src/Service/BinaryMath.php | 118 ++++ .../Service/RangesFromBounradyCalculator.php | 161 +++++ 20 files changed, 3048 insertions(+), 8 deletions(-) create mode 100644 vendor/mlocati/ip-lib/ip-lib.php create mode 100644 vendor/mlocati/ip-lib/src/Address/AddressInterface.php create mode 100644 vendor/mlocati/ip-lib/src/Address/AssignedRange.php create mode 100644 vendor/mlocati/ip-lib/src/Address/IPv4.php create mode 100644 vendor/mlocati/ip-lib/src/Address/IPv6.php create mode 100644 vendor/mlocati/ip-lib/src/Address/Type.php create mode 100644 vendor/mlocati/ip-lib/src/Factory.php create mode 100644 vendor/mlocati/ip-lib/src/Range/AbstractRange.php create mode 100644 vendor/mlocati/ip-lib/src/Range/Pattern.php create mode 100644 vendor/mlocati/ip-lib/src/Range/RangeInterface.php create mode 100644 vendor/mlocati/ip-lib/src/Range/Single.php create mode 100644 vendor/mlocati/ip-lib/src/Range/Subnet.php create mode 100644 vendor/mlocati/ip-lib/src/Range/Type.php create mode 100644 vendor/mlocati/ip-lib/src/Service/BinaryMath.php create mode 100644 vendor/mlocati/ip-lib/src/Service/RangesFromBounradyCalculator.php diff --git a/composer.json b/composer.json index ff79af99..98aaedde 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "php" : "^5.6.0 || ^7.0 || ^8.0", "paragonie/random_compat" : "2.0.19", "yzalis/identicon" : "2.0.0", - "mlocati/ip-lib": "^1.14" + "mlocati/ip-lib" : "1.14.0" }, "require-dev" : { "phpunit/phpunit" : "^4.6 || ^5.0" @@ -40,4 +40,4 @@ "config" : { "autoloader-suffix" : "DontChange" } -} +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index 66a9c8a6..20b0732a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8138b0e4bb3fcaab9ca4c02bbe35d891", + "content-hash": "c3aa7487ba976536cd3db9a60473ce67", "packages": [ { "name": "mlocati/ip-lib", @@ -1495,16 +1495,16 @@ }, { "name": "symfony/yaml", - "version": "v4.4.21", + "version": "v4.4.24", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "3871c720871029f008928244e56cf43497da7e9d" + "reference": "8b6d1b97521e2f125039b3fcb4747584c6dfa0ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/3871c720871029f008928244e56cf43497da7e9d", - "reference": "3871c720871029f008928244e56cf43497da7e9d", + "url": "https://api.github.com/repos/symfony/yaml/zipball/8b6d1b97521e2f125039b3fcb4747584c6dfa0ef", + "reference": "8b6d1b97521e2f125039b3fcb4747584c6dfa0ef", "shasum": "" }, "require": { @@ -1559,7 +1559,7 @@ "type": "tidelift" } ], - "time": "2021-03-05T17:58:50+00:00" + "time": "2021-05-16T09:52:47+00:00" }, { "name": "webmozart/assert", diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index b98b672f..81358f5f 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -6,6 +6,20 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( + 'IPLib\\Address\\AddressInterface' => $vendorDir . '/mlocati/ip-lib/src/Address/AddressInterface.php', + 'IPLib\\Address\\AssignedRange' => $vendorDir . '/mlocati/ip-lib/src/Address/AssignedRange.php', + 'IPLib\\Address\\IPv4' => $vendorDir . '/mlocati/ip-lib/src/Address/IPv4.php', + 'IPLib\\Address\\IPv6' => $vendorDir . '/mlocati/ip-lib/src/Address/IPv6.php', + 'IPLib\\Address\\Type' => $vendorDir . '/mlocati/ip-lib/src/Address/Type.php', + 'IPLib\\Factory' => $vendorDir . '/mlocati/ip-lib/src/Factory.php', + 'IPLib\\Range\\AbstractRange' => $vendorDir . '/mlocati/ip-lib/src/Range/AbstractRange.php', + 'IPLib\\Range\\Pattern' => $vendorDir . '/mlocati/ip-lib/src/Range/Pattern.php', + 'IPLib\\Range\\RangeInterface' => $vendorDir . '/mlocati/ip-lib/src/Range/RangeInterface.php', + 'IPLib\\Range\\Single' => $vendorDir . '/mlocati/ip-lib/src/Range/Single.php', + 'IPLib\\Range\\Subnet' => $vendorDir . '/mlocati/ip-lib/src/Range/Subnet.php', + 'IPLib\\Range\\Type' => $vendorDir . '/mlocati/ip-lib/src/Range/Type.php', + 'IPLib\\Service\\BinaryMath' => $vendorDir . '/mlocati/ip-lib/src/Service/BinaryMath.php', + 'IPLib\\Service\\RangesFromBounradyCalculator' => $vendorDir . '/mlocati/ip-lib/src/Service/RangesFromBounradyCalculator.php', 'Identicon\\Generator\\BaseGenerator' => $vendorDir . '/yzalis/identicon/src/Identicon/Generator/BaseGenerator.php', 'Identicon\\Generator\\GdGenerator' => $vendorDir . '/yzalis/identicon/src/Identicon/Generator/GdGenerator.php', 'Identicon\\Generator\\GeneratorInterface' => $vendorDir . '/yzalis/identicon/src/Identicon/Generator/GeneratorInterface.php', diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 313097d4..9bd3702d 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -8,4 +8,5 @@ $baseDir = dirname($vendorDir); return array( 'PrivateBin\\' => array($baseDir . '/lib'), 'Identicon\\' => array($vendorDir . '/yzalis/identicon/src/Identicon'), + 'IPLib\\' => array($vendorDir . '/mlocati/ip-lib/src'), ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 604d6bba..9197c946 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -18,6 +18,7 @@ class ComposerStaticInitDontChange 'I' => array ( 'Identicon\\' => 10, + 'IPLib\\' => 6, ), ); @@ -30,9 +31,27 @@ class ComposerStaticInitDontChange array ( 0 => __DIR__ . '/..' . '/yzalis/identicon/src/Identicon', ), + 'IPLib\\' => + array ( + 0 => __DIR__ . '/..' . '/mlocati/ip-lib/src', + ), ); public static $classMap = array ( + 'IPLib\\Address\\AddressInterface' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Address/AddressInterface.php', + 'IPLib\\Address\\AssignedRange' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Address/AssignedRange.php', + 'IPLib\\Address\\IPv4' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Address/IPv4.php', + 'IPLib\\Address\\IPv6' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Address/IPv6.php', + 'IPLib\\Address\\Type' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Address/Type.php', + 'IPLib\\Factory' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Factory.php', + 'IPLib\\Range\\AbstractRange' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Range/AbstractRange.php', + 'IPLib\\Range\\Pattern' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Range/Pattern.php', + 'IPLib\\Range\\RangeInterface' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Range/RangeInterface.php', + 'IPLib\\Range\\Single' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Range/Single.php', + 'IPLib\\Range\\Subnet' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Range/Subnet.php', + 'IPLib\\Range\\Type' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Range/Type.php', + 'IPLib\\Service\\BinaryMath' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Service/BinaryMath.php', + 'IPLib\\Service\\RangesFromBounradyCalculator' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Service/RangesFromBounradyCalculator.php', 'Identicon\\Generator\\BaseGenerator' => __DIR__ . '/..' . '/yzalis/identicon/src/Identicon/Generator/BaseGenerator.php', 'Identicon\\Generator\\GdGenerator' => __DIR__ . '/..' . '/yzalis/identicon/src/Identicon/Generator/GdGenerator.php', 'Identicon\\Generator\\GeneratorInterface' => __DIR__ . '/..' . '/yzalis/identicon/src/Identicon/Generator/GeneratorInterface.php', diff --git a/vendor/mlocati/ip-lib/ip-lib.php b/vendor/mlocati/ip-lib/ip-lib.php new file mode 100644 index 00000000..c34d0b49 --- /dev/null +++ b/vendor/mlocati/ip-lib/ip-lib.php @@ -0,0 +1,13 @@ +range = $range; + $this->type = $type; + $this->exceptions = $exceptions; + } + + /** + * Get the range definition. + * + * @return \IPLib\Range\RangeInterface + */ + public function getRange() + { + return $this->range; + } + + /** + * Get the range type. + * + * @return int one of the \IPLib\Range\Type::T_ constants + */ + public function getType() + { + return $this->type; + } + + /** + * Get the list of exceptions for this range type. + * + * @return \IPLib\Address\AssignedRange[] + */ + public function getExceptions() + { + return $this->exceptions; + } + + /** + * Get the assigned type for a specific address. + * + * @param \IPLib\Address\AddressInterface $address + * + * @return int|null return NULL of the address is outside this address; a \IPLib\Range\Type::T_ constant otherwise + */ + public function getAddressType(AddressInterface $address) + { + $result = null; + if ($this->range->contains($address)) { + foreach ($this->exceptions as $exception) { + $result = $exception->getAddressType($address); + if ($result !== null) { + break; + } + } + if ($result === null) { + $result = $this->type; + } + } + + return $result; + } + + /** + * Get the assigned type for a specific address range. + * + * @param \IPLib\Range\RangeInterface $range + * + * @return int|false|null return NULL of the range is fully outside this range; false if it's partly crosses this range (or it contains mixed types); a \IPLib\Range\Type::T_ constant otherwise + */ + public function getRangeType(RangeInterface $range) + { + $myStart = $this->range->getComparableStartString(); + $rangeEnd = $range->getComparableEndString(); + if ($myStart > $rangeEnd) { + $result = null; + } else { + $myEnd = $this->range->getComparableEndString(); + $rangeStart = $range->getComparableStartString(); + if ($myEnd < $rangeStart) { + $result = null; + } elseif ($rangeStart < $myStart || $rangeEnd > $myEnd) { + $result = false; + } else { + $result = null; + foreach ($this->exceptions as $exception) { + $result = $exception->getRangeType($range); + if ($result !== null) { + break; + } + } + if ($result === null) { + $result = $this->getType(); + } + } + } + + return $result; + } +} diff --git a/vendor/mlocati/ip-lib/src/Address/IPv4.php b/vendor/mlocati/ip-lib/src/Address/IPv4.php new file mode 100644 index 00000000..d31338e5 --- /dev/null +++ b/vendor/mlocati/ip-lib/src/Address/IPv4.php @@ -0,0 +1,465 @@ +address = $address; + $this->bytes = null; + $this->rangeType = null; + $this->comparableString = null; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::__toString() + */ + public function __toString() + { + return $this->address; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getNumberOfBits() + */ + public static function getNumberOfBits() + { + return 32; + } + + /** + * Parse a string and returns an IPv4 instance if the string is valid, or null otherwise. + * + * @param string|mixed $address the address to parse + * @param bool $mayIncludePort set to false to avoid parsing addresses with ports + * @param bool $supportNonDecimalIPv4 set to true to support parsing non decimal (that is, octal and hexadecimal) IPv4 addresses + * + * @return static|null + */ + public static function fromString($address, $mayIncludePort = true, $supportNonDecimalIPv4 = false) + { + if (!is_string($address) || !strpos($address, '.')) { + return null; + } + $rxChunk = '0?[0-9]{1,3}'; + if ($supportNonDecimalIPv4) { + $rxChunk = "(?:0[Xx]0*[0-9A-Fa-f]{1,2})|(?:{$rxChunk})"; + } + $rx = "0*?({$rxChunk})\.0*?({$rxChunk})\.0*?({$rxChunk})\.0*?({$rxChunk})"; + if ($mayIncludePort) { + $rx .= '(?::\d+)?'; + } + $matches = null; + if (!preg_match('/^' . $rx . '$/', $address, $matches)) { + return null; + } + $nums = array(); + for ($i = 1; $i <= 4; $i++) { + $s = $matches[$i]; + if ($supportNonDecimalIPv4) { + if (stripos($s, '0x') === 0) { + $n = hexdec(substr($s, 2)); + } elseif ($s[0] === '0') { + if (!preg_match('/^[0-7]+$/', $s)) { + return null; + } + $n = octdec(substr($s, 1)); + } else { + $n = (int) $s; + } + } else { + $n = (int) $s; + } + if ($n < 0 || $n > 255) { + return null; + } + $nums[] = (string) $n; + } + + return new static(implode('.', $nums)); + } + + /** + * Parse an array of bytes and returns an IPv4 instance if the array is valid, or null otherwise. + * + * @param int[]|array $bytes + * + * @return static|null + */ + public static function fromBytes(array $bytes) + { + $result = null; + if (count($bytes) === 4) { + $chunks = array_map( + function ($byte) { + return (is_int($byte) && $byte >= 0 && $byte <= 255) ? (string) $byte : false; + }, + $bytes + ); + if (in_array(false, $chunks, true) === false) { + $result = new static(implode('.', $chunks)); + } + } + + return $result; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::toString() + */ + public function toString($long = false) + { + if ($long) { + return $this->getComparableString(); + } + + return $this->address; + } + + /** + * Get the octal representation of this IP address. + * + * @param bool $long + * + * @return string + * + * @example if $long == false: if the decimal representation is '0.7.8.255': '0.7.010.0377' + * @example if $long == true: if the decimal representation is '0.7.8.255': '0000.0007.0010.0377' + */ + public function toOctal($long = false) + { + $chunks = array(); + foreach ($this->getBytes() as $byte) { + if ($long) { + $chunks[] = sprintf('%04o', $byte); + } else { + $chunks[] = '0' . decoct($byte); + } + } + + return implode('.', $chunks); + } + + /** + * Get the hexadecimal representation of this IP address. + * + * @param bool $long + * + * @return string + * + * @example if $long == false: if the decimal representation is '0.9.10.255': '0.9.0xa.0xff' + * @example if $long == true: if the decimal representation is '0.9.10.255': '0x00.0x09.0x0a.0xff' + */ + public function toHexadecimal($long = false) + { + $chunks = array(); + foreach ($this->getBytes() as $byte) { + if ($long) { + $chunks[] = sprintf('0x%02x', $byte); + } else { + $chunks[] = '0x' . dechex($byte); + } + } + + return implode('.', $chunks); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getBytes() + */ + public function getBytes() + { + if ($this->bytes === null) { + $this->bytes = array_map( + function ($chunk) { + return (int) $chunk; + }, + explode('.', $this->address) + ); + } + + return $this->bytes; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getBits() + */ + public function getBits() + { + $parts = array(); + foreach ($this->getBytes() as $byte) { + $parts[] = sprintf('%08b', $byte); + } + + return implode('', $parts); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getAddressType() + */ + public function getAddressType() + { + return Type::T_IPv4; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getDefaultReservedRangeType() + */ + public static function getDefaultReservedRangeType() + { + return RangeType::T_PUBLIC; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getReservedRanges() + */ + public static function getReservedRanges() + { + if (self::$reservedRanges === null) { + $reservedRanges = array(); + foreach (array( + // RFC 5735 + '0.0.0.0/8' => array(RangeType::T_THISNETWORK, array('0.0.0.0/32' => RangeType::T_UNSPECIFIED)), + // RFC 5735 + '10.0.0.0/8' => array(RangeType::T_PRIVATENETWORK), + // RFC 6598 + '100.64.0.0/10' => array(RangeType::T_CGNAT), + // RFC 5735 + '127.0.0.0/8' => array(RangeType::T_LOOPBACK), + // RFC 5735 + '169.254.0.0/16' => array(RangeType::T_LINKLOCAL), + // RFC 5735 + '172.16.0.0/12' => array(RangeType::T_PRIVATENETWORK), + // RFC 5735 + '192.0.0.0/24' => array(RangeType::T_RESERVED), + // RFC 5735 + '192.0.2.0/24' => array(RangeType::T_RESERVED), + // RFC 5735 + '192.88.99.0/24' => array(RangeType::T_ANYCASTRELAY), + // RFC 5735 + '192.168.0.0/16' => array(RangeType::T_PRIVATENETWORK), + // RFC 5735 + '198.18.0.0/15' => array(RangeType::T_RESERVED), + // RFC 5735 + '198.51.100.0/24' => array(RangeType::T_RESERVED), + // RFC 5735 + '203.0.113.0/24' => array(RangeType::T_RESERVED), + // RFC 5735 + '224.0.0.0/4' => array(RangeType::T_MULTICAST), + // RFC 5735 + '240.0.0.0/4' => array(RangeType::T_RESERVED, array('255.255.255.255/32' => RangeType::T_LIMITEDBROADCAST)), + ) as $range => $data) { + $exceptions = array(); + if (isset($data[1])) { + foreach ($data[1] as $exceptionRange => $exceptionType) { + $exceptions[] = new AssignedRange(Subnet::fromString($exceptionRange), $exceptionType); + } + } + $reservedRanges[] = new AssignedRange(Subnet::fromString($range), $data[0], $exceptions); + } + self::$reservedRanges = $reservedRanges; + } + + return self::$reservedRanges; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getRangeType() + */ + public function getRangeType() + { + if ($this->rangeType === null) { + $rangeType = null; + foreach (static::getReservedRanges() as $reservedRange) { + $rangeType = $reservedRange->getAddressType($this); + if ($rangeType !== null) { + break; + } + } + $this->rangeType = $rangeType === null ? static::getDefaultReservedRangeType() : $rangeType; + } + + return $this->rangeType; + } + + /** + * Create an IPv6 representation of this address (in 6to4 notation). + * + * @return \IPLib\Address\IPv6 + */ + public function toIPv6() + { + $myBytes = $this->getBytes(); + + return IPv6::fromString('2002:' . sprintf('%02x', $myBytes[0]) . sprintf('%02x', $myBytes[1]) . ':' . sprintf('%02x', $myBytes[2]) . sprintf('%02x', $myBytes[3]) . '::'); + } + + /** + * Create an IPv6 representation of this address (in IPv6 IPv4-mapped notation). + * + * @return \IPLib\Address\IPv6 + */ + public function toIPv6IPv4Mapped() + { + return IPv6::fromBytes(array_merge(array(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff), $this->getBytes())); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getComparableString() + */ + public function getComparableString() + { + if ($this->comparableString === null) { + $chunks = array(); + foreach ($this->getBytes() as $byte) { + $chunks[] = sprintf('%03d', $byte); + } + $this->comparableString = implode('.', $chunks); + } + + return $this->comparableString; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::matches() + */ + public function matches(RangeInterface $range) + { + return $range->contains($this); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getNextAddress() + */ + public function getNextAddress() + { + $overflow = false; + $bytes = $this->getBytes(); + for ($i = count($bytes) - 1; $i >= 0; $i--) { + if ($bytes[$i] === 255) { + if ($i === 0) { + $overflow = true; + break; + } + $bytes[$i] = 0; + } else { + $bytes[$i]++; + break; + } + } + + return $overflow ? null : static::fromBytes($bytes); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getPreviousAddress() + */ + public function getPreviousAddress() + { + $overflow = false; + $bytes = $this->getBytes(); + for ($i = count($bytes) - 1; $i >= 0; $i--) { + if ($bytes[$i] === 0) { + if ($i === 0) { + $overflow = true; + break; + } + $bytes[$i] = 255; + } else { + $bytes[$i]--; + break; + } + } + + return $overflow ? null : static::fromBytes($bytes); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getReverseDNSLookupName() + */ + public function getReverseDNSLookupName() + { + return implode( + '.', + array_reverse($this->getBytes()) + ) . '.in-addr.arpa'; + } +} diff --git a/vendor/mlocati/ip-lib/src/Address/IPv6.php b/vendor/mlocati/ip-lib/src/Address/IPv6.php new file mode 100644 index 00000000..36664878 --- /dev/null +++ b/vendor/mlocati/ip-lib/src/Address/IPv6.php @@ -0,0 +1,568 @@ +longAddress = $longAddress; + $this->shortAddress = null; + $this->bytes = null; + $this->words = null; + $this->rangeType = null; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::__toString() + */ + public function __toString() + { + return $this->toString(); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getNumberOfBits() + */ + public static function getNumberOfBits() + { + return 128; + } + + /** + * Parse a string and returns an IPv6 instance if the string is valid, or null otherwise. + * + * @param string|mixed $address the address to parse + * @param bool $mayIncludePort set to false to avoid parsing addresses with ports + * @param bool $mayIncludeZoneID set to false to avoid parsing addresses with zone IDs (see RFC 4007) + * + * @return static|null + */ + public static function fromString($address, $mayIncludePort = true, $mayIncludeZoneID = true) + { + $result = null; + if (is_string($address) && strpos($address, ':') !== false && strpos($address, ':::') === false) { + $matches = null; + if ($mayIncludePort && $address[0] === '[' && preg_match('/^\[(.+)]:\d+$/', $address, $matches)) { + $address = $matches[1]; + } + if ($mayIncludeZoneID) { + $percentagePos = strpos($address, '%'); + if ($percentagePos > 0) { + $address = substr($address, 0, $percentagePos); + } + } + if (preg_match('/^((?:[0-9a-f]*:+)+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i', $address, $matches)) { + $address6 = static::fromString($matches[1] . '0:0', false); + if ($address6 !== null) { + $address4 = IPv4::fromString($matches[2], false); + if ($address4 !== null) { + $bytes4 = $address4->getBytes(); + $address6->longAddress = substr($address6->longAddress, 0, -9) . sprintf('%02x%02x:%02x%02x', $bytes4[0], $bytes4[1], $bytes4[2], $bytes4[3]); + $result = $address6; + } + } + } else { + if (strpos($address, '::') === false) { + $chunks = explode(':', $address); + } else { + $chunks = array(); + $parts = explode('::', $address); + if (count($parts) === 2) { + $before = ($parts[0] === '') ? array() : explode(':', $parts[0]); + $after = ($parts[1] === '') ? array() : explode(':', $parts[1]); + $missing = 8 - count($before) - count($after); + if ($missing >= 0) { + $chunks = $before; + if ($missing !== 0) { + $chunks = array_merge($chunks, array_fill(0, $missing, '0')); + } + $chunks = array_merge($chunks, $after); + } + } + } + if (count($chunks) === 8) { + $nums = array_map( + function ($chunk) { + return preg_match('/^[0-9A-Fa-f]{1,4}$/', $chunk) ? hexdec($chunk) : false; + }, + $chunks + ); + if (!in_array(false, $nums, true)) { + $longAddress = implode( + ':', + array_map( + function ($num) { + return sprintf('%04x', $num); + }, + $nums + ) + ); + $result = new static($longAddress); + } + } + } + } + + return $result; + } + + /** + * Parse an array of bytes and returns an IPv6 instance if the array is valid, or null otherwise. + * + * @param int[]|array $bytes + * + * @return static|null + */ + public static function fromBytes(array $bytes) + { + $result = null; + if (count($bytes) === 16) { + $address = ''; + for ($i = 0; $i < 16; $i++) { + if ($i !== 0 && $i % 2 === 0) { + $address .= ':'; + } + $byte = $bytes[$i]; + if (is_int($byte) && $byte >= 0 && $byte <= 255) { + $address .= sprintf('%02x', $byte); + } else { + $address = null; + break; + } + } + if ($address !== null) { + $result = new static($address); + } + } + + return $result; + } + + /** + * Parse an array of words and returns an IPv6 instance if the array is valid, or null otherwise. + * + * @param int[]|array $words + * + * @return static|null + */ + public static function fromWords(array $words) + { + $result = null; + if (count($words) === 8) { + $chunks = array(); + for ($i = 0; $i < 8; $i++) { + $word = $words[$i]; + if (is_int($word) && $word >= 0 && $word <= 0xffff) { + $chunks[] = sprintf('%04x', $word); + } else { + $chunks = null; + break; + } + } + if ($chunks !== null) { + $result = new static(implode(':', $chunks)); + } + } + + return $result; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::toString() + */ + public function toString($long = false) + { + if ($long) { + $result = $this->longAddress; + } else { + if ($this->shortAddress === null) { + if (strpos($this->longAddress, '0000:0000:0000:0000:0000:ffff:') === 0) { + $lastBytes = array_slice($this->getBytes(), -4); + $this->shortAddress = '::ffff:' . implode('.', $lastBytes); + } else { + $chunks = array_map( + function ($word) { + return dechex($word); + }, + $this->getWords() + ); + $shortAddress = implode(':', $chunks); + $matches = null; + for ($i = 8; $i > 1; $i--) { + $search = '(?:^|:)' . rtrim(str_repeat('0:', $i), ':') . '(?:$|:)'; + if (preg_match('/^(.*?)' . $search . '(.*)$/', $shortAddress, $matches)) { + $shortAddress = $matches[1] . '::' . $matches[2]; + break; + } + } + $this->shortAddress = $shortAddress; + } + } + $result = $this->shortAddress; + } + + return $result; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getBytes() + */ + public function getBytes() + { + if ($this->bytes === null) { + $bytes = array(); + foreach ($this->getWords() as $word) { + $bytes[] = $word >> 8; + $bytes[] = $word & 0xff; + } + $this->bytes = $bytes; + } + + return $this->bytes; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getBits() + */ + public function getBits() + { + $parts = array(); + foreach ($this->getBytes() as $byte) { + $parts[] = sprintf('%08b', $byte); + } + + return implode('', $parts); + } + + /** + * Get the word list of the IP address. + * + * @return int[] + */ + public function getWords() + { + if ($this->words === null) { + $this->words = array_map( + function ($chunk) { + return hexdec($chunk); + }, + explode(':', $this->longAddress) + ); + } + + return $this->words; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getAddressType() + */ + public function getAddressType() + { + return Type::T_IPv6; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getDefaultReservedRangeType() + */ + public static function getDefaultReservedRangeType() + { + return RangeType::T_RESERVED; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getReservedRanges() + */ + public static function getReservedRanges() + { + if (self::$reservedRanges === null) { + $reservedRanges = array(); + foreach (array( + // RFC 4291 + '::/128' => array(RangeType::T_UNSPECIFIED), + // RFC 4291 + '::1/128' => array(RangeType::T_LOOPBACK), + // RFC 4291 + '100::/8' => array(RangeType::T_DISCARD, array('100::/64' => RangeType::T_DISCARDONLY)), + //'2002::/16' => array(RangeType::), + // RFC 4291 + '2000::/3' => array(RangeType::T_PUBLIC), + // RFC 4193 + 'fc00::/7' => array(RangeType::T_PRIVATENETWORK), + // RFC 4291 + 'fe80::/10' => array(RangeType::T_LINKLOCAL_UNICAST), + // RFC 4291 + 'ff00::/8' => array(RangeType::T_MULTICAST), + // RFC 4291 + //'::/8' => array(RangeType::T_RESERVED), + // RFC 4048 + //'200::/7' => array(RangeType::T_RESERVED), + // RFC 4291 + //'400::/6' => array(RangeType::T_RESERVED), + // RFC 4291 + //'800::/5' => array(RangeType::T_RESERVED), + // RFC 4291 + //'1000::/4' => array(RangeType::T_RESERVED), + // RFC 4291 + //'4000::/3' => array(RangeType::T_RESERVED), + // RFC 4291 + //'6000::/3' => array(RangeType::T_RESERVED), + // RFC 4291 + //'8000::/3' => array(RangeType::T_RESERVED), + // RFC 4291 + //'a000::/3' => array(RangeType::T_RESERVED), + // RFC 4291 + //'c000::/3' => array(RangeType::T_RESERVED), + // RFC 4291 + //'e000::/4' => array(RangeType::T_RESERVED), + // RFC 4291 + //'f000::/5' => array(RangeType::T_RESERVED), + // RFC 4291 + //'f800::/6' => array(RangeType::T_RESERVED), + // RFC 4291 + //'fe00::/9' => array(RangeType::T_RESERVED), + // RFC 3879 + //'fec0::/10' => array(RangeType::T_RESERVED), + ) as $range => $data) { + $exceptions = array(); + if (isset($data[1])) { + foreach ($data[1] as $exceptionRange => $exceptionType) { + $exceptions[] = new AssignedRange(Subnet::fromString($exceptionRange), $exceptionType); + } + } + $reservedRanges[] = new AssignedRange(Subnet::fromString($range), $data[0], $exceptions); + } + self::$reservedRanges = $reservedRanges; + } + + return self::$reservedRanges; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getRangeType() + */ + public function getRangeType() + { + if ($this->rangeType === null) { + $ipv4 = $this->toIPv4(); + if ($ipv4 !== null) { + $this->rangeType = $ipv4->getRangeType(); + } else { + $rangeType = null; + foreach (static::getReservedRanges() as $reservedRange) { + $rangeType = $reservedRange->getAddressType($this); + if ($rangeType !== null) { + break; + } + } + $this->rangeType = $rangeType === null ? static::getDefaultReservedRangeType() : $rangeType; + } + } + + return $this->rangeType; + } + + /** + * Create an IPv4 representation of this address (if possible, otherwise returns null). + * + * @return \IPLib\Address\IPv4|null + */ + public function toIPv4() + { + if (strpos($this->longAddress, '2002:') === 0) { + // 6to4 + return IPv4::fromBytes(array_slice($this->getBytes(), 2, 4)); + } + if (strpos($this->longAddress, '0000:0000:0000:0000:0000:ffff:') === 0) { + // IPv4-mapped IPv6 addresses + return IPv4::fromBytes(array_slice($this->getBytes(), -4)); + } + + return null; + } + + /** + * Render this IPv6 address in the "mixed" IPv6 (first 12 bytes) + IPv4 (last 4 bytes) mixed syntax. + * + * @param bool $ipV6Long render the IPv6 part in "long" format? + * @param bool $ipV4Long render the IPv4 part in "long" format? + * + * @return string + * + * @example '::13.1.68.3' + * @example '0000:0000:0000:0000:0000:0000:13.1.68.3' when $ipV6Long is true + * @example '::013.001.068.003' when $ipV4Long is true + * @example '0000:0000:0000:0000:0000:0000:013.001.068.003' when $ipV6Long and $ipV4Long are true + * + * @see https://tools.ietf.org/html/rfc4291#section-2.2 point 3. + */ + public function toMixedIPv6IPv4String($ipV6Long = false, $ipV4Long = false) + { + $myBytes = $this->getBytes(); + $ipv6Bytes = array_merge(array_slice($myBytes, 0, 12), array(0xff, 0xff, 0xff, 0xff)); + $ipv6String = static::fromBytes($ipv6Bytes)->toString($ipV6Long); + $ipv4Bytes = array_slice($myBytes, 12, 4); + $ipv4String = IPv4::fromBytes($ipv4Bytes)->toString($ipV4Long); + + return preg_replace('/((ffff:ffff)|(\d+(\.\d+){3}))$/i', $ipv4String, $ipv6String); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getComparableString() + */ + public function getComparableString() + { + return $this->longAddress; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::matches() + */ + public function matches(RangeInterface $range) + { + return $range->contains($this); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getNextAddress() + */ + public function getNextAddress() + { + $overflow = false; + $words = $this->getWords(); + for ($i = count($words) - 1; $i >= 0; $i--) { + if ($words[$i] === 0xffff) { + if ($i === 0) { + $overflow = true; + break; + } + $words[$i] = 0; + } else { + $words[$i]++; + break; + } + } + + return $overflow ? null : static::fromWords($words); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getPreviousAddress() + */ + public function getPreviousAddress() + { + $overflow = false; + $words = $this->getWords(); + for ($i = count($words) - 1; $i >= 0; $i--) { + if ($words[$i] === 0) { + if ($i === 0) { + $overflow = true; + break; + } + $words[$i] = 0xffff; + } else { + $words[$i]--; + break; + } + } + + return $overflow ? null : static::fromWords($words); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Address\AddressInterface::getReverseDNSLookupName() + */ + public function getReverseDNSLookupName() + { + return implode( + '.', + array_reverse(str_split(str_replace(':', '', $this->toString(true)), 1)) + ) . '.ip6.arpa'; + } +} diff --git a/vendor/mlocati/ip-lib/src/Address/Type.php b/vendor/mlocati/ip-lib/src/Address/Type.php new file mode 100644 index 00000000..06b07535 --- /dev/null +++ b/vendor/mlocati/ip-lib/src/Address/Type.php @@ -0,0 +1,42 @@ +getNumberOfBits())); + } + $numberOfBits = $from->getNumberOfBits(); + if ($to->getNumberOfBits() !== $numberOfBits) { + return null; + } + $calculator = new RangesFromBounradyCalculator($numberOfBits); + + return $calculator->getRanges($from, $to); + } + + /** + * @param \IPLib\Address\AddressInterface $from + * @param \IPLib\Address\AddressInterface $to + * + * @return \IPLib\Range\RangeInterface|null + */ + protected static function rangeFromBoundaryAddresses(AddressInterface $from = null, AddressInterface $to = null) + { + if ($from === null && $to === null) { + $result = null; + } elseif ($to === null) { + $result = Range\Single::fromAddress($from); + } elseif ($from === null) { + $result = Range\Single::fromAddress($to); + } else { + $result = null; + $addressType = $from->getAddressType(); + if ($addressType === $to->getAddressType()) { + $cmp = strcmp($from->getComparableString(), $to->getComparableString()); + if ($cmp === 0) { + $result = Range\Single::fromAddress($from); + } else { + if ($cmp > 0) { + list($from, $to) = array($to, $from); + } + $fromBytes = $from->getBytes(); + $toBytes = $to->getBytes(); + $numBytes = count($fromBytes); + $sameBits = 0; + for ($byteIndex = 0; $byteIndex < $numBytes; $byteIndex++) { + $fromByte = $fromBytes[$byteIndex]; + $toByte = $toBytes[$byteIndex]; + if ($fromByte === $toByte) { + $sameBits += 8; + } else { + $differentBitsInByte = decbin($fromByte ^ $toByte); + $sameBits += 8 - strlen($differentBitsInByte); + break; + } + } + $result = static::rangeFromString($from->toString(true) . '/' . (string) $sameBits); + } + } + } + + return $result; + } + + /** + * @param string|\IPLib\Address\AddressInterface $from + * @param string|\IPLib\Address\AddressInterface $to + * @param bool $supportNonDecimalIPv4 + * + * @return \IPLib\Address\AddressInterface[]|null[]|false[] + */ + private static function parseBoundaries($from, $to, $supportNonDecimalIPv4 = false) + { + $result = array(); + foreach (array('from', 'to') as $param) { + $value = $$param; + if (!($value instanceof AddressInterface)) { + $value = (string) $value; + if ($value === '') { + $value = null; + } else { + $value = static::addressFromString($value, true, true, $supportNonDecimalIPv4); + if ($value === null) { + $value = false; + } + } + } + $result[] = $value; + } + if ($result[0] && $result[1] && strcmp($result[0]->getComparableString(), $result[1]->getComparableString()) > 0) { + $result = array($result[1], $result[0]); + } + + return $result; + } +} diff --git a/vendor/mlocati/ip-lib/src/Range/AbstractRange.php b/vendor/mlocati/ip-lib/src/Range/AbstractRange.php new file mode 100644 index 00000000..1da94d00 --- /dev/null +++ b/vendor/mlocati/ip-lib/src/Range/AbstractRange.php @@ -0,0 +1,95 @@ +rangeType === null) { + $addressType = $this->getAddressType(); + if ($addressType === AddressType::T_IPv6 && Subnet::get6to4()->containsRange($this)) { + $this->rangeType = Factory::rangeFromBoundaries($this->fromAddress->toIPv4(), $this->toAddress->toIPv4())->getRangeType(); + } else { + switch ($addressType) { + case AddressType::T_IPv4: + $defaultType = IPv4::getDefaultReservedRangeType(); + $reservedRanges = IPv4::getReservedRanges(); + break; + case AddressType::T_IPv6: + $defaultType = IPv6::getDefaultReservedRangeType(); + $reservedRanges = IPv6::getReservedRanges(); + break; + default: + throw new \Exception('@todo'); // @codeCoverageIgnore + } + $rangeType = null; + foreach ($reservedRanges as $reservedRange) { + $rangeType = $reservedRange->getRangeType($this); + if ($rangeType !== null) { + break; + } + } + $this->rangeType = $rangeType === null ? $defaultType : $rangeType; + } + } + + return $this->rangeType === false ? null : $this->rangeType; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::contains() + */ + public function contains(AddressInterface $address) + { + $result = false; + if ($address->getAddressType() === $this->getAddressType()) { + $cmp = $address->getComparableString(); + $from = $this->getComparableStartString(); + if ($cmp >= $from) { + $to = $this->getComparableEndString(); + if ($cmp <= $to) { + $result = true; + } + } + } + + return $result; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::containsRange() + */ + public function containsRange(RangeInterface $range) + { + $result = false; + if ($range->getAddressType() === $this->getAddressType()) { + $myStart = $this->getComparableStartString(); + $itsStart = $range->getComparableStartString(); + if ($itsStart >= $myStart) { + $myEnd = $this->getComparableEndString(); + $itsEnd = $range->getComparableEndString(); + if ($itsEnd <= $myEnd) { + $result = true; + } + } + } + + return $result; + } +} diff --git a/vendor/mlocati/ip-lib/src/Range/Pattern.php b/vendor/mlocati/ip-lib/src/Range/Pattern.php new file mode 100644 index 00000000..fc19d1ee --- /dev/null +++ b/vendor/mlocati/ip-lib/src/Range/Pattern.php @@ -0,0 +1,275 @@ +fromAddress = $fromAddress; + $this->toAddress = $toAddress; + $this->asterisksCount = $asterisksCount; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::__toString() + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Try get the range instance starting from its string representation. + * + * @param string|mixed $range + * @param bool $supportNonDecimalIPv4 set to true to support parsing non decimal (that is, octal and hexadecimal) IPv4 addresses + * + * @return static|null + */ + public static function fromString($range, $supportNonDecimalIPv4 = false) + { + if (!is_string($range) || strpos($range, '*') === false) { + return null; + } + if ($range === '*.*.*.*') { + return new static(IPv4::fromString('0.0.0.0'), IPv4::fromString('255.255.255.255'), 4); + } + if ($range === '*:*:*:*:*:*:*:*') { + return new static(IPv6::fromString('::'), IPv6::fromString('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'), 8); + } + $matches = null; + if (strpos($range, '.') !== false && preg_match('/^[^*]+((?:\.\*)+)$/', $range, $matches)) { + $asterisksCount = strlen($matches[1]) >> 1; + if ($asterisksCount > 0) { + $missingDots = 3 - substr_count($range, '.'); + if ($missingDots > 0) { + $range .= str_repeat('.*', $missingDots); + $asterisksCount += $missingDots; + } + } + $fromAddress = IPv4::fromString(str_replace('*', '0', $range), true, $supportNonDecimalIPv4); + if ($fromAddress === null) { + return null; + } + $fixedBytes = array_slice($fromAddress->getBytes(), 0, -$asterisksCount); + $otherBytes = array_fill(0, $asterisksCount, 255); + $toAddress = IPv4::fromBytes(array_merge($fixedBytes, $otherBytes)); + + return new static($fromAddress, $toAddress, $asterisksCount); + } + if (strpos($range, ':') !== false && preg_match('/^[^*]+((?::\*)+)$/', $range, $matches)) { + $asterisksCount = strlen($matches[1]) >> 1; + $fromAddress = IPv6::fromString(str_replace('*', '0', $range)); + if ($fromAddress === null) { + return null; + } + $fixedWords = array_slice($fromAddress->getWords(), 0, -$asterisksCount); + $otherWords = array_fill(0, $asterisksCount, 0xffff); + $toAddress = IPv6::fromWords(array_merge($fixedWords, $otherWords)); + + return new static($fromAddress, $toAddress, $asterisksCount); + } + + return null; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::toString() + */ + public function toString($long = false) + { + if ($this->asterisksCount === 0) { + return $this->fromAddress->toString($long); + } + switch (true) { + case $this->fromAddress instanceof \IPLib\Address\IPv4: + $chunks = explode('.', $this->fromAddress->toString()); + $chunks = array_slice($chunks, 0, -$this->asterisksCount); + $chunks = array_pad($chunks, 4, '*'); + $result = implode('.', $chunks); + break; + case $this->fromAddress instanceof \IPLib\Address\IPv6: + if ($long) { + $chunks = explode(':', $this->fromAddress->toString(true)); + $chunks = array_slice($chunks, 0, -$this->asterisksCount); + $chunks = array_pad($chunks, 8, '*'); + $result = implode(':', $chunks); + } elseif ($this->asterisksCount === 8) { + $result = '*:*:*:*:*:*:*:*'; + } else { + $bytes = $this->toAddress->getBytes(); + $bytes = array_slice($bytes, 0, -$this->asterisksCount * 2); + $bytes = array_pad($bytes, 16, 1); + $address = IPv6::fromBytes($bytes); + $before = substr($address->toString(false), 0, -strlen(':101') * $this->asterisksCount); + $result = $before . str_repeat(':*', $this->asterisksCount); + } + break; + default: + throw new \Exception('@todo'); // @codeCoverageIgnore + } + + return $result; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getAddressType() + */ + public function getAddressType() + { + return $this->fromAddress->getAddressType(); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getStartAddress() + */ + public function getStartAddress() + { + return $this->fromAddress; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getEndAddress() + */ + public function getEndAddress() + { + return $this->toAddress; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getComparableStartString() + */ + public function getComparableStartString() + { + return $this->fromAddress->getComparableString(); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getComparableEndString() + */ + public function getComparableEndString() + { + return $this->toAddress->getComparableString(); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::asSubnet() + */ + public function asSubnet() + { + switch ($this->getAddressType()) { + case AddressType::T_IPv4: + return new Subnet($this->getStartAddress(), $this->getEndAddress(), 8 * (4 - $this->asterisksCount)); + case AddressType::T_IPv6: + return new Subnet($this->getStartAddress(), $this->getEndAddress(), 16 * (8 - $this->asterisksCount)); + } + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::asPattern() + */ + public function asPattern() + { + return $this; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getSubnetMask() + */ + public function getSubnetMask() + { + if ($this->getAddressType() !== AddressType::T_IPv4) { + return null; + } + switch ($this->asterisksCount) { + case 0: + $bytes = array(255, 255, 255, 255); + break; + case 4: + $bytes = array(0, 0, 0, 0); + break; + default: + $bytes = array_pad(array_fill(0, 4 - $this->asterisksCount, 255), 4, 0); + break; + } + + return IPv4::fromBytes($bytes); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getReverseDNSLookupName() + */ + public function getReverseDNSLookupName() + { + return $this->asterisksCount === 0 ? array($this->getStartAddress()->getReverseDNSLookupName()) : $this->asSubnet()->getReverseDNSLookupName(); + } +} diff --git a/vendor/mlocati/ip-lib/src/Range/RangeInterface.php b/vendor/mlocati/ip-lib/src/Range/RangeInterface.php new file mode 100644 index 00000000..468df3e4 --- /dev/null +++ b/vendor/mlocati/ip-lib/src/Range/RangeInterface.php @@ -0,0 +1,120 @@ +address = $address; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::__toString() + */ + public function __toString() + { + return $this->address->__toString(); + } + + /** + * Try get the range instance starting from its string representation. + * + * @param string|mixed $range + * @param bool $supportNonDecimalIPv4 set to true to support parsing non decimal (that is, octal and hexadecimal) IPv4 addresses + * + * @return static|null + */ + public static function fromString($range, $supportNonDecimalIPv4 = false) + { + $result = null; + $address = Factory::addressFromString($range, true, true, $supportNonDecimalIPv4); + if ($address !== null) { + $result = new static($address); + } + + return $result; + } + + /** + * Create the range instance starting from an address instance. + * + * @param \IPLib\Address\AddressInterface $address + * + * @return static + */ + public static function fromAddress(AddressInterface $address) + { + return new static($address); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::toString() + */ + public function toString($long = false) + { + return $this->address->toString($long); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getAddressType() + */ + public function getAddressType() + { + return $this->address->getAddressType(); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getRangeType() + */ + public function getRangeType() + { + return $this->address->getRangeType(); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::contains() + */ + public function contains(AddressInterface $address) + { + $result = false; + if ($address->getAddressType() === $this->getAddressType()) { + if ($address->toString(false) === $this->address->toString(false)) { + $result = true; + } + } + + return $result; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::containsRange() + */ + public function containsRange(RangeInterface $range) + { + $result = false; + if ($range->getAddressType() === $this->getAddressType()) { + if ($range->toString(false) === $this->toString(false)) { + $result = true; + } + } + + return $result; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getStartAddress() + */ + public function getStartAddress() + { + return $this->address; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getEndAddress() + */ + public function getEndAddress() + { + return $this->address; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getComparableStartString() + */ + public function getComparableStartString() + { + return $this->address->getComparableString(); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getComparableEndString() + */ + public function getComparableEndString() + { + return $this->address->getComparableString(); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::asSubnet() + */ + public function asSubnet() + { + $networkPrefixes = array( + AddressType::T_IPv4 => 32, + AddressType::T_IPv6 => 128, + ); + + return new Subnet($this->address, $this->address, $networkPrefixes[$this->address->getAddressType()]); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::asPattern() + */ + public function asPattern() + { + return new Pattern($this->address, $this->address, 0); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getSubnetMask() + */ + public function getSubnetMask() + { + if ($this->getAddressType() !== AddressType::T_IPv4) { + return null; + } + + return IPv4::fromBytes(array(255, 255, 255, 255)); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getReverseDNSLookupName() + */ + public function getReverseDNSLookupName() + { + return array($this->getStartAddress()->getReverseDNSLookupName()); + } +} diff --git a/vendor/mlocati/ip-lib/src/Range/Subnet.php b/vendor/mlocati/ip-lib/src/Range/Subnet.php new file mode 100644 index 00000000..2ce166b7 --- /dev/null +++ b/vendor/mlocati/ip-lib/src/Range/Subnet.php @@ -0,0 +1,305 @@ +fromAddress = $fromAddress; + $this->toAddress = $toAddress; + $this->networkPrefix = $networkPrefix; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::__toString() + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Try get the range instance starting from its string representation. + * + * @param string|mixed $range + * @param bool $supportNonDecimalIPv4 set to true to support parsing non decimal (that is, octal and hexadecimal) IPv4 addresses + * + * @return static|null + */ + public static function fromString($range, $supportNonDecimalIPv4 = false) + { + if (!is_string($range)) { + return null; + } + $parts = explode('/', $range); + if (count($parts) !== 2) { + return null; + } + $address = Factory::addressFromString($parts[0], true, true, $supportNonDecimalIPv4); + if ($address === null) { + return null; + } + if (!preg_match('/^[0-9]{1,9}$/', $parts[1])) { + return null; + } + $networkPrefix = (int) $parts[1]; + $addressBytes = $address->getBytes(); + $totalBytes = count($addressBytes); + $numDifferentBits = $totalBytes * 8 - $networkPrefix; + if ($numDifferentBits < 0) { + return null; + } + $numSameBytes = $networkPrefix >> 3; + $sameBytes = array_slice($addressBytes, 0, $numSameBytes); + $differentBytesStart = ($totalBytes === $numSameBytes) ? array() : array_fill(0, $totalBytes - $numSameBytes, 0); + $differentBytesEnd = ($totalBytes === $numSameBytes) ? array() : array_fill(0, $totalBytes - $numSameBytes, 255); + $startSameBits = $networkPrefix % 8; + if ($startSameBits !== 0) { + $varyingByte = $addressBytes[$numSameBytes]; + $differentBytesStart[0] = $varyingByte & bindec(str_pad(str_repeat('1', $startSameBits), 8, '0', STR_PAD_RIGHT)); + $differentBytesEnd[0] = $differentBytesStart[0] + bindec(str_repeat('1', 8 - $startSameBits)); + } + + return new static( + Factory::addressFromBytes(array_merge($sameBytes, $differentBytesStart)), + Factory::addressFromBytes(array_merge($sameBytes, $differentBytesEnd)), + $networkPrefix + ); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::toString() + */ + public function toString($long = false) + { + return $this->fromAddress->toString($long) . '/' . $this->networkPrefix; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getAddressType() + */ + public function getAddressType() + { + return $this->fromAddress->getAddressType(); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getStartAddress() + */ + public function getStartAddress() + { + return $this->fromAddress; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getEndAddress() + */ + public function getEndAddress() + { + return $this->toAddress; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getComparableStartString() + */ + public function getComparableStartString() + { + return $this->fromAddress->getComparableString(); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getComparableEndString() + */ + public function getComparableEndString() + { + return $this->toAddress->getComparableString(); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::asSubnet() + */ + public function asSubnet() + { + return $this; + } + + /** + * Get the pattern (asterisk) representation (if applicable) of this range. + * + * @return \IPLib\Range\Pattern|null return NULL if this range can't be represented by a pattern notation + */ + public function asPattern() + { + $address = $this->getStartAddress(); + $networkPrefix = $this->getNetworkPrefix(); + switch ($address->getAddressType()) { + case AddressType::T_IPv4: + return $networkPrefix % 8 === 0 ? new Pattern($address, $address, 4 - $networkPrefix / 8) : null; + case AddressType::T_IPv6: + return $networkPrefix % 16 === 0 ? new Pattern($address, $address, 8 - $networkPrefix / 16) : null; + } + } + + /** + * Get the 6to4 address IPv6 address range. + * + * @return self + */ + public static function get6to4() + { + if (self::$sixToFour === null) { + self::$sixToFour = self::fromString('2002::/16'); + } + + return self::$sixToFour; + } + + /** + * Get subnet prefix. + * + * @return int + */ + public function getNetworkPrefix() + { + return $this->networkPrefix; + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getSubnetMask() + */ + public function getSubnetMask() + { + if ($this->getAddressType() !== AddressType::T_IPv4) { + return null; + } + $bytes = array(); + $prefix = $this->getNetworkPrefix(); + while ($prefix >= 8) { + $bytes[] = 255; + $prefix -= 8; + } + if ($prefix !== 0) { + $bytes[] = bindec(str_pad(str_repeat('1', $prefix), 8, '0')); + } + $bytes = array_pad($bytes, 4, 0); + + return IPv4::fromBytes($bytes); + } + + /** + * {@inheritdoc} + * + * @see \IPLib\Range\RangeInterface::getReverseDNSLookupName() + */ + public function getReverseDNSLookupName() + { + switch ($this->getAddressType()) { + case AddressType::T_IPv4: + $unitSize = 8; // bytes + $maxUnits = 4; + $isHex = false; + $rxUnit = '\d+'; + break; + case AddressType::T_IPv6: + $unitSize = 4; // nibbles + $maxUnits = 32; + $isHex = true; + $rxUnit = '[0-9A-Fa-f]'; + break; + } + $totBits = $unitSize * $maxUnits; + $prefixUnits = (int) ($this->networkPrefix / $unitSize); + $extraBits = ($totBits - $this->networkPrefix) % $unitSize; + if ($extraBits !== 0) { + $prefixUnits += 1; + } + $numVariants = 1 << $extraBits; + $result = array(); + $unitsToRemove = $maxUnits - $prefixUnits; + $initialPointer = preg_replace("/^(({$rxUnit})\.){{$unitsToRemove}}/", '', $this->getStartAddress()->getReverseDNSLookupName()); + $chunks = explode('.', $initialPointer, 2); + for ($index = 0; $index < $numVariants; $index++) { + if ($index !== 0) { + $chunks[0] = $isHex ? dechex(1 + hexdec($chunks[0])) : (string) (1 + (int) $chunks[0]); + } + $result[] = implode('.', $chunks); + } + + return $result; + } +} diff --git a/vendor/mlocati/ip-lib/src/Range/Type.php b/vendor/mlocati/ip-lib/src/Range/Type.php new file mode 100644 index 00000000..cfc268b6 --- /dev/null +++ b/vendor/mlocati/ip-lib/src/Range/Type.php @@ -0,0 +1,150 @@ +toSameLength($a, $b); + + return $a < $b ? -1 : ($a > $b ? 1 : 0); + } + + /** + * Add 1 to a non-negative integer represented in binary form. + * + * @param string $value + * + * @return string + */ + public function increment($value) + { + $lastZeroIndex = strrpos($value, '0'); + if ($lastZeroIndex === false) { + return '1' . str_repeat('0', strlen($value)); + } + + return ltrim(substr($value, 0, $lastZeroIndex), '0') . '1' . str_repeat('0', strlen($value) - $lastZeroIndex - 1); + } + + /** + * Calculate the bitwise AND of two non-negative integers represented in binary form. + * + * @param string $operand1 + * @param string $operand2 + * + * @return string + */ + public function andX($operand1, $operand2) + { + $operand1 = $this->reduce($operand1); + $operand2 = $this->reduce($operand2); + $numBits = min(strlen($operand1), strlen($operand2)); + $operand1 = substr(str_pad($operand1, $numBits, '0', STR_PAD_LEFT), -$numBits); + $operand2 = substr(str_pad($operand2, $numBits, '0', STR_PAD_LEFT), -$numBits); + $result = ''; + for ($index = 0; $index < $numBits; $index++) { + $result .= $operand1[$index] === '1' && $operand2[$index] === '1' ? '1' : '0'; + } + + return $this->reduce($result); + } + + /** + * Calculate the bitwise OR of two non-negative integers represented in binary form. + * + * @param string $operand1 + * @param string $operand2 + * + * @return string + */ + public function orX($operand1, $operand2) + { + list($operand1, $operand2, $numBits) = $this->toSameLength($operand1, $operand2); + $result = ''; + for ($index = 0; $index < $numBits; $index++) { + $result .= $operand1[$index] === '1' || $operand2[$index] === '1' ? '1' : '0'; + } + + return $result; + } + + /** + * Zero-padding of two non-negative integers represented in binary form, so that they have the same length. + * + * @param string $num1 + * @param string $num2 + * + * @return string[],int[] The first array element is $num1 (padded), the first array element is $num2 (padded), the third array element is the number of bits + */ + private function toSameLength($num1, $num2) + { + $num1 = $this->reduce($num1); + $num2 = $this->reduce($num2); + $numBits = max(strlen($num1), strlen($num2)); + + return array( + str_pad($num1, $numBits, '0', STR_PAD_LEFT), + str_pad($num2, $numBits, '0', STR_PAD_LEFT), + $numBits, + ); + } +} diff --git a/vendor/mlocati/ip-lib/src/Service/RangesFromBounradyCalculator.php b/vendor/mlocati/ip-lib/src/Service/RangesFromBounradyCalculator.php new file mode 100644 index 00000000..c1d29d6f --- /dev/null +++ b/vendor/mlocati/ip-lib/src/Service/RangesFromBounradyCalculator.php @@ -0,0 +1,161 @@ +math = new BinaryMath(); + $this->setNumBits($numBits); + } + + /** + * Calculate the subnets describing all (and only all) the addresses between two bouundaries. + * + * @param \IPLib\Address\AddressInterface $from + * @param \IPLib\Address\AddressInterface $to + * + * @return \IPLib\Range\Subnet[]|null return NULL if the two addresses have an invalid number of bits (that is, different from the one passed to the constructor of this class) + */ + public function getRanges(AddressInterface $from, AddressInterface $to) + { + if ($from->getNumberOfBits() !== $this->numBits || $to->getNumberOfBits() !== $this->numBits) { + return null; + } + if ($from->getComparableString() > $to->getComparableString()) { + list($from, $to) = array($to, $from); + } + $result = array(); + $this->calculate($this->math->reduce($from->getBits()), $this->math->reduce($to->getBits()), $this->numBits, $result); + + return $result; + } + + /** + * Set the number of bits used to represent addresses (32 for IPv4, 128 for IPv6). + * + * @param int $numBits + */ + private function setNumBits($numBits) + { + $numBits = (int) $numBits; + $masks = array(); + $unmasks = array(); + for ($bit = 0; $bit < $numBits; $bit++) { + $masks[$bit] = str_repeat('1', $numBits - $bit) . str_repeat('0', $bit); + $unmasks[$bit] = $bit === 0 ? '0' : str_repeat('1', $bit); + } + $this->numBits = $numBits; + $this->masks = $masks; + $this->unmasks = $unmasks; + } + + /** + * Calculate the subnets. + * + * @param string $start the start address (represented in reduced bit form) + * @param string $end the end address (represented in reduced bit form) + * @param int $position the number of bits in the mask we are comparing at this cycle + * @param \IPLib\Range\Subnet[] $result found ranges will be added to this variable + */ + private function calculate($start, $end, $position, array &$result) + { + if ($start === $end) { + $result[] = $this->subnetFromBits($start, $this->numBits); + + return; + } + for ($index = $position - 1; $index >= 0; $index--) { + $startMasked = $this->math->andX($start, $this->masks[$index]); + $endMasked = $this->math->andX($end, $this->masks[$index]); + if ($startMasked !== $endMasked) { + $position = $index; + break; + } + } + if ($startMasked === $start && $this->math->andX($this->math->increment($end), $this->unmasks[$position]) === '0') { + $result[] = $this->subnetFromBits($start, $this->numBits - 1 - $position); + + return; + } + $middleAddress = $this->math->orX($start, $this->unmasks[$position]); + $this->calculate($start, $middleAddress, $position, $result); + $this->calculate($this->math->increment($middleAddress), $end, $position, $result); + } + + /** + * Create an address instance starting from its bits. + * + * @param string $bits the bits of the address (represented in reduced bit form) + * + * @return \IPLib\Address\AddressInterface + */ + private function addressFromBits($bits) + { + $bits = str_pad($bits, $this->numBits, '0', STR_PAD_LEFT); + $bytes = array(); + foreach (explode("\n", trim(chunk_split($bits, 8, "\n"))) as $byteBits) { + $bytes[] = bindec($byteBits); + } + + return Factory::addressFromBytes($bytes); + } + + /** + * Create an range instance starting from the bits if the address and the length of the network prefix. + * + * @param string $bits the bits of the address (represented in reduced bit form) + * @param int $networkPrefix the length of the network prefix + * + * @return \IPLib\Range\Subnet + */ + private function subnetFromBits($bits, $networkPrefix) + { + $address = $this->addressFromBits($bits); + + return new Subnet($address, $address, $networkPrefix); + } +} From 3dd01b1f7035f9c774b6a2a3c5b2a3720a04975a Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 22 May 2021 10:59:47 +0200 Subject: [PATCH 145/223] testing IP exemption, handle corner cases found in testing --- composer.json | 2 +- composer.lock | 12 ++++++------ lib/Persistence/TrafficLimiter.php | 13 ++++++++----- tst/Persistence/TrafficLimiterTest.php | 15 +++++++++++++++ vendor/paragonie/random_compat/lib/random.php | 19 ++++++++++--------- .../random_compat/phpunit-autoload.php | 14 -------------- 6 files changed, 40 insertions(+), 35 deletions(-) delete mode 100644 vendor/paragonie/random_compat/phpunit-autoload.php diff --git a/composer.json b/composer.json index 98aaedde..a8e98aaa 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ }, "require" : { "php" : "^5.6.0 || ^7.0 || ^8.0", - "paragonie/random_compat" : "2.0.19", + "paragonie/random_compat" : "2.0.20", "yzalis/identicon" : "2.0.0", "mlocati/ip-lib" : "1.14.0" }, diff --git a/composer.lock b/composer.lock index 20b0732a..931c92fb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c3aa7487ba976536cd3db9a60473ce67", + "content-hash": "217f0ba9bdac1014a332a8ba390be949", "packages": [ { "name": "mlocati/ip-lib", @@ -76,16 +76,16 @@ }, { "name": "paragonie/random_compat", - "version": "v2.0.19", + "version": "v2.0.20", "source": { "type": "git", "url": "https://github.com/paragonie/random_compat.git", - "reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241" + "reference": "0f1f60250fccffeaf5dda91eea1c018aed1adc2a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/446fc9faa5c2a9ddf65eb7121c0af7e857295241", - "reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/0f1f60250fccffeaf5dda91eea1c018aed1adc2a", + "reference": "0f1f60250fccffeaf5dda91eea1c018aed1adc2a", "shasum": "" }, "require": { @@ -121,7 +121,7 @@ "pseudorandom", "random" ], - "time": "2020-10-15T10:06:57+00:00" + "time": "2021-04-17T09:33:01+00:00" }, { "name": "yzalis/identicon", diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index af6e4979..612a1c91 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -121,19 +121,22 @@ class TrafficLimiter extends AbstractPersistence $address = \IPLib\Factory::addressFromString($_SERVER[self::$_ipKey]); $range = \IPLib\Factory::rangeFromString(trim($ipRange)); - // If $range is null something went wrong (possible invalid ip given in config). It's here becaue matches($range) does not accepts null vallue + // address could not be parsed, we might not be in IP space and try a string comparison instead + if ($address == null) { + return $_SERVER[self::$_ipKey] === $ipRange; + } + // range could not be parsed, possibly an invalid ip range given in config if ($range == null) { return false; } - // Ip-lib does throws and exception when something goes wrong, if so we want to catch it and set contained to false + // Ip-lib throws an exception when something goes wrong, if so we want to catch it and set contained to false try { return $address->matches($range); } catch (\Exception $e) { - // If something is wrong with matching the ip, we do nothing + // If something is wrong with matching the ip, we assume it doesn't match + return false; } - - return false; } /** diff --git a/tst/Persistence/TrafficLimiterTest.php b/tst/Persistence/TrafficLimiterTest.php index 73769380..41013016 100644 --- a/tst/Persistence/TrafficLimiterTest.php +++ b/tst/Persistence/TrafficLimiterTest.php @@ -35,5 +35,20 @@ class TrafficLimiterTest extends PHPUnit_Framework_TestCase $this->assertTrue(TrafficLimiter::canPass(), 'fourth request has different ip and may pass'); $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; $this->assertFalse(TrafficLimiter::canPass(), 'fifth request is to fast, may not pass'); + + // exempted IPs configuration + TrafficLimiter::setExemptedIp('1.2.3.4,10.10.10.0/24,2001:1620:2057::/48'); + $this->assertFalse(TrafficLimiter::canPass(), 'still too fast and not exempted'); + $_SERVER['REMOTE_ADDR'] = '10.10.10.10'; + $this->assertTrue(TrafficLimiter::canPass(), 'IPv4 in exempted range'); + $this->assertTrue(TrafficLimiter::canPass(), 'request is to fast, but IPv4 in exempted range'); + $_SERVER['REMOTE_ADDR'] = '2001:1620:2057:dead:beef::cafe:babe'; + $this->assertTrue(TrafficLimiter::canPass(), 'IPv6 in exempted range'); + $this->assertTrue(TrafficLimiter::canPass(), 'request is to fast, but IPv6 in exempted range'); + TrafficLimiter::setExemptedIp('127.*,foobar'); + $this->assertFalse(TrafficLimiter::canPass(), 'request is to fast, invalid range'); + $_SERVER['REMOTE_ADDR'] = 'foobar'; + $this->assertTrue(TrafficLimiter::canPass(), 'non-IP address'); + $this->assertTrue(TrafficLimiter::canPass(), 'request is to fast, but non-IP address matches exempted range'); } } diff --git a/vendor/paragonie/random_compat/lib/random.php b/vendor/paragonie/random_compat/lib/random.php index 36245f54..6df1cb0c 100644 --- a/vendor/paragonie/random_compat/lib/random.php +++ b/vendor/paragonie/random_compat/lib/random.php @@ -54,9 +54,9 @@ if (!defined('RANDOM_COMPAT_READ_BUFFER')) { $RandomCompatDIR = dirname(__FILE__); -require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'byte_safe_strings.php'; -require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'cast_to_int.php'; -require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'error_polyfill.php'; +require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'byte_safe_strings.php'; +require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'cast_to_int.php'; +require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'error_polyfill.php'; if (!is_callable('random_bytes')) { /** @@ -76,9 +76,9 @@ if (!is_callable('random_bytes')) { if (extension_loaded('libsodium')) { // See random_bytes_libsodium.php if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) { - require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_libsodium.php'; + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium.php'; } elseif (method_exists('Sodium', 'randombytes_buf')) { - require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_libsodium_legacy.php'; + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium_legacy.php'; } } @@ -117,7 +117,7 @@ if (!is_callable('random_bytes')) { // place, that is not helpful to us here. // See random_bytes_dev_urandom.php - require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_dev_urandom.php'; + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_dev_urandom.php'; } // Unset variables after use $RandomCompat_basedir = null; @@ -159,7 +159,7 @@ if (!is_callable('random_bytes')) { extension_loaded('mcrypt') ) { // See random_bytes_mcrypt.php - require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_mcrypt.php'; + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_mcrypt.php'; } $RandomCompatUrandom = null; @@ -182,9 +182,10 @@ if (!is_callable('random_bytes')) { if (!in_array('com', $RandomCompat_disabled_classes)) { try { $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); + /** @psalm-suppress TypeDoesNotContainType */ if (method_exists($RandomCompatCOMtest, 'GetRandom')) { // See random_bytes_com_dotnet.php - require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_com_dotnet.php'; + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_com_dotnet.php'; } } catch (com_exception $e) { // Don't try to use it. @@ -219,7 +220,7 @@ if (!is_callable('random_bytes')) { } if (!is_callable('random_int')) { - require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_int.php'; + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_int.php'; } $RandomCompatDIR = null; diff --git a/vendor/paragonie/random_compat/phpunit-autoload.php b/vendor/paragonie/random_compat/phpunit-autoload.php deleted file mode 100644 index 87b01aac..00000000 --- a/vendor/paragonie/random_compat/phpunit-autoload.php +++ /dev/null @@ -1,14 +0,0 @@ -= 5.3 - * - * Class PHPUnit_Framework_TestCase - */ -if (PHP_VERSION_ID >= 50300) { - if (!class_exists('PHPUnit_Framework_TestCase')) { - require_once __DIR__ . '/other/phpunit-shim.php'; - } -} From 84771d716713a51aadc84ab2721c01f7c21fc97e Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 22 May 2021 11:01:16 +0200 Subject: [PATCH 146/223] documenting changes --- CHANGELOG.md | 2 ++ CREDITS.md | 1 + 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e416b9e..0a8ed407 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ * ADDED: new HTTP headers improving security (#765) * ADDED: Download button for paste text (#774) * ADDED: Opt-out of federated learning of cohorts (FLoC) (#776) + * ADDED: Configuration option to exempt ips from the rate-limiter (#787) * CHANGED: Language selection cookie only transmitted over HTTPS (#472) + * CHANGED: Upgrading libraries to: random_compat 2.0.20 * **1.3.5 (2021-04-05)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan * ADDED: Make the project info configurable (#681) diff --git a/CREDITS.md b/CREDITS.md index 1aabf6f1..338c2df6 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -27,6 +27,7 @@ Sébastien Sauvage - original idea and main developer * Harald Leithner - base58 encoding of key * Haocen - lots of bugfixes and UI improvements * Lucas Savva - configurable config file location, NixOS packaging +* rodehoed - option to exempt ips from the rate-limiter ## Translations * Hexalyse - French From 91c8f9f23c9a302c567b328eef73eb49540f2872 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 22 May 2021 11:02:54 +0200 Subject: [PATCH 147/223] use namespaces --- lib/Persistence/TrafficLimiter.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 612a1c91..dedf588f 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -13,6 +13,8 @@ namespace PrivateBin\Persistence; +use Exception; +use IPLib\Factory; use PrivateBin\Configuration; /** @@ -118,8 +120,8 @@ class TrafficLimiter extends AbstractPersistence private static function matchIp($ipRange = null) { // Match $_ipKey to $ipRange and if it matches it will return with a true - $address = \IPLib\Factory::addressFromString($_SERVER[self::$_ipKey]); - $range = \IPLib\Factory::rangeFromString(trim($ipRange)); + $address = Factory::addressFromString($_SERVER[self::$_ipKey]); + $range = Factory::rangeFromString(trim($ipRange)); // address could not be parsed, we might not be in IP space and try a string comparison instead if ($address == null) { @@ -133,7 +135,7 @@ class TrafficLimiter extends AbstractPersistence // Ip-lib throws an exception when something goes wrong, if so we want to catch it and set contained to false try { return $address->matches($range); - } catch (\Exception $e) { + } catch (Exception $e) { // If something is wrong with matching the ip, we assume it doesn't match return false; } From b6460616baa2d7f0a940dffd3f5b5efb9ecd00fd Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 22 May 2021 11:30:17 +0200 Subject: [PATCH 148/223] address Scrutinizer issues --- lib/Persistence/TrafficLimiter.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index dedf588f..b45dcf81 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -38,7 +38,7 @@ class TrafficLimiter extends AbstractPersistence * * @access private * @static - * @var array + * @var string|null */ private static $_exemptedIp = null; @@ -110,7 +110,7 @@ class TrafficLimiter extends AbstractPersistence } /** - * Validate $_ipKey against configured ipranges. If matched ratelimiter will ignore ip + * Validate $_ipKey against configured ipranges. If matched we will ignore the ip * * @access private * @static @@ -119,9 +119,11 @@ class TrafficLimiter extends AbstractPersistence */ private static function matchIp($ipRange = null) { - // Match $_ipKey to $ipRange and if it matches it will return with a true + if (is_string($ipRange)) { + $ipRange = trim($ipRange); + } $address = Factory::addressFromString($_SERVER[self::$_ipKey]); - $range = Factory::rangeFromString(trim($ipRange)); + $range = Factory::rangeFromString($ipRange); // address could not be parsed, we might not be in IP space and try a string comparison instead if ($address == null) { @@ -148,7 +150,7 @@ class TrafficLimiter extends AbstractPersistence * * @access public * @static - * @throws \Exception + * @throws Exception * @return bool */ public static function canPass() From 7de12d64d532f9cc28c8122b9e553b257bd18b75 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 22 May 2021 11:35:53 +0200 Subject: [PATCH 149/223] be more precise --- lib/Persistence/TrafficLimiter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index b45dcf81..be76b8cd 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -126,11 +126,11 @@ class TrafficLimiter extends AbstractPersistence $range = Factory::rangeFromString($ipRange); // address could not be parsed, we might not be in IP space and try a string comparison instead - if ($address == null) { + if (is_null($address)) { return $_SERVER[self::$_ipKey] === $ipRange; } // range could not be parsed, possibly an invalid ip range given in config - if ($range == null) { + if (is_null($range)) { return false; } From dae093bbfa73fff54ae6521d81d6d5f4bbd0d226 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Mon, 24 May 2021 11:40:34 +0200 Subject: [PATCH 150/223] import latest scrutinizer configuration from web backend --- .gitattributes | 1 + .scrutinizer.yml | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .scrutinizer.yml diff --git a/.gitattributes b/.gitattributes index ef060615..28b68d13 100644 --- a/.gitattributes +++ b/.gitattributes @@ -16,6 +16,7 @@ js/test/ export-ignore .jshintrc export-ignore .nsprc export-ignore .php_cs export-ignore +.scrutinizer.yml export-ignore .styleci.yml export-ignore .travis.yml export-ignore composer.json export-ignore diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 00000000..e3c8fe1b --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,36 @@ +checks: + php: true + javascript: true +filter: + paths: + - "css/privatebin.css" + - "css/bootstrap/privatebin.css" + - "js/privatebin.js" + - "lib/*.php" + - "index.php" +coding_style: + php: + spaces: + around_operators: + additive: false + concatenation: true +build: + environment: + php: + version: '7.2' + tests: + override: + - + command: 'cd tst && ../vendor/bin/phpunit' + coverage: + file: 'tst/log/coverage-clover.xml' + format: 'clover' + nodes: + tests: true + analysis: + tests: + override: + - + command: phpcs-run + use_website_config: true + - php-scrutinizer-run From 342270d6dd82e956313cb93008a1bd37576321c5 Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Fri, 28 May 2021 22:39:50 +0200 Subject: [PATCH 151/223] added Google Cloud Storage support --- .gitattributes | 1 + .github/workflows/tests.yml | 4 + .gitignore | 4 +- .scrutinizer.yml | 39 ++ INSTALL.md | 12 + cfg/conf.sample.php | 7 + composer.json | 5 +- composer.lock | 132 ++++- lib/Configuration.php | 10 + lib/Data/GoogleCloudStorage.php | 251 +++++++++ lib/Persistence/TrafficLimiter.php | 4 +- tst/Data/GoogleCloudStorageTest.php | 715 ++++++++++++++++++++++++++ vendor/composer/ClassLoader.php | 40 +- vendor/composer/InstalledVersions.php | 326 ++++++++++++ vendor/composer/autoload_classmap.php | 2 + vendor/composer/autoload_real.php | 6 +- vendor/composer/autoload_static.php | 2 + vendor/composer/installed.php | 51 ++ vendor/composer/platform_check.php | 26 + 19 files changed, 1621 insertions(+), 16 deletions(-) create mode 100644 .scrutinizer.yml create mode 100644 lib/Data/GoogleCloudStorage.php create mode 100644 tst/Data/GoogleCloudStorageTest.php create mode 100644 vendor/composer/InstalledVersions.php create mode 100644 vendor/composer/installed.php create mode 100644 vendor/composer/platform_check.php diff --git a/.gitattributes b/.gitattributes index ef060615..28b68d13 100644 --- a/.gitattributes +++ b/.gitattributes @@ -16,6 +16,7 @@ js/test/ export-ignore .jshintrc export-ignore .nsprc export-ignore .php_cs export-ignore +.scrutinizer.yml export-ignore .styleci.yml export-ignore .travis.yml export-ignore composer.json export-ignore diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c1ac3d9c..c4bfae67 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,6 +11,8 @@ jobs: run: composer validate - name: Install dependencies run: /usr/bin/php7.4 $(which composer) install --prefer-dist --no-suggest + - name: Install Google Cloud Storage + run: /usr/bin/php7.4 $(which composer) require google/cloud-storage PHPunit: runs-on: ubuntu-latest strategy: @@ -29,6 +31,8 @@ jobs: run: rm composer.lock - name: Setup PHPunit run: composer install -n + - name: Install Google Cloud Storage + run: composer require google/cloud-storage - name: Run unit tests run: ../vendor/bin/phpunit --no-coverage working-directory: tst diff --git a/.gitignore b/.gitignore index a4cd2bb6..65ef7189 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ cfg/* !cfg/.htaccess # Ignore data/ -data/ +/data/ # Ignore PhpDoc doc/* @@ -36,3 +36,5 @@ tst/ConfigurationCombinationsTest.php .project .externalToolBuilders .c9 +/.idea/ +*.iml diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 00000000..e6957a51 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,39 @@ +checks: + php: true + javascript: true +filter: + paths: + - "css/privatebin.css" + - "css/bootstrap/privatebin.css" + - "js/privatebin.js" + - "lib/*.php" + - "index.php" + excluded_paths: + - lib/Data/GoogleCloudStorage.php + - tst/Data/GoogleCloudStorageTest.php +coding_style: + php: + spaces: + around_operators: + additive: false + concatenation: true +build: + environment: + php: + version: '7.2' + tests: + override: + - + command: 'composer require google/cloud-storage && cd tst && ../vendor/bin/phpunit' + coverage: + file: 'tst/log/coverage-clover.xml' + format: 'clover' + nodes: + tests: true + analysis: + tests: + override: + - + command: phpcs-run + use_website_config: true + - php-scrutinizer-run diff --git a/INSTALL.md b/INSTALL.md index df0cac23..ec0d7f48 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -191,3 +191,15 @@ INSERT INTO prefix_config VALUES('VERSION', '1.3.5'); ``` In **PostgreSQL**, the data, attachment, nickname and vizhash columns needs to be TEXT and not BLOB or MEDIUMBLOB. + +### Using Google Cloud Storage +If you want to deploy PrivateBin in a serverless manner, you can choose the `GoogleCloudStorage` as backend. +To use this backend, you create a GCS bucket and specify the name as the model option `bucket`. Alternatively, +you can set the name through the environment variable PASTEBIN_GCS_BUCKET. + +The default prefix for pastes stored in the bucket is `pastes`. To change the prefix, specify the option `prefix`. + +Google Cloud Storage buckets may be significantly slower than a `FileSystem` or `Database` backend. The big advantage +is that the deployment on Google Cloud Platform using Google Cloud Run is easy and cheap. + +To use the Google Cloud Storage backend you have to install the suggested google/cloud-storage library. diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php index e9e500b0..a4b7f6b5 100644 --- a/cfg/conf.sample.php +++ b/cfg/conf.sample.php @@ -167,6 +167,13 @@ class = Filesystem [model_options] dir = PATH "data" +[model] +; example of a Google Cloud Storage configuration +;class = GoogleCloudStorage +;[model_options] +;bucket = "my-private-bin" +;prefix = "pastes" + ;[model] ; example of DB configuration for MySQL ;class = Database diff --git a/composer.json b/composer.json index a8e98aaa..6f507778 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,9 @@ "yzalis/identicon" : "2.0.0", "mlocati/ip-lib" : "1.14.0" }, + "suggest": { + "google/cloud-storage": "1.23.1" + }, "require-dev" : { "phpunit/phpunit" : "^4.6 || ^5.0" }, @@ -40,4 +43,4 @@ "config" : { "autoloader-suffix" : "DontChange" } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 931c92fb..96183d1e 100644 --- a/composer.lock +++ b/composer.lock @@ -62,6 +62,10 @@ "range", "subnet" ], + "support": { + "issues": "https://github.com/mlocati/ip-lib/issues", + "source": "https://github.com/mlocati/ip-lib/tree/1.14.0" + }, "funding": [ { "url": "https://github.com/sponsors/mlocati", @@ -121,6 +125,11 @@ "pseudorandom", "random" ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, "time": "2021-04-17T09:33:01+00:00" }, { @@ -173,6 +182,10 @@ "identicon", "image" ], + "support": { + "issues": "https://github.com/yzalis/Identicon/issues", + "source": "https://github.com/yzalis/Identicon/tree/master" + }, "abandoned": true, "time": "2019-10-14T09:30:57+00:00" } @@ -227,6 +240,10 @@ "constructor", "instantiate" ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + }, "funding": [ { "url": "https://www.doctrine-project.org/sponsorship.html", @@ -289,6 +306,10 @@ "object", "object graph" ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + }, "funding": [ { "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", @@ -344,6 +365,10 @@ "reflection", "static analysis" ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, "time": "2020-06-27T09:03:43+00:00" }, { @@ -396,6 +421,10 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + }, "time": "2020-09-03T19:13:55+00:00" }, { @@ -441,6 +470,10 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" + }, "time": "2020-09-17T18:55:26+00:00" }, { @@ -504,6 +537,10 @@ "spy", "stub" ], + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/v1.10.3" + }, "time": "2020-03-05T15:02:03+00:00" }, { @@ -567,6 +604,11 @@ "testing", "xunit" ], + "support": { + "irc": "irc://irc.freenode.net/phpunit", + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/4.0" + }, "time": "2017-04-02T07:44:40+00:00" }, { @@ -614,6 +656,11 @@ "filesystem", "iterator" ], + "support": { + "irc": "irc://irc.freenode.net/phpunit", + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/1.4.5" + }, "time": "2017-11-27T13:52:08+00:00" }, { @@ -655,6 +702,10 @@ "keywords": [ "template" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" + }, "time": "2015-06-21T13:50:34+00:00" }, { @@ -704,6 +755,10 @@ "keywords": [ "timer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/master" + }, "time": "2017-02-26T11:10:40+00:00" }, { @@ -753,6 +808,10 @@ "keywords": [ "tokenizer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" + }, "abandoned": true, "time": "2017-11-27T05:48:46+00:00" }, @@ -836,6 +895,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/5.7.27" + }, "time": "2018-02-01T05:50:59+00:00" }, { @@ -895,6 +958,11 @@ "mock", "xunit" ], + "support": { + "irc": "irc://irc.freenode.net/phpunit", + "issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues", + "source": "https://github.com/sebastianbergmann/phpunit-mock-objects/tree/3.4" + }, "abandoned": true, "time": "2017-06-30T09:13:00+00:00" }, @@ -941,6 +1009,10 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1011,6 +1083,10 @@ "compare", "equality" ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/1.2" + }, "time": "2017-01-29T09:50:25+00:00" }, { @@ -1063,6 +1139,10 @@ "keywords": [ "diff" ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/1.4" + }, "time": "2017-05-22T07:24:03+00:00" }, { @@ -1113,6 +1193,10 @@ "environment", "hhvm" ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/master" + }, "time": "2016-11-26T07:53:53+00:00" }, { @@ -1180,6 +1264,10 @@ "export", "exporter" ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/master" + }, "time": "2016-11-19T08:54:04+00:00" }, { @@ -1231,6 +1319,10 @@ "keywords": [ "global state" ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/1.1.1" + }, "time": "2015-10-12T03:26:01+00:00" }, { @@ -1277,6 +1369,10 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/master" + }, "time": "2017-02-18T15:18:39+00:00" }, { @@ -1330,6 +1426,10 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/master" + }, "time": "2016-11-19T07:33:16+00:00" }, { @@ -1372,6 +1472,10 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/master" + }, "time": "2015-07-28T20:34:47+00:00" }, { @@ -1415,20 +1519,24 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/master" + }, "time": "2016-10-03T07:35:21+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.22.1", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", - "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", "shasum": "" }, "require": { @@ -1440,7 +1548,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.22-dev" + "dev-main": "1.23-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1477,6 +1585,9 @@ "polyfill", "portable" ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -1491,7 +1602,7 @@ "type": "tidelift" } ], - "time": "2021-01-07T16:49:33+00:00" + "time": "2021-02-19T12:13:01+00:00" }, { "name": "symfony/yaml", @@ -1545,6 +1656,9 @@ ], "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/yaml/tree/v4.4.24" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -1613,6 +1727,10 @@ "check", "validate" ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.10.0" + }, "time": "2021-03-09T10:59:23+00:00" } ], @@ -1625,5 +1743,5 @@ "php": "^5.6.0 || ^7.0 || ^8.0" }, "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } diff --git a/lib/Configuration.php b/lib/Configuration.php index 5de6de3a..1e92fc9b 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -153,6 +153,16 @@ class Configuration 'pwd' => null, 'opt' => array(PDO::ATTR_PERSISTENT => true), ); + } elseif ( + $section == 'model_options' && in_array( + $this->_configuration['model']['class'], + array('GoogleCloudStorage') + ) + ) { + $values = array( + 'bucket' => getenv('PRIVATEBIN_GCS_BUCKET') ? getenv('PRIVATEBIN_GCS_BUCKET') : null, + 'prefix' => 'pastes', + ); } // "*_options" sections don't require all defaults to be set diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php new file mode 100644 index 00000000..1a1d8bf5 --- /dev/null +++ b/lib/Data/GoogleCloudStorage.php @@ -0,0 +1,251 @@ +_client = new StorageClient(array('suppressKeyFileNotice' => true)); + } else { + // use given client for test purposes + $this->_client = $client; + } + + $this->_bucket = $this->_client->bucket($bucket); + if ($prefix != null) { + $this->_prefix = $prefix; + } + } + + /** + * returns the google storage object key for $pasteid in $this->_bucket. + * @param $pasteid string to get the key for + * @return string + */ + private function _getKey($pasteid) + { + if ($this->_prefix != '') { + return $this->_prefix . '/' . $pasteid; + } + return $pasteid; + } + + /** + * Uploads the payload in the $this->_bucket under the specified key. + * The entire payload is stored as a JSON document. The metadata is replicated + * as the GCS object's metadata except for the fields attachment, attachmentname + * and salt. + * + * @param $key string to store the payload under + * @param $payload array to store + * @return bool true if successful, otherwise false. + */ + private function upload($key, $payload) + { + $metadata = array_key_exists('meta', $payload) ? $payload['meta'] : array(); + unset($metadata['attachment'], $metadata['attachmentname'], $metadata['salt']); + foreach ($metadata as $k => $v) { + $metadata[$k] = strval($v); + } + try { + $this->_bucket->upload(Json::encode($payload), array( + 'name' => $key, + 'chunkSize' => 262144, + 'predefinedAcl' => 'private', + 'metadata' => array( + 'content-type' => 'application/json', + 'metadata' => $metadata, + ), + )); + } catch (Exception $e) { + error_log('failed to upload ' . $key . ' to ' . $this->_bucket->name() . ', ' . + trim(preg_replace('/\s\s+/', ' ', $e->getMessage()))); + return false; + } + return true; + } + + /** + * @inheritDoc + */ + public function create($pasteid, array $paste) + { + if ($this->exists($pasteid)) { + return false; + } + + return $this->upload($this->_getKey($pasteid), $paste); + } + + /** + * @inheritDoc + */ + public function read($pasteid) + { + try { + $o = $this->_bucket->object($this->_getKey($pasteid)); + $data = $o->downloadAsString(); + return Json::decode($data); + } catch (NotFoundException $e) { + return false; + } catch (Exception $e) { + error_log('failed to read ' . $pasteid . ' from ' . $this->_bucket->name() . ', ' . + trim(preg_replace('/\s\s+/', ' ', $e->getMessage()))); + return false; + } + } + + /** + * @inheritDoc + */ + public function delete($pasteid) + { + $name = $this->_getKey($pasteid); + + try { + foreach ($this->_bucket->objects(array('prefix' => $name . '/discussion/')) as $comment) { + try { + $this->_bucket->object($comment->name())->delete(); + } catch (NotFoundException $e) { + // ignore if already deleted. + } + } + } catch (NotFoundException $e) { + // there are no discussions associated with the paste + } + + try { + $this->_bucket->object($name)->delete(); + } catch (NotFoundException $e) { + // ignore if already deleted + } + } + + /** + * @inheritDoc + */ + public function exists($pasteid) + { + $o = $this->_bucket->object($this->_getKey($pasteid)); + return $o->exists(); + } + + /** + * @inheritDoc + */ + public function createComment($pasteid, $parentid, $commentid, array $comment) + { + if ($this->existsComment($pasteid, $parentid, $commentid)) { + return false; + } + $key = $this->_getKey($pasteid) . '/discussion/' . $parentid . '/' . $commentid; + return $this->upload($key, $comment); + } + + /** + * @inheritDoc + */ + public function readComments($pasteid) + { + $comments = array(); + $prefix = $this->_getKey($pasteid) . '/discussion/'; + try { + foreach ($this->_bucket->objects(array('prefix' => $prefix)) as $key) { + $comment = JSON::decode($this->_bucket->object($key->name())->downloadAsString()); + $comment['id'] = basename($key->name()); + $slot = $this->getOpenSlot($comments, (int) $comment['meta']['created']); + $comments[$slot] = $comment; + } + } catch (NotFoundException $e) { + // no comments found + } + return $comments; + } + + /** + * @inheritDoc + */ + public function existsComment($pasteid, $parentid, $commentid) + { + $name = $this->_getKey($pasteid) . '/discussion/' . $parentid . '/' . $commentid; + $o = $this->_bucket->object($name); + return $o->exists(); + } + + /** + * @inheritDoc + */ + protected function _getExpiredPastes($batchsize) + { + $expired = array(); + + $now = time(); + $prefix = $this->_prefix; + if ($prefix != '') { + $prefix = $prefix . '/'; + } + try { + foreach ($this->_bucket->objects(array('prefix' => $prefix)) as $object) { + $metadata = $object->info()['metadata']; + if ($metadata != null && array_key_exists('expire_date', $metadata)) { + $expire_at = intval($metadata['expire_date']); + if ($expire_at != 0 && $expire_at < $now) { + array_push($expired, basename($object->name())); + } + } + + if (count($expired) > $batchsize) { + break; + } + } + } catch (NotFoundException $e) { + // no objects in the bucket yet + } + return $expired; + } +} diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index b45dcf81..be76b8cd 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -126,11 +126,11 @@ class TrafficLimiter extends AbstractPersistence $range = Factory::rangeFromString($ipRange); // address could not be parsed, we might not be in IP space and try a string comparison instead - if ($address == null) { + if (is_null($address)) { return $_SERVER[self::$_ipKey] === $ipRange; } // range could not be parsed, possibly an invalid ip range given in config - if ($range == null) { + if (is_null($range)) { return false; } diff --git a/tst/Data/GoogleCloudStorageTest.php b/tst/Data/GoogleCloudStorageTest.php new file mode 100644 index 00000000..91a5ca99 --- /dev/null +++ b/tst/Data/GoogleCloudStorageTest.php @@ -0,0 +1,715 @@ +false)); + $handler = HttpHandlerFactory::build($httpClient); + + $name = 'pb-'; + $alphabet = 'abcdefghijklmnopqrstuvwxyz'; + for ($i = 0; $i < 29; ++$i) { + $name .= $alphabet[rand(0, strlen($alphabet) - 1)]; + } + self::$_client = new StorageClientStub(array()); + self::$_bucket = self::$_client->createBucket($name); + } + + public function setUp() + { + // do not report E_NOTICE as fsouza/fake-gcs-server does not return a `generation` value in the response + // which the Google Cloud Storage PHP library expects. + error_reporting(E_ERROR | E_WARNING | E_PARSE); + $this->_model = GoogleCloudStorage::getInstance(array( + 'bucket' => self::$_bucket->name(), + 'prefix' => 'pastes', + 'client' => self::$_client, )); + } + + public function tearDown() + { + foreach (self::$_bucket->objects() as $object) { + $object->delete(); + } + error_reporting(E_ALL); + } + + public static function tearDownAfterClass() + { + self::$_bucket->delete(); + } + + public function testFileBasedDataStoreWorks() + { + $this->_model->delete(Helper::getPasteId()); + + // storing pastes + $paste = Helper::getPaste(2, array('expire_date' => 1344803344)); + $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist'); + $this->assertTrue($this->_model->create(Helper::getPasteId(), $paste), 'store new paste'); + $this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists after storing it'); + $this->assertFalse($this->_model->create(Helper::getPasteId(), $paste), 'unable to store the same paste twice'); + $this->assertEquals($paste, $this->_model->read(Helper::getPasteId())); + + // storing comments + $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment does not yet exist'); + $this->assertTrue($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), Helper::getComment()), 'store comment'); + $this->assertTrue($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment exists after storing it'); + $this->assertFalse($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), Helper::getComment()), 'unable to store the same comment twice'); + $comment = Helper::getComment(); + $comment['id'] = Helper::getCommentId(); + $comment['parentid'] = Helper::getPasteId(); + $this->assertEquals( + array($comment['meta']['created'] => $comment), + $this->_model->readComments(Helper::getPasteId()) + ); + + // deleting pastes + $this->_model->delete(Helper::getPasteId()); + $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste successfully deleted'); + $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment was deleted with paste'); + $this->assertFalse($this->_model->read(Helper::getPasteId()), 'paste can no longer be found'); + } + + /** + * pastes a-g are expired and should get deleted, x never expires and y-z expire in an hour + */ + public function testPurge() + { + $expired = Helper::getPaste(2, array('expire_date' => 1344803344)); + $paste = Helper::getPaste(2, array('expire_date' => time() + 3600)); + $keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z'); + $ids = array(); + foreach ($keys as $key) { + $ids[$key] = hash('fnv164', $key); + $this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist"); + if (in_array($key, array('x', 'y', 'z'))) { + $this->assertTrue($this->_model->create($ids[$key], $paste), "store $key paste"); + } elseif ($key === 'x') { + $this->assertTrue($this->_model->create($ids[$key], Helper::getPaste()), "store $key paste"); + } else { + $this->assertTrue($this->_model->create($ids[$key], $expired), "store $key paste"); + } + $this->assertTrue($this->_model->exists($ids[$key]), "paste $key exists after storing it"); + } + $this->_model->purge(10); + foreach ($ids as $key => $id) { + if (in_array($key, array('x', 'y', 'z'))) { + $this->assertTrue($this->_model->exists($id), "paste $key exists after purge"); + $this->_model->delete($id); + } else { + $this->assertFalse($this->_model->exists($id), "paste $key was purged"); + } + } + } + + public function testErrorDetection() + { + $this->_model->delete(Helper::getPasteId()); + $paste = Helper::getPaste(2, array('expire' => "Invalid UTF-8 sequence: \xB1\x31")); + $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist'); + $this->assertFalse($this->_model->create(Helper::getPasteId(), $paste), 'unable to store broken paste'); + $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does still not exist'); + } + + public function testCommentErrorDetection() + { + $this->_model->delete(Helper::getPasteId()); + $comment = Helper::getComment(1, array('nickname' => "Invalid UTF-8 sequence: \xB1\x31")); + $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist'); + $this->assertTrue($this->_model->create(Helper::getPasteId(), Helper::getPaste()), 'store new paste'); + $this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists after storing it'); + $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment does not yet exist'); + $this->assertFalse($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), $comment), 'unable to store broken comment'); + $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment does still not exist'); + } +} + +/** + * Class StorageClientStub provides a limited stub for performing the unit test + */ +class StorageClientStub extends StorageClient +{ + private $_config = null; + private $_connection = null; + private $_buckets = array(); + + public function __construct(array $config = array()) + { + $this->_config = $config; + $this->_connection = new ConnectionInterfaceStub(); + } + + public function bucket($name, $userProject = false) + { + if (!key_exists($name, $this->_buckets)) { + $b = new BucketStub($this->_connection, $name, array(), $this); + $this->_buckets[$name] = $b; + } + return $this->_buckets[$name]; + } + + /** + * @throws \Google\Cloud\Core\Exception\NotFoundException + */ + public function deleteBucket($name) + { + if (key_exists($name, $this->_buckets)) { + unset($this->_buckets[$name]); + } else { + throw new NotFoundException(); + } + } + + public function buckets(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function registerStreamWrapper($protocol = null) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function unregisterStreamWrapper($protocol = null) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function signedUrlUploader($uri, $data, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function timestamp(\DateTimeInterface $timestamp, $nanoSeconds = null) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getServiceAccount(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function hmacKeys(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function hmacKey($accessId, $projectId = null, array $metadata = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function createHmacKey($serviceAccountEmail, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function createBucket($name, array $options = array()) + { + if (key_exists($name, $this->_buckets)) { + throw new BadRequestException('already exists'); + } + $b = new BucketStub($this->_connection, $name, array(), $this); + $this->_buckets[$name] = $b; + return $b; + } +} + +/** + * Class BucketStub stubs a GCS bucket. + */ +class BucketStub extends Bucket +{ + public $_objects; + private $_name; + private $_info; + private $_connection; + private $_client; + + public function __construct(ConnectionInterface $connection, $name, array $info = array(), $client = null) + { + $this->_name = $name; + $this->_info = $info; + $this->_connection = $connection; + $this->_objects = array(); + $this->_client = $client; + } + + public function acl() + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function defaultAcl() + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function exists() + { + return true; + } + + public function upload($data, array $options = array()) + { + if (!is_string($data) || !key_exists('name', $options)) { + throw new BadMethodCallException('not supported by this stub'); + } + + $name = $options['name']; + $generation = '1'; + $o = new StorageObjectStub($this->_connection, $name, $this, $generation, $options); + $this->_objects[$options['name']] = $o; + $o->setData($data); + } + + public function uploadAsync($data, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getResumableUploader($data, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getStreamableUploader($data, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function object($name, array $options = array()) + { + if (key_exists($name, $this->_objects)) { + return $this->_objects[$name]; + } else { + return new StorageObjectStub($this->_connection, $name, $this, null, $options); + } + } + + public function objects(array $options = array()) + { + $prefix = key_exists('prefix', $options) ? $options['prefix'] : ''; + + return new CallbackFilterIterator( + new ArrayIterator($this->_objects), + function ($current, $key, $iterator) use ($prefix) { + return substr($key, 0, strlen($prefix)) == $prefix; + } + ); + } + + public function createNotification($topic, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function notification($id) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function notifications(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function delete(array $options = array()) + { + $this->_client->deleteBucket($this->_name); + } + + public function update(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function compose(array $sourceObjects, $name, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function info(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function reload(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function name() + { + return $this->_name; + } + + public static function lifecycle(array $lifecycle = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function currentLifecycle(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function isWritable($file = null) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function iam() + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function lockRetentionPolicy(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function signedUrl($expires, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function generateSignedPostPolicyV4($objectName, $expires, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } +} + +/** + * Class StorageObjectStub stubs a GCS storage object. + */ +class StorageObjectStub extends StorageObject +{ + private $_name; + private $_data; + private $_info; + private $_bucket; + private $_generation; + private $_exists = false; + private $_connection; + + public function __construct(ConnectionInterface $connection, $name, $bucket, $generation = null, array $info = array(), $encryptionKey = null, $encryptionKeySHA256 = null) + { + $this->_name = $name; + $this->_bucket = $bucket; + $this->_generation = $generation; + $this->_info = $info; + $this->_connection = $connection; + } + + public function acl() + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function exists(array $options = array()) + { + return key_exists($this->_name, $this->_bucket->_objects); + } + + /** + * @throws NotFoundException + */ + public function delete(array $options = array()) + { + if (key_exists($this->_name, $this->_bucket->_objects)) { + unset($this->_bucket->_objects[$this->_name]); + } else { + throw new NotFoundException('key ' . $this->_name . ' not found.'); + } + } + + /** + * @throws NotFoundException + */ + public function update(array $metadata, array $options = array()) + { + if (!$this->_exists) { + throw new NotFoundException('key ' . $this->_name . ' not found.'); + } + $this->_info = $metadata; + } + + public function copy($destination, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function rewrite($destination, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function rename($name, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + /** + * @throws NotFoundException + */ + public function downloadAsString(array $options = array()) + { + if (!$this->_exists) { + throw new NotFoundException('key ' . $this->_name . ' not found.'); + } + return $this->_data; + } + + public function downloadToFile($path, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function downloadAsStream(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function downloadAsStreamAsync(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function signedUrl($expires, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function signedUploadUrl($expires, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function beginSignedUploadSession(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function info(array $options = array()) + { + return key_exists('metadata',$this->_info) ? $this->_info['metadata'] : array(); + } + + public function reload(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function name() + { + return $this->_name; + } + + public function identity() + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function gcsUri() + { + return sprintf( + 'gs://%s/%s', + $this->_bucket->name(), + $this->_name + ); + } + + public function setData($data) + { + $this->_data = $data; + $this->_exists = true; + } +} + +/** + * Class ConnectionInterfaceStub required for the stubs. + */ +class ConnectionInterfaceStub implements ConnectionInterface +{ + public function deleteAcl(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getAcl(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function listAcl(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function insertAcl(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function patchAcl(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function deleteBucket(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getBucket(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function listBuckets(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function insertBucket(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getBucketIamPolicy(array $args) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function setBucketIamPolicy(array $args) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function testBucketIamPermissions(array $args) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function patchBucket(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function deleteObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function copyObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function rewriteObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function composeObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function listObjects(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function patchObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function downloadObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function insertObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getNotification(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function deleteNotification(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function insertNotification(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function listNotifications(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getServiceAccount(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function lockRetentionPolicy(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function createHmacKey(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function deleteHmacKey(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getHmacKey(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function updateHmacKey(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function listHmacKeys(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } +} diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index fce8549f..247294d6 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -37,11 +37,13 @@ namespace Composer\Autoload; * * @author Fabien Potencier * @author Jordi Boggiano - * @see http://www.php-fig.org/psr/psr-0/ - * @see http://www.php-fig.org/psr/psr-4/ + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ */ class ClassLoader { + private $vendorDir; + // PSR-4 private $prefixLengthsPsr4 = array(); private $prefixDirsPsr4 = array(); @@ -57,10 +59,17 @@ class ClassLoader private $missingClasses = array(); private $apcuPrefix; + private static $registeredLoaders = array(); + + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); @@ -300,6 +309,17 @@ class ClassLoader public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } } /** @@ -308,6 +328,10 @@ class ClassLoader public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } } /** @@ -367,6 +391,16 @@ class ClassLoader return $file; } + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + private function findFileWithExtension($class, $ext) { // PSR-4 lookup diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 00000000..9766d9b4 --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,326 @@ + + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => 'b6460616baa2d7f0a940dffd3f5b5efb9ecd00fd', + 'name' => 'privatebin/privatebin', + ), + 'versions' => + array ( + 'mlocati/ip-lib' => + array ( + 'pretty_version' => '1.14.0', + 'version' => '1.14.0.0', + 'aliases' => + array ( + ), + 'reference' => '882bc0e115970a536b13bcfa59f312783fce08c8', + ), + 'paragonie/random_compat' => + array ( + 'pretty_version' => 'v2.0.20', + 'version' => '2.0.20.0', + 'aliases' => + array ( + ), + 'reference' => '0f1f60250fccffeaf5dda91eea1c018aed1adc2a', + ), + 'privatebin/privatebin' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => 'b6460616baa2d7f0a940dffd3f5b5efb9ecd00fd', + ), + 'yzalis/identicon' => + array ( + 'pretty_version' => '2.0.0', + 'version' => '2.0.0.0', + 'aliases' => + array ( + ), + 'reference' => 'ff5ed090129cab9bfa2a322857d4a01d107aa0ae', + ), + ), +); +private static $canGetVendors; +private static $installedByVendor = array(); + + + + + + + +public static function getInstalledPackages() +{ +$packages = array(); +foreach (self::getInstalled() as $installed) { +$packages[] = array_keys($installed['versions']); +} + +if (1 === \count($packages)) { +return $packages[0]; +} + +return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); +} + + + + + + + + + +public static function isInstalled($packageName) +{ +foreach (self::getInstalled() as $installed) { +if (isset($installed['versions'][$packageName])) { +return true; +} +} + +return false; +} + + + + + + + + + + + + + + +public static function satisfies(VersionParser $parser, $packageName, $constraint) +{ +$constraint = $parser->parseConstraints($constraint); +$provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + +return $provided->matches($constraint); +} + + + + + + + + + + +public static function getVersionRanges($packageName) +{ +foreach (self::getInstalled() as $installed) { +if (!isset($installed['versions'][$packageName])) { +continue; +} + +$ranges = array(); +if (isset($installed['versions'][$packageName]['pretty_version'])) { +$ranges[] = $installed['versions'][$packageName]['pretty_version']; +} +if (array_key_exists('aliases', $installed['versions'][$packageName])) { +$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); +} +if (array_key_exists('replaced', $installed['versions'][$packageName])) { +$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); +} +if (array_key_exists('provided', $installed['versions'][$packageName])) { +$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); +} + +return implode(' || ', $ranges); +} + +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + + + + + +public static function getVersion($packageName) +{ +foreach (self::getInstalled() as $installed) { +if (!isset($installed['versions'][$packageName])) { +continue; +} + +if (!isset($installed['versions'][$packageName]['version'])) { +return null; +} + +return $installed['versions'][$packageName]['version']; +} + +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + + + + + +public static function getPrettyVersion($packageName) +{ +foreach (self::getInstalled() as $installed) { +if (!isset($installed['versions'][$packageName])) { +continue; +} + +if (!isset($installed['versions'][$packageName]['pretty_version'])) { +return null; +} + +return $installed['versions'][$packageName]['pretty_version']; +} + +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + + + + + +public static function getReference($packageName) +{ +foreach (self::getInstalled() as $installed) { +if (!isset($installed['versions'][$packageName])) { +continue; +} + +if (!isset($installed['versions'][$packageName]['reference'])) { +return null; +} + +return $installed['versions'][$packageName]['reference']; +} + +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + + + + + +public static function getRootPackage() +{ +$installed = self::getInstalled(); + +return $installed[0]['root']; +} + + + + + + + + +public static function getRawData() +{ +@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + +return self::$installed; +} + + + + + + + +public static function getAllRawData() +{ +return self::getInstalled(); +} + + + + + + + + + + + + + + + + + + + +public static function reload($data) +{ +self::$installed = $data; +self::$installedByVendor = array(); +} + + + + + +private static function getInstalled() +{ +if (null === self::$canGetVendors) { +self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); +} + +$installed = array(); + +if (self::$canGetVendors) { +foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { +if (isset(self::$installedByVendor[$vendorDir])) { +$installed[] = self::$installedByVendor[$vendorDir]; +} elseif (is_file($vendorDir.'/composer/installed.php')) { +$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; +} +} +} + +$installed[] = self::$installed; + +return $installed; +} +} diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 81358f5f..2abf65ec 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -6,6 +6,7 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( + 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', 'IPLib\\Address\\AddressInterface' => $vendorDir . '/mlocati/ip-lib/src/Address/AddressInterface.php', 'IPLib\\Address\\AssignedRange' => $vendorDir . '/mlocati/ip-lib/src/Address/AssignedRange.php', 'IPLib\\Address\\IPv4' => $vendorDir . '/mlocati/ip-lib/src/Address/IPv4.php', @@ -31,6 +32,7 @@ return array( 'PrivateBin\\Data\\AbstractData' => $baseDir . '/lib/Data/AbstractData.php', 'PrivateBin\\Data\\Database' => $baseDir . '/lib/Data/Database.php', 'PrivateBin\\Data\\Filesystem' => $baseDir . '/lib/Data/Filesystem.php', + 'PrivateBin\\Data\\GoogleCloudStorage' => $baseDir . '/lib/Data/GoogleCloudStorage.php', 'PrivateBin\\Filter' => $baseDir . '/lib/Filter.php', 'PrivateBin\\FormatV2' => $baseDir . '/lib/FormatV2.php', 'PrivateBin\\I18n' => $baseDir . '/lib/I18n.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 7a6fd4c0..fe68b5cb 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -22,13 +22,15 @@ class ComposerAutoloaderInitDontChange return self::$loader; } + require __DIR__ . '/platform_check.php'; + spl_autoload_register(array('ComposerAutoloaderInitDontChange', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); spl_autoload_unregister(array('ComposerAutoloaderInitDontChange', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { - require_once __DIR__ . '/autoload_static.php'; + require __DIR__ . '/autoload_static.php'; call_user_func(\Composer\Autoload\ComposerStaticInitDontChange::getInitializer($loader)); } else { diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 9197c946..cfe595dd 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -38,6 +38,7 @@ class ComposerStaticInitDontChange ); public static $classMap = array ( + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', 'IPLib\\Address\\AddressInterface' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Address/AddressInterface.php', 'IPLib\\Address\\AssignedRange' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Address/AssignedRange.php', 'IPLib\\Address\\IPv4' => __DIR__ . '/..' . '/mlocati/ip-lib/src/Address/IPv4.php', @@ -63,6 +64,7 @@ class ComposerStaticInitDontChange 'PrivateBin\\Data\\AbstractData' => __DIR__ . '/../..' . '/lib/Data/AbstractData.php', 'PrivateBin\\Data\\Database' => __DIR__ . '/../..' . '/lib/Data/Database.php', 'PrivateBin\\Data\\Filesystem' => __DIR__ . '/../..' . '/lib/Data/Filesystem.php', + 'PrivateBin\\Data\\GoogleCloudStorage' => __DIR__ . '/../..' . '/lib/Data/GoogleCloudStorage.php', 'PrivateBin\\Filter' => __DIR__ . '/../..' . '/lib/Filter.php', 'PrivateBin\\FormatV2' => __DIR__ . '/../..' . '/lib/FormatV2.php', 'PrivateBin\\I18n' => __DIR__ . '/../..' . '/lib/I18n.php', diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 00000000..56f2a5e4 --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,51 @@ + + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => 'b6460616baa2d7f0a940dffd3f5b5efb9ecd00fd', + 'name' => 'privatebin/privatebin', + ), + 'versions' => + array ( + 'mlocati/ip-lib' => + array ( + 'pretty_version' => '1.14.0', + 'version' => '1.14.0.0', + 'aliases' => + array ( + ), + 'reference' => '882bc0e115970a536b13bcfa59f312783fce08c8', + ), + 'paragonie/random_compat' => + array ( + 'pretty_version' => 'v2.0.20', + 'version' => '2.0.20.0', + 'aliases' => + array ( + ), + 'reference' => '0f1f60250fccffeaf5dda91eea1c018aed1adc2a', + ), + 'privatebin/privatebin' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => 'b6460616baa2d7f0a940dffd3f5b5efb9ecd00fd', + ), + 'yzalis/identicon' => + array ( + 'pretty_version' => '2.0.0', + 'version' => '2.0.0.0', + 'aliases' => + array ( + ), + 'reference' => 'ff5ed090129cab9bfa2a322857d4a01d107aa0ae', + ), + ), +); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 00000000..8b379f44 --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 50600)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} From 5c5ae967a862282db12fa5e11bfb6958c7a1c171 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sat, 29 May 2021 03:56:04 +0200 Subject: [PATCH 152/223] New translations en.json (Catalan) --- i18n/ca.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i18n/ca.json b/i18n/ca.json index a6936bed..89cad69b 100644 --- a/i18n/ca.json +++ b/i18n/ca.json @@ -8,9 +8,9 @@ "%s requires php %s or above to work. Sorry.": "%s requereix php %s o superior per funcionar. Ho sento.", "%s requires configuration section [%s] to be present in configuration file.": "%s requereix que la secció de configuració [%s] sigui present al fitxer de configuració.", "Please wait %d seconds between each post.": [ - "Please wait %d second between each post. (singular)", - "Please wait %d seconds between each post. (1st plural)", - "Please wait %d seconds between each post. (2nd plural)", + "Espereu %d segon entre cada entrada. (singular)", + "Espereu %d segons entre cada entrada. (1r plural)", + "Espereu %d segons entre cada entrada. (2n plural)", "Please wait %d seconds between each post. (3rd plural)" ], "Paste is limited to %s of encrypted data.": "Paste is limited to %s of encrypted data.", From de4bada695d8bb8b79be582b26839e7f7c124515 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Sat, 29 May 2021 04:56:21 +0200 Subject: [PATCH 153/223] New translations en.json (Catalan) --- i18n/ca.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/i18n/ca.json b/i18n/ca.json index 89cad69b..b2b86fe2 100644 --- a/i18n/ca.json +++ b/i18n/ca.json @@ -11,14 +11,14 @@ "Espereu %d segon entre cada entrada. (singular)", "Espereu %d segons entre cada entrada. (1r plural)", "Espereu %d segons entre cada entrada. (2n plural)", - "Please wait %d seconds between each post. (3rd plural)" + "Please wait %d seconds between each post. (3er plural)" ], - "Paste is limited to %s of encrypted data.": "Paste is limited to %s of encrypted data.", - "Invalid data.": "Invalid data.", - "You are unlucky. Try again.": "You are unlucky. Try again.", - "Error saving comment. Sorry.": "Error saving comment. Sorry.", - "Error saving paste. Sorry.": "Error saving paste. Sorry.", - "Invalid paste ID.": "Invalid paste ID.", + "Paste is limited to %s of encrypted data.": "L'enganxat està limitat a %s de dades encriptades.", + "Invalid data.": "Dades no vàlides.", + "You are unlucky. Try again.": "Mala sort. Torna-ho a provar.", + "Error saving comment. Sorry.": "S'ha produït un error en desar el comentari. Ho sento.", + "Error saving paste. Sorry.": "S'ha produït un error en desar l'enganxat. Ho sento.", + "Invalid paste ID.": "Identificador d'enganxament no vàlid.", "Paste is not of burn-after-reading type.": "Paste is not of burn-after-reading type.", "Wrong deletion token. Paste was not deleted.": "Wrong deletion token. Paste was not deleted.", "Paste was properly deleted.": "Paste was properly deleted.", From d355bb87e361787beb3258c9da5bc906ebc774db Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 30 May 2021 08:11:45 +0200 Subject: [PATCH 154/223] documenting changes --- CHANGELOG.md | 3 ++- CREDITS.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a8ed407..84f630e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ * ADDED: new HTTP headers improving security (#765) * ADDED: Download button for paste text (#774) * ADDED: Opt-out of federated learning of cohorts (FLoC) (#776) - * ADDED: Configuration option to exempt ips from the rate-limiter (#787) + * ADDED: Configuration option to exempt IPs from the rate-limiter (#787) + * ADDED: Google Cloud Storage backend support (#795) * CHANGED: Language selection cookie only transmitted over HTTPS (#472) * CHANGED: Upgrading libraries to: random_compat 2.0.20 * **1.3.5 (2021-04-05)** diff --git a/CREDITS.md b/CREDITS.md index 338c2df6..612749c0 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -13,7 +13,7 @@ Sébastien Sauvage - original idea and main developer * Alexey Gladkov - syntax highlighting * Greg Knaddison - robots.txt * MrKooky - HTML5 markup, CSS cleanup -* Simon Rupf - WebCrypto, unit tests, current docker containers, MVC, configuration, i18n +* Simon Rupf - WebCrypto, unit tests, containers images, database backend, MVC, configuration, i18n * Hexalyse - Password protection * Viktor Stanchev - File upload support * azlux - Tab character input support @@ -28,6 +28,7 @@ Sébastien Sauvage - original idea and main developer * Haocen - lots of bugfixes and UI improvements * Lucas Savva - configurable config file location, NixOS packaging * rodehoed - option to exempt ips from the rate-limiter +* Mark van Holsteijn - Google Cloud Storage backend ## Translations * Hexalyse - French From 33587d54e4b56738c543487a999d8b6d27dc61ed Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 30 May 2021 09:17:23 +0200 Subject: [PATCH 155/223] fix composer test on PHP 8 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0d1e3549..a8c94ae1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: - name: Validate composer.json and composer.lock run: composer validate - name: Install dependencies - run: composer install --prefer-dist --no-suggest + run: composer install --prefer-dist --no-dev - name: Install Google Cloud Storage run: composer require google/cloud-storage PHPunit: From fc5e380ccc249a619f60ad182a17c55a49140c42 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 30 May 2021 09:18:56 +0200 Subject: [PATCH 156/223] fix composer test on PHP 8 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a8c94ae1..aff27df1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-dev - name: Install Google Cloud Storage - run: composer require google/cloud-storage + run: composer require google/cloud-storage --no-dev PHPunit: runs-on: ubuntu-latest strategy: From 93138cbbae6d1ada37f3dcb5cba6a4b77a71d0f4 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 30 May 2021 09:26:13 +0200 Subject: [PATCH 157/223] we already test this via the regular unit tests --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aff27df1..73fa11aa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,8 +11,6 @@ jobs: run: composer validate - name: Install dependencies run: composer install --prefer-dist --no-dev - - name: Install Google Cloud Storage - run: composer require google/cloud-storage --no-dev PHPunit: runs-on: ubuntu-latest strategy: From 3df6b62d222d0073d80f3251038a522cad103888 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Thu, 3 Jun 2021 03:00:55 +0200 Subject: [PATCH 158/223] New translations en.json (Catalan) --- i18n/ca.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/i18n/ca.json b/i18n/ca.json index b2b86fe2..ef6b348d 100644 --- a/i18n/ca.json +++ b/i18n/ca.json @@ -22,18 +22,18 @@ "Paste is not of burn-after-reading type.": "Paste is not of burn-after-reading type.", "Wrong deletion token. Paste was not deleted.": "Wrong deletion token. Paste was not deleted.", "Paste was properly deleted.": "Paste was properly deleted.", - "JavaScript is required for %s to work. Sorry for the inconvenience.": "JavaScript is required for %s to work. Sorry for the inconvenience.", - "%s requires a modern browser to work.": "%s requires a modern browser to work.", - "New": "New", - "Send": "Send", - "Clone": "Clone", - "Raw text": "Raw text", - "Expires": "Expires", - "Burn after reading": "Burn after reading", - "Open discussion": "Open discussion", - "Password (recommended)": "Password (recommended)", - "Discussion": "Discussion", - "Toggle navigation": "Toggle navigation", + "JavaScript is required for %s to work. Sorry for the inconvenience.": "Cal JavaScript perquè %s funcioni. Em sap greu les molèsties.", + "%s requires a modern browser to work.": "%s requereix un navegador modern per funcionar.", + "New": "Nou", + "Send": "Enviar", + "Clone": "Clona", + "Raw text": "Text sense processar", + "Expires": "Caducitat", + "Burn after reading": "Esborra després de ser llegit", + "Open discussion": "Discussió oberta", + "Password (recommended)": "Contrasenya (recomanat)", + "Discussion": "Discussió", + "Toggle navigation": "Alternar navegació", "%d seconds": [ "%d second (singular)", "%d seconds (1st plural)", From 8bc97517fb16499b0cd20a14cd01ad286349ded8 Mon Sep 17 00:00:00 2001 From: rugk Date: Fri, 4 Jun 2021 23:43:01 +0200 Subject: [PATCH 159/223] Add Snyk security scan for PHP After I found https://github.com/PrivateBin/docker-nginx-fpm-alpine/pull/44 I saw they also support PHP, so let's do it here (one level before container packaging), too. Also it complements the CodeQL analysis, which only covers the JS part. I added the API token to the PrivateBIn org now. --- .github/workflows/snyk-scan.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/snyk-scan.yml diff --git a/.github/workflows/snyk-scan.yml b/.github/workflows/snyk-scan.yml new file mode 100644 index 00000000..af0afbd7 --- /dev/null +++ b/.github/workflows/snyk-scan.yml @@ -0,0 +1,27 @@ +# This is a basic workflow to help you get started with Actions + +name: Snyk scan + +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ master ] + pull_request: + branches: [ master ] +jobs: + # https://github.com/snyk/actions/tree/master/php + snyk-php: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Run Snyk to check for vulnerabilities + uses: snyk/actions/php@master + continue-on-error: true # To make sure that SARIF upload gets called + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + with: + args: --sarif-file-output=snyk.sarif + - name: Upload result to GitHub Code Scanning + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: snyk.sarif From ffe48092fecde86474a194b05c5611edfd5fa593 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 5 Jun 2021 05:38:05 +0200 Subject: [PATCH 160/223] suppress error_log output of GoogleCloudStorage class in unit testing --- tst/Data/GoogleCloudStorageTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tst/Data/GoogleCloudStorageTest.php b/tst/Data/GoogleCloudStorageTest.php index 91a5ca99..6905f04b 100644 --- a/tst/Data/GoogleCloudStorageTest.php +++ b/tst/Data/GoogleCloudStorageTest.php @@ -34,6 +34,7 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase // do not report E_NOTICE as fsouza/fake-gcs-server does not return a `generation` value in the response // which the Google Cloud Storage PHP library expects. error_reporting(E_ERROR | E_WARNING | E_PARSE); + ini_set('error_log', stream_get_meta_data(tmpfile())['uri']); $this->_model = GoogleCloudStorage::getInstance(array( 'bucket' => self::$_bucket->name(), 'prefix' => 'pastes', From edb8e5e078f2557716a17c8e92f91eb657d3b728 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 5 Jun 2021 05:48:17 +0200 Subject: [PATCH 161/223] handle edge cases with file locking: file needs to exist before it can be locked, fixes #803 --- lib/Persistence/AbstractPersistence.php | 28 +++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/Persistence/AbstractPersistence.php b/lib/Persistence/AbstractPersistence.php index 0dcef50e..c96a0de3 100644 --- a/lib/Persistence/AbstractPersistence.php +++ b/lib/Persistence/AbstractPersistence.php @@ -90,12 +90,15 @@ abstract class AbstractPersistence } $file = self::$_path . DIRECTORY_SEPARATOR . '.htaccess'; if (!is_file($file)) { - $writtenBytes = @file_put_contents( - $file, - 'Require all denied' . PHP_EOL, - LOCK_EX - ); - if ($writtenBytes === false || $writtenBytes < 19) { + $writtenBytes = 0; + if ($fileCreated = @touch($file)) { + $writtenBytes = @file_put_contents( + $file, + 'Require all denied' . PHP_EOL, + LOCK_EX + ); + } + if ($fileCreated === false || $writtenBytes === false || $writtenBytes < 19) { throw new Exception('unable to write to file ' . $file, 11); } } @@ -114,9 +117,16 @@ abstract class AbstractPersistence protected static function _store($filename, $data) { self::_initialize(); - $file = self::$_path . DIRECTORY_SEPARATOR . $filename; - $writtenBytes = @file_put_contents($file, $data, LOCK_EX); - if ($writtenBytes === false || $writtenBytes < strlen($data)) { + $file = self::$_path . DIRECTORY_SEPARATOR . $filename; + $fileCreated = true; + $writtenBytes = 0; + if (!is_file($file)) { + $fileCreated = @touch($file); + } + if ($fileCreated) { + $writtenBytes = @file_put_contents($file, $data, LOCK_EX); + } + if ($fileCreated === false || $writtenBytes === false || $writtenBytes < strlen($data)) { throw new Exception('unable to write to file ' . $file, 13); } @chmod($file, 0640); // protect file access From abb2b90e9b13e09ee8853a6ff20f5617a4aadd94 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 5 Jun 2021 05:52:13 +0200 Subject: [PATCH 162/223] make StyleCI happy --- lib/Persistence/AbstractPersistence.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Persistence/AbstractPersistence.php b/lib/Persistence/AbstractPersistence.php index c96a0de3..489836da 100644 --- a/lib/Persistence/AbstractPersistence.php +++ b/lib/Persistence/AbstractPersistence.php @@ -117,8 +117,8 @@ abstract class AbstractPersistence protected static function _store($filename, $data) { self::_initialize(); - $file = self::$_path . DIRECTORY_SEPARATOR . $filename; - $fileCreated = true; + $file = self::$_path . DIRECTORY_SEPARATOR . $filename; + $fileCreated = true; $writtenBytes = 0; if (!is_file($file)) { $fileCreated = @touch($file); From 371dca19868464f3adf6a52a54423bd4f3652125 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 5 Jun 2021 08:10:12 +0200 Subject: [PATCH 163/223] ensure the GCS library and dependencies get included in the scan --- .github/workflows/snyk-scan.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/snyk-scan.yml b/.github/workflows/snyk-scan.yml index af0afbd7..15e2beec 100644 --- a/.github/workflows/snyk-scan.yml +++ b/.github/workflows/snyk-scan.yml @@ -14,6 +14,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master + - name: Install Google Cloud Storage + run: composer require google/cloud-storage - name: Run Snyk to check for vulnerabilities uses: snyk/actions/php@master continue-on-error: true # To make sure that SARIF upload gets called From cbdcaf4c307b9894fae4a995d98924b3103a0623 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 5 Jun 2021 08:14:04 +0200 Subject: [PATCH 164/223] fix snyk --- .github/workflows/snyk-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snyk-scan.yml b/.github/workflows/snyk-scan.yml index 15e2beec..3d3e3e7f 100644 --- a/.github/workflows/snyk-scan.yml +++ b/.github/workflows/snyk-scan.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@master - name: Install Google Cloud Storage - run: composer require google/cloud-storage + run: composer require --no-dev google/cloud-storage - name: Run Snyk to check for vulnerabilities uses: snyk/actions/php@master continue-on-error: true # To make sure that SARIF upload gets called From 7a3a306ddcbf0cef045444b7ecd7aaab671a5f0d Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 5 Jun 2021 08:22:50 +0200 Subject: [PATCH 165/223] fix snyk --- .github/workflows/snyk-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snyk-scan.yml b/.github/workflows/snyk-scan.yml index 3d3e3e7f..91ae0924 100644 --- a/.github/workflows/snyk-scan.yml +++ b/.github/workflows/snyk-scan.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@master - name: Install Google Cloud Storage - run: composer require --no-dev google/cloud-storage + run: composer install --no-dev google/cloud-storage - name: Run Snyk to check for vulnerabilities uses: snyk/actions/php@master continue-on-error: true # To make sure that SARIF upload gets called From 197c4a34e8a0e303cc46743834b65634cef27a3a Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 5 Jun 2021 08:25:19 +0200 Subject: [PATCH 166/223] fix snyk --- .github/workflows/snyk-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snyk-scan.yml b/.github/workflows/snyk-scan.yml index 91ae0924..4730eec0 100644 --- a/.github/workflows/snyk-scan.yml +++ b/.github/workflows/snyk-scan.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@master - name: Install Google Cloud Storage - run: composer install --no-dev google/cloud-storage + run: composer require --no-update google/cloud-storage && composer update --no-dev - name: Run Snyk to check for vulnerabilities uses: snyk/actions/php@master continue-on-error: true # To make sure that SARIF upload gets called From a2ffbafa136fb8db83e956c2a63f4974f9f6103f Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 5 Jun 2021 09:43:01 +0200 Subject: [PATCH 167/223] ensure npm's package.json version gets incremented --- Makefile | 2 +- js/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 691d72bf..83a6b6de 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CURRENT_VERSION = 1.3.5 VERSION ?= 1.3.6 -VERSION_FILES = index.php cfg/ *.md css/ i18n/ img/ js/privatebin.js lib/ Makefile tpl/ tst/ +VERSION_FILES = index.php cfg/ *.md css/ i18n/ img/ js/package.json js/privatebin.js lib/ Makefile tpl/ tst/ REGEX_CURRENT_VERSION := $(shell echo $(CURRENT_VERSION) | sed "s/\./\\\./g") REGEX_VERSION := $(shell echo $(VERSION) | sed "s/\./\\\./g") diff --git a/js/package.json b/js/package.json index 489cc677..53e85dc3 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "privatebin", - "version": "1.3.0", + "version": "1.3.5", "description": "PrivateBin is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bit AES in Galois Counter mode (GCM).", "main": "privatebin.js", "directories": { From 2bc54caa071f35bf2e2f68dbe5df579fc2f8f59a Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 5 Jun 2021 10:33:01 +0200 Subject: [PATCH 168/223] fix never matched condition, kudos @ShiftLeftSecurity, found via #807 --- lib/Request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Request.php b/lib/Request.php index cfa883ad..5776cabe 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -288,7 +288,7 @@ class Request } krsort($mediaTypes); foreach ($mediaTypes as $acceptedQuality => $acceptedValues) { - if ($acceptedQuality === 0.0) { + if ($acceptedQuality === '0.0') { continue; } foreach ($acceptedValues as $acceptedValue) { From 9beb17687400c08e4fb297b3cce7c1efac4acf10 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 6 Jun 2021 17:52:10 +0200 Subject: [PATCH 169/223] these don't belong in a release --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index 28b68d13..60629c04 100644 --- a/.gitattributes +++ b/.gitattributes @@ -19,6 +19,8 @@ js/test/ export-ignore .scrutinizer.yml export-ignore .styleci.yml export-ignore .travis.yml export-ignore +codacy-analysis.yml export-ignore +crowdin.yml export-ignore composer.json export-ignore composer.lock export-ignore BADGES.md export-ignore From c758eca0a4c450aa62e54614d6510d02bf638517 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 6 Jun 2021 17:53:08 +0200 Subject: [PATCH 170/223] removed automatic .ini configuration file migration, closes #808 --- CHANGELOG.md | 1 + lib/Configuration.php | 12 ------- lib/Persistence/DataStore.php | 5 ++- tst/ConfigurationTest.php | 63 ----------------------------------- 4 files changed, 3 insertions(+), 78 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84f630e6..2c4321ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * ADDED: Google Cloud Storage backend support (#795) * CHANGED: Language selection cookie only transmitted over HTTPS (#472) * CHANGED: Upgrading libraries to: random_compat 2.0.20 + * CHANGED: Removed automatic `.ini` configuration file migration (#808) * **1.3.5 (2021-04-05)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan * ADDED: Make the project info configurable (#681) diff --git a/lib/Configuration.php b/lib/Configuration.php index 1e92fc9b..a56217b5 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -106,20 +106,8 @@ class Configuration { $config = array(); $basePath = (getenv('CONFIG_PATH') !== false ? getenv('CONFIG_PATH') : PATH . 'cfg') . DIRECTORY_SEPARATOR; - $configIni = $basePath . 'conf.ini'; $configFile = $basePath . 'conf.php'; - // rename INI files to avoid configuration leakage - if (is_readable($configIni)) { - DataStore::prependRename($configIni, $configFile, ';'); - - // cleanup sample, too - $configIniSample = $configIni . '.sample'; - if (is_readable($configIniSample)) { - DataStore::prependRename($configIniSample, $basePath . 'conf.sample.php', ';'); - } - } - if (is_readable($configFile)) { $config = parse_ini_file($configFile, true); foreach (array('main', 'model', 'model_options') as $section) { diff --git a/lib/Persistence/DataStore.php b/lib/Persistence/DataStore.php index d96f0707..d17e5faf 100644 --- a/lib/Persistence/DataStore.php +++ b/lib/Persistence/DataStore.php @@ -80,15 +80,14 @@ class DataStore extends AbstractPersistence * @static * @param string $srcFile * @param string $destFile - * @param string $prefix (optional) * @return void */ - public static function prependRename($srcFile, $destFile, $prefix = '') + public static function prependRename($srcFile, $destFile) { // don't overwrite already converted file if (!is_readable($destFile)) { $handle = fopen($srcFile, 'r', false, stream_context_create()); - file_put_contents($destFile, $prefix . self::PROTECTION_LINE . PHP_EOL); + file_put_contents($destFile, self::PROTECTION_LINE . PHP_EOL); file_put_contents($destFile, $handle, FILE_APPEND); fclose($handle); } diff --git a/tst/ConfigurationTest.php b/tst/ConfigurationTest.php index bb4ce36f..246618cc 100644 --- a/tst/ConfigurationTest.php +++ b/tst/ConfigurationTest.php @@ -147,44 +147,6 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase $this->assertEquals('Database', $conf->getKey('class', 'model'), 'old db class gets renamed'); } - public function testHandleConfigFileRename() - { - $options = $this->_options; - Helper::createIniFile(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini.sample', $options); - - $options['main']['opendiscussion'] = true; - $options['main']['fileupload'] = true; - $options['main']['template'] = 'darkstrap'; - Helper::createIniFile(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', $options); - - $conf = new Configuration; - $this->assertFileExists(CONF, 'old configuration file gets converted'); - $this->assertFileNotExists(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', 'old configuration file gets removed'); - $this->assertFileNotExists(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini.sample', 'old configuration sample file gets removed'); - $this->assertTrue( - $conf->getKey('opendiscussion') && - $conf->getKey('fileupload') && - $conf->getKey('template') === 'darkstrap', - 'configuration values get converted' - ); - } - - public function testRenameIniSample() - { - $iniSample = PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini.sample'; - - Helper::createIniFile(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', $this->_options); - if (is_file(CONF)) { - unlink(CONF); - } - rename(CONF_SAMPLE, $iniSample); - new Configuration; - $this->assertFileNotExists($iniSample, 'old sample file gets removed'); - $this->assertFileExists(CONF_SAMPLE, 'new sample file gets created'); - $this->assertFileExists(CONF, 'old configuration file gets converted'); - $this->assertFileNotExists(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', 'old configuration file gets removed'); - } - public function testConfigPath() { // setup @@ -204,29 +166,4 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase } putenv('CONFIG_PATH'); } - - public function testConfigPathIni() - { - // setup - $configFile = $this->_path . DIRECTORY_SEPARATOR . 'conf.ini'; - $configMigrated = $this->_path . DIRECTORY_SEPARATOR . 'conf.php'; - $options = $this->_options; - $options['main']['name'] = 'OtherBin'; - Helper::createIniFile($configFile, $options); - $this->assertFileNotExists(CONF, 'configuration in the default location is non existing'); - - // test - putenv('CONFIG_PATH=' . $this->_path); - $conf = new Configuration; - $this->assertEquals('OtherBin', $conf->getKey('name'), 'changing config path is supported for ini files as well'); - $this->assertFileExists($configMigrated, 'old configuration file gets converted'); - $this->assertFileNotExists($configFile, 'old configuration file gets removed'); - $this->assertFileNotExists(CONF, 'configuration is not created in the default location'); - - // cleanup environment - if (is_file($configFile)) { - unlink($configFile); - } - putenv('CONFIG_PATH'); - } } From de8f40ac1a8b43fe6aa6a7a2fb1ab370ee62b438 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 6 Jun 2021 19:35:31 +0200 Subject: [PATCH 171/223] kudos @StyleCI --- lib/Configuration.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Configuration.php b/lib/Configuration.php index a56217b5..1185440c 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -14,7 +14,6 @@ namespace PrivateBin; use Exception; use PDO; -use PrivateBin\Persistence\DataStore; /** * Configuration From 1a7d0799c00de0e2944e0e15e29c64e64d89e4a3 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Mon, 7 Jun 2021 06:53:15 +0200 Subject: [PATCH 172/223] scaffolding interface for AbstractData key/value storage, folding Persistance\DataStore into Data\Filesystem --- lib/Data/AbstractData.php | 35 ++++++- lib/Data/Filesystem.php | 170 ++++++++++++++++++++++++++++++---- lib/Persistence/DataStore.php | 96 ------------------- 3 files changed, 185 insertions(+), 116 deletions(-) delete mode 100644 lib/Persistence/DataStore.php diff --git a/lib/Data/AbstractData.php b/lib/Data/AbstractData.php index 077864ec..8a52d1d7 100644 --- a/lib/Data/AbstractData.php +++ b/lib/Data/AbstractData.php @@ -20,7 +20,7 @@ namespace PrivateBin\Data; abstract class AbstractData { /** - * singleton instance + * Singleton instance * * @access protected * @static @@ -28,8 +28,14 @@ abstract class AbstractData */ protected static $_instance = null; + protected static $_namespaces = array( + 'purge_limiter', + 'salt', + 'traffic_limiter', + ); + /** - * enforce singleton, disable constructor + * Enforce singleton, disable constructor * * Instantiate using {@link getInstance()}, privatebin is a singleton object. * @@ -40,7 +46,7 @@ abstract class AbstractData } /** - * enforce singleton, disable cloning + * Enforce singleton, disable cloning * * Instantiate using {@link getInstance()}, privatebin is a singleton object. * @@ -51,7 +57,7 @@ abstract class AbstractData } /** - * get instance of singleton + * Get instance of singleton * * @access public * @static @@ -130,6 +136,27 @@ abstract class AbstractData */ abstract public function existsComment($pasteid, $parentid, $commentid); + /** + * Save a value. + * + * @access public + * @param string $value + * @param string $namespace + * @param string $key + * @return bool + */ + abstract public function setValue($value, $namespace, $key = ''); + + /** + * Load a value. + * + * @access public + * @param string $namespace + * @param string $key + * @return string + */ + abstract public function getValue($namespace, $key = ''); + /** * Returns up to batch size number of paste ids that have expired * diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 96ee6915..fee61c10 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -12,7 +12,8 @@ namespace PrivateBin\Data; -use PrivateBin\Persistence\DataStore; +use Exception; +use PrivateBin\Json; /** * Filesystem @@ -21,6 +22,22 @@ use PrivateBin\Persistence\DataStore; */ class Filesystem extends AbstractData { + /** + * first line in file, to protect its contents + * + * @const string + */ + const PROTECTION_LINE = 'read())) { if (substr($filename, -4) !== '.php' && strlen($filename) >= 16) { $commentFilename = $discdir . $filename . '.php'; - DataStore::prependRename($discdir . $filename, $commentFilename); + self::_prependRename($discdir . $filename, $commentFilename); } } $dir->close(); @@ -165,7 +182,7 @@ class Filesystem extends AbstractData if (!is_dir($storagedir)) { mkdir($storagedir, 0700, true); } - return DataStore::store($file, $comment); + return self::_store($file, $comment); } /** @@ -187,7 +204,7 @@ class Filesystem extends AbstractData // - commentid is the comment identifier itself. // - parentid is the comment this comment replies to (It can be pasteid) if (is_file($discdir . $filename)) { - $comment = DataStore::get($discdir . $filename); + $comment = self::_get($discdir . $filename); $items = explode('.', $filename); // Add some meta information not contained in file. $comment['id'] = $items[1]; @@ -223,6 +240,33 @@ class Filesystem extends AbstractData ); } + /** + * Save a value. + * + * @access public + * @param string $value + * @param string $namespace + * @param string $key + * @return bool + */ + public function setValue($value, $namespace, $key = '') + { + + } + + /** + * Load a value. + * + * @access public + * @param string $namespace + * @param string $key + * @return string + */ + public function getValue($namespace, $key = '') + { + + } + /** * Returns up to batch size number of paste ids that have expired * @@ -233,9 +277,8 @@ class Filesystem extends AbstractData protected function _getExpiredPastes($batchsize) { $pastes = array(); - $mainpath = DataStore::getPath(); $firstLevel = array_filter( - scandir($mainpath), + scandir(self::$_path), 'self::_isFirstLevelDir' ); if (count($firstLevel) > 0) { @@ -243,7 +286,7 @@ class Filesystem extends AbstractData for ($i = 0, $max = $batchsize * 10; $i < $max; ++$i) { $firstKey = array_rand($firstLevel); $secondLevel = array_filter( - scandir($mainpath . DIRECTORY_SEPARATOR . $firstLevel[$firstKey]), + scandir(self::$_path . DIRECTORY_SEPARATOR . $firstLevel[$firstKey]), 'self::_isSecondLevelDir' ); @@ -254,7 +297,7 @@ class Filesystem extends AbstractData } $secondKey = array_rand($secondLevel); - $path = $mainpath . DIRECTORY_SEPARATOR . + $path = self::$_path . DIRECTORY_SEPARATOR . $firstLevel[$firstKey] . DIRECTORY_SEPARATOR . $secondLevel[$secondKey]; if (!is_dir($path)) { @@ -314,10 +357,9 @@ class Filesystem extends AbstractData */ private static function _dataid2path($dataid) { - return DataStore::getPath( + return self::$_path . DIRECTORY_SEPARATOR . substr($dataid, 0, 2) . DIRECTORY_SEPARATOR . - substr($dataid, 2, 2) . DIRECTORY_SEPARATOR - ); + substr($dataid, 2, 2) . DIRECTORY_SEPARATOR; } /** @@ -347,7 +389,7 @@ class Filesystem extends AbstractData private static function _isFirstLevelDir($element) { return self::_isSecondLevelDir($element) && - is_dir(DataStore::getPath($element)); + is_dir(self::$_path . DIRECTORY_SEPARATOR . $element); } /** @@ -362,4 +404,100 @@ class Filesystem extends AbstractData { return (bool) preg_match('/^[a-f0-9]{2}$/', $element); } + + /** + * store the data + * + * @access public + * @static + * @param string $filename + * @param array $data + * @return bool + */ + private static function _store($filename, $data) + { + if (strpos($filename, self::$_path) === 0) { + $filename = substr($filename, strlen(self::$_path)); + } + + // Create storage directory if it does not exist. + if (!is_dir(self::$_path)) { + if (!@mkdir(self::$_path, 0700)) { + throw new Exception('unable to create directory ' . self::$_path, 10); + } + } + $file = self::$_path . DIRECTORY_SEPARATOR . '.htaccess'; + if (!is_file($file)) { + $writtenBytes = 0; + if ($fileCreated = @touch($file)) { + $writtenBytes = @file_put_contents( + $file, + 'Require all denied' . PHP_EOL, + LOCK_EX + ); + } + if ($fileCreated === false || $writtenBytes === false || $writtenBytes < 19) { + return false; + } + } + + try { + $data = self::PROTECTION_LINE . PHP_EOL . Json::encode($data); + } catch (Exception $e) { + return false; + } + $file = self::$_path . DIRECTORY_SEPARATOR . $filename; + $fileCreated = true; + $writtenBytes = 0; + if (!is_file($file)) { + $fileCreated = @touch($file); + } + if ($fileCreated) { + $writtenBytes = @file_put_contents($file, $data, LOCK_EX); + } + if ($fileCreated === false || $writtenBytes === false || $writtenBytes < strlen($data)) { + return false; + } + @chmod($file, 0640); // protect file access + return true; + } + + /** + * get the data + * + * @access public + * @static + * @param string $filename + * @return array|false $data + */ + private static function _get($filename) + { + return Json::decode( + substr( + file_get_contents($filename), + strlen(self::PROTECTION_LINE . PHP_EOL) + ) + ); + } + + /** + * rename a file, prepending the protection line at the beginning + * + * @access public + * @static + * @param string $srcFile + * @param string $destFile + * @return void + */ + private static function _prependRename($srcFile, $destFile) + { + // don't overwrite already converted file + if (!is_readable($destFile)) { + $handle = fopen($srcFile, 'r', false, stream_context_create()); + file_put_contents($destFile, self::PROTECTION_LINE . PHP_EOL); + file_put_contents($destFile, $handle, FILE_APPEND); + fclose($handle); + } + unlink($srcFile); + } } diff --git a/lib/Persistence/DataStore.php b/lib/Persistence/DataStore.php deleted file mode 100644 index d17e5faf..00000000 --- a/lib/Persistence/DataStore.php +++ /dev/null @@ -1,96 +0,0 @@ - Date: Mon, 7 Jun 2021 07:02:47 +0200 Subject: [PATCH 173/223] conclude scaffolding of AbstractData key/value storage, missing implementation --- lib/Data/AbstractData.php | 6 ----- lib/Data/Database.php | 40 +++++++++++++++++++++++++++++++++ lib/Data/Filesystem.php | 15 ++++++++++++- lib/Data/GoogleCloudStorage.php | 40 +++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 7 deletions(-) diff --git a/lib/Data/AbstractData.php b/lib/Data/AbstractData.php index 8a52d1d7..0508bc02 100644 --- a/lib/Data/AbstractData.php +++ b/lib/Data/AbstractData.php @@ -28,12 +28,6 @@ abstract class AbstractData */ protected static $_instance = null; - protected static $_namespaces = array( - 'purge_limiter', - 'salt', - 'traffic_limiter', - ); - /** * Enforce singleton, disable constructor * diff --git a/lib/Data/Database.php b/lib/Data/Database.php index 607013ba..5a0f369e 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -423,6 +423,46 @@ class Database extends AbstractData ); } + /** + * Save a value. + * + * @access public + * @param string $value + * @param string $namespace + * @param string $key + * @return bool + */ + public function setValue($value, $namespace, $key = '') + { + switch ($namespace) { + case 'purge_limiter': + ; + break; + case 'salt': + ; + break; + case 'traffic_limiter': + ; + break; + default: + return false; + break; + } + } + + /** + * Load a value. + * + * @access public + * @param string $namespace + * @param string $key + * @return string + */ + public function getValue($namespace, $key = '') + { + + } + /** * Returns up to batch size number of paste ids that have expired * diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index fee61c10..76c2600b 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -251,7 +251,20 @@ class Filesystem extends AbstractData */ public function setValue($value, $namespace, $key = '') { - + switch ($namespace) { + case 'purge_limiter': + ; + break; + case 'salt': + ; + break; + case 'traffic_limiter': + ; + break; + default: + return false; + break; + } } /** diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index 1a1d8bf5..81fcce64 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -217,6 +217,46 @@ class GoogleCloudStorage extends AbstractData return $o->exists(); } + /** + * Save a value. + * + * @access public + * @param string $value + * @param string $namespace + * @param string $key + * @return bool + */ + public function setValue($value, $namespace, $key = '') + { + switch ($namespace) { + case 'purge_limiter': + ; + break; + case 'salt': + ; + break; + case 'traffic_limiter': + ; + break; + default: + return false; + break; + } + } + + /** + * Load a value. + * + * @access public + * @param string $namespace + * @param string $key + * @return string + */ + public function getValue($namespace, $key = '') + { + + } + /** * @inheritDoc */ From 55efc858b5d523c65581b999a2ab0def7e540c9b Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Mon, 7 Jun 2021 09:11:24 +0200 Subject: [PATCH 174/223] simplest implementation of kv support on gcs --- lib/Data/GoogleCloudStorage.php | 59 ++++++++++++++++------------- tst/Data/GoogleCloudStorageTest.php | 25 ++++++++++-- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index 81fcce64..ca1b3408 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -218,43 +218,48 @@ class GoogleCloudStorage extends AbstractData } /** - * Save a value. - * - * @access public - * @param string $value - * @param string $namespace - * @param string $key - * @return bool + * This is the simplest thing that could possibly work. + * will be to tested for runtime performance. + * @inheritDoc */ public function setValue($value, $namespace, $key = '') { - switch ($namespace) { - case 'purge_limiter': - ; - break; - case 'salt': - ; - break; - case 'traffic_limiter': - ; - break; - default: - return false; - break; + $key = 'config/' . $namespace . '/' . $key; + $data = Json::encode($value); + + try { + $this->_bucket->upload($data, array( + 'name' => $key, + 'chunkSize' => 262144, + 'predefinedAcl' => 'private', + 'metadata' => array( + 'content-type' => 'application/json', + 'metadata' => array('namespace' => $namespace), + ), + )); + } catch (Exception $e) { + error_log('failed to set key ' . $key . ' to ' . $this->_bucket->name() . ', ' . + trim(preg_replace('/\s\s+/', ' ', $e->getMessage()))); + return false; } + return true; } /** - * Load a value. - * - * @access public - * @param string $namespace - * @param string $key - * @return string + * This is the simplest thing that could possibly work. + * will be to tested for runtime performance. + * @inheritDoc */ public function getValue($namespace, $key = '') { - + $key = 'config/' . $namespace . '/' . $key; + try { + $o = $this->_bucket->object($key); + $data = $o->downloadAsString(); + return Json::decode($data); + } catch (NotFoundException $e) { + return false; + } } /** diff --git a/tst/Data/GoogleCloudStorageTest.php b/tst/Data/GoogleCloudStorageTest.php index 6905f04b..30a7d5eb 100644 --- a/tst/Data/GoogleCloudStorageTest.php +++ b/tst/Data/GoogleCloudStorageTest.php @@ -31,9 +31,6 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase public function setUp() { - // do not report E_NOTICE as fsouza/fake-gcs-server does not return a `generation` value in the response - // which the Google Cloud Storage PHP library expects. - error_reporting(E_ERROR | E_WARNING | E_PARSE); ini_set('error_log', stream_get_meta_data(tmpfile())['uri']); $this->_model = GoogleCloudStorage::getInstance(array( 'bucket' => self::$_bucket->name(), @@ -138,6 +135,28 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase $this->assertFalse($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), $comment), 'unable to store broken comment'); $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment does still not exist'); } + + /** + * @throws Exception + */ + public function testKeyValueStore() + { + $salt = bin2hex(random_bytes(256)); + $this->_model->setValue($salt, 'salt', 'master'); + $storedSalt = $this->_model->getValue('salt', 'master'); + $this->assertEquals($salt, $storedSalt); + + $client = hash_hmac('sha512', '127.0.0.1', $salt); + $expire = time(); + $this->_model->setValue($expire, 'traffic_limiter', $client); + $storedExpired = $this->_model->getValue('traffic_limiter', $client); + $this->assertEquals($expire, $storedExpired); + + $purgeAt = $expire + (15 * 60); + $this->_model->setValue($purgeAt, 'purge_limiter', 'at'); + $storedPurgedAt = $this->_model->getValue('purge_limiter', 'at'); + $this->assertEquals($purgeAt, $storedPurgedAt); + } } /** From ae486d651be3a622dd1307bc0c681ecf5a894058 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Mon, 7 Jun 2021 21:53:42 +0200 Subject: [PATCH 175/223] folding Persistance\PurgeLimiter into Data\Filesystem --- lib/Data/Filesystem.php | 99 ++++++++++++++++--------- lib/Model.php | 1 + lib/Persistence/AbstractPersistence.php | 22 ++++++ lib/Persistence/PurgeLimiter.php | 14 +--- tst/Persistence/PurgeLimiterTest.php | 4 + 5 files changed, 94 insertions(+), 46 deletions(-) diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 76c2600b..f24691b9 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -253,7 +253,10 @@ class Filesystem extends AbstractData { switch ($namespace) { case 'purge_limiter': - ; + return self::_storeString( + self::$_path . DIRECTORY_SEPARATOR . 'purge_limiter.php', + '_conf); + PurgeLimiter::setStore($this->_getStore()); if (PurgeLimiter::canPurge()) { $this->_getStore()->purge($this->_conf->getKey('batchsize', 'purge')); } diff --git a/lib/Persistence/AbstractPersistence.php b/lib/Persistence/AbstractPersistence.php index 489836da..73f0ab2e 100644 --- a/lib/Persistence/AbstractPersistence.php +++ b/lib/Persistence/AbstractPersistence.php @@ -13,6 +13,7 @@ namespace PrivateBin\Persistence; use Exception; +use PrivateBin\Data\AbstractData; /** * AbstractPersistence @@ -30,6 +31,15 @@ abstract class AbstractPersistence */ private static $_path = 'data'; + /** + * data storage to use to persist something + * + * @access private + * @static + * @var AbstractData + */ + protected static $_store; + /** * set the path * @@ -42,6 +52,18 @@ abstract class AbstractPersistence self::$_path = $path; } + /** + * set the path + * + * @access public + * @static + * @param AbstractData $store + */ + public static function setStore(AbstractData $store) + { + self::$_store = $store; + } + /** * get the path * diff --git a/lib/Persistence/PurgeLimiter.php b/lib/Persistence/PurgeLimiter.php index ea07e322..19b83e2d 100644 --- a/lib/Persistence/PurgeLimiter.php +++ b/lib/Persistence/PurgeLimiter.php @@ -71,17 +71,11 @@ class PurgeLimiter extends AbstractPersistence } $now = time(); - $file = 'purge_limiter.php'; - if (self::_exists($file)) { - require self::getPath($file); - $pl = $GLOBALS['purge_limiter']; - if ($pl + self::$_limit >= $now) { - return false; - } + $pl = (int) self::$_store->getValue('purge_limiter'); + if ($pl + self::$_limit >= $now) { + return false; } - - $content = 'setValue((string) $now, 'purge_limiter'); return true; } } diff --git a/tst/Persistence/PurgeLimiterTest.php b/tst/Persistence/PurgeLimiterTest.php index 391a840b..e8cedc0a 100644 --- a/tst/Persistence/PurgeLimiterTest.php +++ b/tst/Persistence/PurgeLimiterTest.php @@ -1,5 +1,6 @@ _path); } PurgeLimiter::setPath($this->_path); + PurgeLimiter::setStore( + Filesystem::getInstance(array('dir' => $this->_path)) + ); } public function tearDown() From 3429d293d3ba0426924b5da488147e4f3b223c9f Mon Sep 17 00:00:00 2001 From: El RIDO Date: Tue, 8 Jun 2021 06:37:27 +0200 Subject: [PATCH 176/223] remove configurable dir for traffic & purge limiters --- CHANGELOG.md | 1 + cfg/conf.sample.php | 6 ------ lib/Configuration.php | 2 -- lib/Controller.php | 1 - lib/Persistence/PurgeLimiter.php | 3 +-- lib/Persistence/TrafficLimiter.php | 1 - tst/ConfigurationTest.php | 2 -- tst/ConfigurationTestGenerator.php | 4 ---- tst/ControllerTest.php | 3 --- tst/JsonApiTest.php | 2 -- tst/Persistence/PurgeLimiterTest.php | 1 - 11 files changed, 2 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c4321ad..c546bd11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * CHANGED: Language selection cookie only transmitted over HTTPS (#472) * CHANGED: Upgrading libraries to: random_compat 2.0.20 * CHANGED: Removed automatic `.ini` configuration file migration (#808) + * CHANGED: Removed configurable `dir` for `traffic` & `purge` limiters (#419) * **1.3.5 (2021-04-05)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan * ADDED: Make the project info configurable (#681) diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php index a4b7f6b5..d362f3f2 100644 --- a/cfg/conf.sample.php +++ b/cfg/conf.sample.php @@ -143,9 +143,6 @@ limit = 10 ; set the HTTP header containing the visitors IP address, i.e. X_FORWARDED_FOR ; header = "X_FORWARDED_FOR" -; directory to store the traffic limits in -dir = PATH "data" - [purge] ; minimum time limit between two purgings of expired pastes, it is only ; triggered when pastes are created @@ -157,9 +154,6 @@ limit = 300 ; site batchsize = 10 -; directory to store the purge limit in -dir = PATH "data" - [model] ; name of data model class to load and directory for storage ; the default model "Filesystem" stores everything in the filesystem diff --git a/lib/Configuration.php b/lib/Configuration.php index 1185440c..7c4eb106 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -80,13 +80,11 @@ class Configuration 'traffic' => array( 'limit' => 10, 'header' => null, - 'dir' => 'data', 'exemptedIp' => null, ), 'purge' => array( 'limit' => 300, 'batchsize' => 10, - 'dir' => 'data', ), 'model' => array( 'class' => 'Filesystem', diff --git a/lib/Controller.php b/lib/Controller.php index 2df522a2..72bd5b2e 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -162,7 +162,6 @@ class Controller $this->_model = new Model($this->_conf); $this->_request = new Request; $this->_urlBase = $this->_request->getRequestUri(); - ServerSalt::setPath($this->_conf->getKey('dir', 'traffic')); // set default language $lang = $this->_conf->getKey('languagedefault'); diff --git a/lib/Persistence/PurgeLimiter.php b/lib/Persistence/PurgeLimiter.php index 19b83e2d..6b608170 100644 --- a/lib/Persistence/PurgeLimiter.php +++ b/lib/Persistence/PurgeLimiter.php @@ -52,7 +52,6 @@ class PurgeLimiter extends AbstractPersistence public static function setConfiguration(Configuration $conf) { self::setLimit($conf->getKey('limit', 'purge')); - self::setPath($conf->getKey('dir', 'purge')); } /** @@ -71,7 +70,7 @@ class PurgeLimiter extends AbstractPersistence } $now = time(); - $pl = (int) self::$_store->getValue('purge_limiter'); + $pl = (int) self::$_store->getValue('purge_limiter'); if ($pl + self::$_limit >= $now) { return false; } diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index be76b8cd..299c7a6d 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -85,7 +85,6 @@ class TrafficLimiter extends AbstractPersistence public static function setConfiguration(Configuration $conf) { self::setLimit($conf->getKey('limit', 'traffic')); - self::setPath($conf->getKey('dir', 'traffic')); self::setExemptedIp($conf->getKey('exemptedIp', 'traffic')); if (($option = $conf->getKey('header', 'traffic')) !== null) { diff --git a/tst/ConfigurationTest.php b/tst/ConfigurationTest.php index 246618cc..312b7997 100644 --- a/tst/ConfigurationTest.php +++ b/tst/ConfigurationTest.php @@ -17,8 +17,6 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase $this->_minimalConfig = '[main]' . PHP_EOL . '[model]' . PHP_EOL . '[model_options]'; $this->_options = Configuration::getDefaults(); $this->_options['model_options']['dir'] = PATH . $this->_options['model_options']['dir']; - $this->_options['traffic']['dir'] = PATH . $this->_options['traffic']['dir']; - $this->_options['purge']['dir'] = PATH . $this->_options['purge']['dir']; $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_cfg'; if (!is_dir($this->_path)) { mkdir($this->_path); diff --git a/tst/ConfigurationTestGenerator.php b/tst/ConfigurationTestGenerator.php index 284fa5f2..945fc479 100755 --- a/tst/ConfigurationTestGenerator.php +++ b/tst/ConfigurationTestGenerator.php @@ -428,8 +428,6 @@ class ConfigurationCombinationsTest extends PHPUnit_Framework_TestCase Helper::confBackup(); $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data'; $this->_model = Filesystem::getInstance(array('dir' => $this->_path)); - ServerSalt::setPath($this->_path); - TrafficLimiter::setPath($this->_path); $this->reset(); } @@ -449,8 +447,6 @@ class ConfigurationCombinationsTest extends PHPUnit_Framework_TestCase if ($this->_model->exists(Helper::getPasteId())) $this->_model->delete(Helper::getPasteId()); $configuration['model_options']['dir'] = $this->_path; - $configuration['traffic']['dir'] = $this->_path; - $configuration['purge']['dir'] = $this->_path; Helper::createIniFile(CONF, $configuration); } diff --git a/tst/ControllerTest.php b/tst/ControllerTest.php index b00f2ce6..6e7ec4c0 100644 --- a/tst/ControllerTest.php +++ b/tst/ControllerTest.php @@ -37,11 +37,8 @@ class ControllerTest extends PHPUnit_Framework_TestCase $this->_data->delete(Helper::getPasteId()); } $options = parse_ini_file(CONF_SAMPLE, true); - $options['purge']['dir'] = $this->_path; - $options['traffic']['dir'] = $this->_path; $options['model_options']['dir'] = $this->_path; Helper::createIniFile(CONF, $options); - ServerSalt::setPath($this->_path); } /** diff --git a/tst/JsonApiTest.php b/tst/JsonApiTest.php index 9655e609..17b699f1 100644 --- a/tst/JsonApiTest.php +++ b/tst/JsonApiTest.php @@ -25,8 +25,6 @@ class JsonApiTest extends PHPUnit_Framework_TestCase $this->_model->delete(Helper::getPasteId()); } $options = parse_ini_file(CONF_SAMPLE, true); - $options['purge']['dir'] = $this->_path; - $options['traffic']['dir'] = $this->_path; $options['model_options']['dir'] = $this->_path; Helper::confBackup(); Helper::createIniFile(CONF, $options); diff --git a/tst/Persistence/PurgeLimiterTest.php b/tst/Persistence/PurgeLimiterTest.php index e8cedc0a..adb96ffd 100644 --- a/tst/Persistence/PurgeLimiterTest.php +++ b/tst/Persistence/PurgeLimiterTest.php @@ -14,7 +14,6 @@ class PurgeLimiterTest extends PHPUnit_Framework_TestCase if (!is_dir($this->_path)) { mkdir($this->_path); } - PurgeLimiter::setPath($this->_path); PurgeLimiter::setStore( Filesystem::getInstance(array('dir' => $this->_path)) ); From b5a6ce323e04318fba7a45a089bd6c872cd5b89c Mon Sep 17 00:00:00 2001 From: El RIDO Date: Tue, 8 Jun 2021 07:49:22 +0200 Subject: [PATCH 177/223] folding Persistance\TrafficLimiter into Data\Filesystem --- lib/Controller.php | 1 + lib/Data/AbstractData.php | 10 +++++++ lib/Data/Database.php | 17 +++++++++++ lib/Data/Filesystem.php | 45 ++++++++++++++++++++++++++++-- lib/Data/GoogleCloudStorage.php | 17 +++++++++++ lib/Model.php | 8 +++--- lib/Persistence/TrafficLimiter.php | 31 +++++--------------- tst/ControllerTest.php | 1 + 8 files changed, 100 insertions(+), 30 deletions(-) diff --git a/lib/Controller.php b/lib/Controller.php index 72bd5b2e..095bbebb 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -198,6 +198,7 @@ class Controller try { // Ensure last paste from visitors IP address was more than configured amount of seconds ago. TrafficLimiter::setConfiguration($this->_conf); + TrafficLimiter::setStore($this->_model->getStore()); if (!TrafficLimiter::canPass()) { $this->_return_message( 1, I18n::_( diff --git a/lib/Data/AbstractData.php b/lib/Data/AbstractData.php index 0508bc02..3de4bab7 100644 --- a/lib/Data/AbstractData.php +++ b/lib/Data/AbstractData.php @@ -130,6 +130,16 @@ abstract class AbstractData */ abstract public function existsComment($pasteid, $parentid, $commentid); + /** + * Purge outdated entries. + * + * @access public + * @param string $namespace + * @param int $time + * @return void + */ + abstract public function purgeValues($namespace, $time); + /** * Save a value. * diff --git a/lib/Data/Database.php b/lib/Data/Database.php index 5a0f369e..2a1bbcbe 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -423,6 +423,23 @@ class Database extends AbstractData ); } + /** + * Purge outdated entries. + * + * @access public + * @param string $namespace + * @param int $time + * @return void + */ + public function purgeValues($namespace, $time) + { + switch ($namespace) { + case 'traffic_limiter': + ; + break; + } + } + /** * Save a value. * diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index f24691b9..3a481d92 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -38,6 +38,15 @@ class Filesystem extends AbstractData */ private static $_path = 'data'; + /** + * cache for the traffic limiter + * + * @access private + * @static + * @var array + */ + private static $_traffic_limiter_cache = array(); + /** * get instance of singleton * @@ -240,6 +249,27 @@ class Filesystem extends AbstractData ); } + /** + * Purge outdated entries. + * + * @access public + * @param string $namespace + * @param int $time + * @return void + */ + public function purgeValues($namespace, $time) + { + switch ($namespace) { + case 'traffic_limiter': + foreach (self::$_traffic_limiter_cache as $key => $last_access) { + if ($last_access <= $time) { + unset(self::$_traffic_limiter_cache[$key]); + } + } + break; + } + } + /** * Save a value. * @@ -262,7 +292,11 @@ class Filesystem extends AbstractData ; break; case 'traffic_limiter': - ; + self::$_traffic_limiter_cache[$key] = $value; + return self::_storeString( + self::$_path . DIRECTORY_SEPARATOR . 'traffic_limiter.php', + 'exists(); } + /** + * Purge outdated entries. + * + * @access public + * @param string $namespace + * @param int $time + * @return void + */ + public function purgeValues($namespace, $time) + { + switch ($namespace) { + case 'traffic_limiter': + ; + break; + } + } + /** * This is the simplest thing that could possibly work. * will be to tested for runtime performance. diff --git a/lib/Model.php b/lib/Model.php index 1a23653c..8aebd794 100644 --- a/lib/Model.php +++ b/lib/Model.php @@ -54,7 +54,7 @@ class Model */ public function getPaste($pasteId = null) { - $paste = new Paste($this->_conf, $this->_getStore()); + $paste = new Paste($this->_conf, $this->getStore()); if ($pasteId !== null) { $paste->setId($pasteId); } @@ -67,9 +67,9 @@ class Model public function purge() { PurgeLimiter::setConfiguration($this->_conf); - PurgeLimiter::setStore($this->_getStore()); + PurgeLimiter::setStore($this->getStore()); if (PurgeLimiter::canPurge()) { - $this->_getStore()->purge($this->_conf->getKey('batchsize', 'purge')); + $this->getStore()->purge($this->_conf->getKey('batchsize', 'purge')); } } @@ -78,7 +78,7 @@ class Model * * @return Data\AbstractData */ - private function _getStore() + public function getStore() { if ($this->_store === null) { $this->_store = forward_static_call( diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 299c7a6d..f6bc07fb 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -169,35 +169,18 @@ class TrafficLimiter extends AbstractPersistence } } - $file = 'traffic_limiter.php'; - if (self::_exists($file)) { - require self::getPath($file); - $tl = $GLOBALS['traffic_limiter']; - } else { - $tl = array(); - } - - // purge file of expired hashes to keep it small - $now = time(); - foreach ($tl as $key => $time) { - if ($time + self::$_limit < $now) { - unset($tl[$key]); - } - } - // this hash is used as an array key, hence a shorter algo is used $hash = self::getHash('sha256'); - if (array_key_exists($hash, $tl) && ($tl[$hash] + self::$_limit >= $now)) { + $now = time(); + $tl = self::$_store->getValue('traffic_limiter', $hash); + self::$_store->purgeValues('traffic_limiter', $now - self::$_limit); + if ($tl > 0 && ($tl + self::$_limit >= $now)) { $result = false; } else { - $tl[$hash] = time(); - $result = true; + $tl = time(); + $result = true; } - self::_store( - $file, - 'setValue((string) $tl, 'traffic_limiter'); return $result; } } diff --git a/tst/ControllerTest.php b/tst/ControllerTest.php index 6e7ec4c0..92683ced 100644 --- a/tst/ControllerTest.php +++ b/tst/ControllerTest.php @@ -17,6 +17,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase /* Setup Routine */ $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data'; $this->_data = Filesystem::getInstance(array('dir' => $this->_path)); + TrafficLimiter::setStore($this->_data); $this->reset(); } From 7901ec74a7167c6fb65866826d7c21e936427c4c Mon Sep 17 00:00:00 2001 From: El RIDO Date: Tue, 8 Jun 2021 22:01:29 +0200 Subject: [PATCH 178/223] folding Persistance\ServerSalt into Data\Filesystem --- lib/Controller.php | 1 + lib/Data/Filesystem.php | 22 +++-- lib/Model/Paste.php | 2 +- lib/Persistence/AbstractPersistence.php | 113 ------------------------ lib/Persistence/ServerSalt.php | 23 ++--- lib/Persistence/TrafficLimiter.php | 4 +- tst/ControllerTest.php | 22 ----- tst/JsonApiTest.php | 2 +- tst/ModelTest.php | 2 +- tst/Persistence/ServerSaltTest.php | 64 ++++++++------ tst/Persistence/TrafficLimiterTest.php | 18 +++- tst/Vizhash16x16Test.php | 3 +- 12 files changed, 80 insertions(+), 196 deletions(-) diff --git a/lib/Controller.php b/lib/Controller.php index 095bbebb..4a1aa0d7 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -197,6 +197,7 @@ class Controller { try { // Ensure last paste from visitors IP address was more than configured amount of seconds ago. + ServerSalt::setStore($this->_model->getStore()); TrafficLimiter::setConfiguration($this->_conf); TrafficLimiter::setStore($this->_model->getStore()); if (!TrafficLimiter::canPass()) { diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 3a481d92..8b443ad4 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -287,17 +287,17 @@ class Filesystem extends AbstractData self::$_path . DIRECTORY_SEPARATOR . 'purge_limiter.php', '_data['meta']['created'] = time(); - $this->_data['meta']['salt'] = serversalt::generate(); + $this->_data['meta']['salt'] = ServerSalt::generate(); // store paste if ( diff --git a/lib/Persistence/AbstractPersistence.php b/lib/Persistence/AbstractPersistence.php index 73f0ab2e..4e61a8ee 100644 --- a/lib/Persistence/AbstractPersistence.php +++ b/lib/Persistence/AbstractPersistence.php @@ -12,7 +12,6 @@ namespace PrivateBin\Persistence; -use Exception; use PrivateBin\Data\AbstractData; /** @@ -22,15 +21,6 @@ use PrivateBin\Data\AbstractData; */ abstract class AbstractPersistence { - /** - * path in which to persist something - * - * @access private - * @static - * @var string - */ - private static $_path = 'data'; - /** * data storage to use to persist something * @@ -40,18 +30,6 @@ abstract class AbstractPersistence */ protected static $_store; - /** - * set the path - * - * @access public - * @static - * @param string $path - */ - public static function setPath($path) - { - self::$_path = $path; - } - /** * set the path * @@ -63,95 +41,4 @@ abstract class AbstractPersistence { self::$_store = $store; } - - /** - * get the path - * - * @access public - * @static - * @param string $filename - * @return string - */ - public static function getPath($filename = null) - { - if (strlen($filename)) { - return self::$_path . DIRECTORY_SEPARATOR . $filename; - } else { - return self::$_path; - } - } - - /** - * checks if the file exists - * - * @access protected - * @static - * @param string $filename - * @return bool - */ - protected static function _exists($filename) - { - self::_initialize(); - return is_file(self::$_path . DIRECTORY_SEPARATOR . $filename); - } - - /** - * prepares path for storage - * - * @access protected - * @static - * @throws Exception - */ - protected static function _initialize() - { - // Create storage directory if it does not exist. - if (!is_dir(self::$_path)) { - if (!@mkdir(self::$_path, 0700)) { - throw new Exception('unable to create directory ' . self::$_path, 10); - } - } - $file = self::$_path . DIRECTORY_SEPARATOR . '.htaccess'; - if (!is_file($file)) { - $writtenBytes = 0; - if ($fileCreated = @touch($file)) { - $writtenBytes = @file_put_contents( - $file, - 'Require all denied' . PHP_EOL, - LOCK_EX - ); - } - if ($fileCreated === false || $writtenBytes === false || $writtenBytes < 19) { - throw new Exception('unable to write to file ' . $file, 11); - } - } - } - - /** - * store the data - * - * @access protected - * @static - * @param string $filename - * @param string $data - * @throws Exception - * @return string - */ - protected static function _store($filename, $data) - { - self::_initialize(); - $file = self::$_path . DIRECTORY_SEPARATOR . $filename; - $fileCreated = true; - $writtenBytes = 0; - if (!is_file($file)) { - $fileCreated = @touch($file); - } - if ($fileCreated) { - $writtenBytes = @file_put_contents($file, $data, LOCK_EX); - } - if ($fileCreated === false || $writtenBytes === false || $writtenBytes < strlen($data)) { - throw new Exception('unable to write to file ' . $file, 13); - } - @chmod($file, 0640); // protect file access - return $file; - } } diff --git a/lib/Persistence/ServerSalt.php b/lib/Persistence/ServerSalt.php index 329a8ef2..93f5486e 100644 --- a/lib/Persistence/ServerSalt.php +++ b/lib/Persistence/ServerSalt.php @@ -13,6 +13,7 @@ namespace PrivateBin\Persistence; use Exception; +use PrivateBin\Data\AbstractData; /** * ServerSalt @@ -71,20 +72,12 @@ class ServerSalt extends AbstractPersistence return self::$_salt; } - if (self::_exists(self::$_file)) { - if (is_readable(self::getPath(self::$_file))) { - $items = explode('|', file_get_contents(self::getPath(self::$_file))); - } - if (!isset($items) || !is_array($items) || count($items) != 3) { - throw new Exception('unable to read file ' . self::getPath(self::$_file), 20); - } - self::$_salt = $items[1]; + $salt = self::$_store->getValue('salt'); + if ($salt) { + self::$_salt = $salt; } else { self::$_salt = self::generate(); - self::_store( - self::$_file, - 'setValue(self::$_salt, 'salt'); } return self::$_salt; } @@ -94,11 +87,11 @@ class ServerSalt extends AbstractPersistence * * @access public * @static - * @param string $path + * @param AbstractData $store */ - public static function setPath($path) + public static function setStore(AbstractData $store) { self::$_salt = ''; - parent::setPath($path); + parent::setStore($store); } } diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index f6bc07fb..11468614 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -172,7 +172,7 @@ class TrafficLimiter extends AbstractPersistence // this hash is used as an array key, hence a shorter algo is used $hash = self::getHash('sha256'); $now = time(); - $tl = self::$_store->getValue('traffic_limiter', $hash); + $tl = (int) self::$_store->getValue('traffic_limiter', $hash); self::$_store->purgeValues('traffic_limiter', $now - self::$_limit); if ($tl > 0 && ($tl + self::$_limit >= $now)) { $result = false; @@ -180,7 +180,7 @@ class TrafficLimiter extends AbstractPersistence $tl = time(); $result = true; } - self::$_store->setValue((string) $tl, 'traffic_limiter'); + self::$_store->setValue((string) $tl, 'traffic_limiter', $hash); return $result; } } diff --git a/tst/ControllerTest.php b/tst/ControllerTest.php index 92683ced..165ae089 100644 --- a/tst/ControllerTest.php +++ b/tst/ControllerTest.php @@ -125,28 +125,6 @@ class ControllerTest extends PHPUnit_Framework_TestCase ); } - /** - * @runInSeparateProcess - */ - public function testHtaccess() - { - $htaccess = $this->_path . DIRECTORY_SEPARATOR . '.htaccess'; - @unlink($htaccess); - - $paste = Helper::getPasteJson(); - $file = tempnam(sys_get_temp_dir(), 'FOO'); - file_put_contents($file, $paste); - Request::setInputStream($file); - $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_SERVER['REMOTE_ADDR'] = '::1'; - ob_start(); - new Controller; - ob_end_clean(); - - $this->assertFileExists($htaccess, 'htaccess recreated'); - } - /** * @expectedException Exception * @expectedExceptionCode 2 diff --git a/tst/JsonApiTest.php b/tst/JsonApiTest.php index 17b699f1..6d9732a5 100644 --- a/tst/JsonApiTest.php +++ b/tst/JsonApiTest.php @@ -16,7 +16,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase /* Setup Routine */ $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data'; $this->_model = Filesystem::getInstance(array('dir' => $this->_path)); - ServerSalt::setPath($this->_path); + ServerSalt::setStore($this->_model); $_POST = array(); $_GET = array(); diff --git a/tst/ModelTest.php b/tst/ModelTest.php index d5c4074f..478d4c10 100644 --- a/tst/ModelTest.php +++ b/tst/ModelTest.php @@ -25,7 +25,6 @@ class ModelTest extends PHPUnit_Framework_TestCase if (!is_dir($this->_path)) { mkdir($this->_path); } - ServerSalt::setPath($this->_path); $options = parse_ini_file(CONF_SAMPLE, true); $options['purge']['limit'] = 0; $options['model'] = array( @@ -39,6 +38,7 @@ class ModelTest extends PHPUnit_Framework_TestCase ); Helper::confBackup(); Helper::createIniFile(CONF, $options); + ServerSalt::setStore(Database::getInstance($options['model_options'])); $this->_conf = new Configuration; $this->_model = new Model($this->_conf); $_SERVER['REMOTE_ADDR'] = '::1'; diff --git a/tst/Persistence/ServerSaltTest.php b/tst/Persistence/ServerSaltTest.php index ecdc0f83..3db5f7d7 100644 --- a/tst/Persistence/ServerSaltTest.php +++ b/tst/Persistence/ServerSaltTest.php @@ -1,5 +1,6 @@ _path)) { mkdir($this->_path); } - ServerSalt::setPath($this->_path); + ServerSalt::setStore( + Filesystem::getInstance(array('dir' => $this->_path)) + ); $this->_otherPath = $this->_path . DIRECTORY_SEPARATOR . 'foo'; @@ -40,46 +43,46 @@ class ServerSaltTest extends PHPUnit_Framework_TestCase public function testGeneration() { // generating new salt - ServerSalt::setPath($this->_path); + ServerSalt::setStore( + Filesystem::getInstance(array('dir' => $this->_path)) + ); $salt = ServerSalt::get(); // try setting a different path and resetting it - ServerSalt::setPath($this->_otherPath); + ServerSalt::setStore( + Filesystem::getInstance(array('dir' => $this->_otherPath)) + ); $this->assertNotEquals($salt, ServerSalt::get()); - ServerSalt::setPath($this->_path); + ServerSalt::setStore( + Filesystem::getInstance(array('dir' => $this->_path)) + ); $this->assertEquals($salt, ServerSalt::get()); } - /** - * @expectedException Exception - * @expectedExceptionCode 11 - */ public function testPathShenanigans() { // try setting an invalid path chmod($this->_invalidPath, 0000); - ServerSalt::setPath($this->_invalidPath); - ServerSalt::get(); + $store = Filesystem::getInstance(array('dir' => $this->_invalidPath)); + ServerSalt::setStore($store); + $salt = ServerSalt::get(); + ServerSalt::setStore($store); + $this->assertNotEquals($salt, ServerSalt::get()); } - /** - * @expectedException Exception - * @expectedExceptionCode 20 - */ public function testFileRead() { // try setting an invalid file chmod($this->_invalidPath, 0700); file_put_contents($this->_invalidFile, ''); chmod($this->_invalidFile, 0000); - ServerSalt::setPath($this->_invalidPath); - ServerSalt::get(); + $store = Filesystem::getInstance(array('dir' => $this->_invalidPath)); + ServerSalt::setStore($store); + $salt = ServerSalt::get(); + ServerSalt::setStore($store); + $this->assertNotEquals($salt, ServerSalt::get()); } - /** - * @expectedException Exception - * @expectedExceptionCode 13 - */ public function testFileWrite() { // try setting an invalid file @@ -90,19 +93,24 @@ class ServerSaltTest extends PHPUnit_Framework_TestCase } file_put_contents($this->_invalidPath . DIRECTORY_SEPARATOR . '.htaccess', ''); chmod($this->_invalidPath, 0500); - ServerSalt::setPath($this->_invalidPath); - ServerSalt::get(); + $store = Filesystem::getInstance(array('dir' => $this->_invalidPath)); + ServerSalt::setStore($store); + $salt = ServerSalt::get(); + ServerSalt::setStore($store); + $this->assertNotEquals($salt, ServerSalt::get()); } - /** - * @expectedException Exception - * @expectedExceptionCode 10 - */ public function testPermissionShenanigans() { // try creating an invalid path chmod($this->_invalidPath, 0000); - ServerSalt::setPath($this->_invalidPath . DIRECTORY_SEPARATOR . 'baz'); - ServerSalt::get(); + ServerSalt::setStore( + Filesystem::getInstance(array('dir' => $this->_invalidPath . DIRECTORY_SEPARATOR . 'baz')) + ); + $store = Filesystem::getInstance(array('dir' => $this->_invalidPath)); + ServerSalt::setStore($store); + $salt = ServerSalt::get(); + ServerSalt::setStore($store); + $this->assertNotEquals($salt, ServerSalt::get()); } } diff --git a/tst/Persistence/TrafficLimiterTest.php b/tst/Persistence/TrafficLimiterTest.php index 41013016..2e81d83a 100644 --- a/tst/Persistence/TrafficLimiterTest.php +++ b/tst/Persistence/TrafficLimiterTest.php @@ -1,5 +1,7 @@ _path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'trafficlimit'; - TrafficLimiter::setPath($this->_path); + $store = Filesystem::getInstance(array('dir' => $this->_path)); + ServerSalt::setStore($store); + TrafficLimiter::setStore($store); } public function tearDown() @@ -19,11 +23,17 @@ class TrafficLimiterTest extends PHPUnit_Framework_TestCase Helper::rmDir($this->_path . DIRECTORY_SEPARATOR); } + public function testHtaccess() + { + $htaccess = $this->_path . DIRECTORY_SEPARATOR . '.htaccess'; + @unlink($htaccess); + $_SERVER['REMOTE_ADDR'] = 'foobar'; + TrafficLimiter::canPass(); + $this->assertFileExists($htaccess, 'htaccess recreated'); + } + public function testTrafficGetsLimited() { - $this->assertEquals($this->_path, TrafficLimiter::getPath()); - $file = 'baz'; - $this->assertEquals($this->_path . DIRECTORY_SEPARATOR . $file, TrafficLimiter::getPath($file)); TrafficLimiter::setLimit(4); $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; $this->assertTrue(TrafficLimiter::canPass(), 'first request may pass'); diff --git a/tst/Vizhash16x16Test.php b/tst/Vizhash16x16Test.php index afcda562..abfb8c49 100644 --- a/tst/Vizhash16x16Test.php +++ b/tst/Vizhash16x16Test.php @@ -1,5 +1,6 @@ _path); } $this->_file = $this->_path . DIRECTORY_SEPARATOR . 'vizhash.png'; - ServerSalt::setPath($this->_path); + ServerSalt::setStore(Filesystem::getInstance(array('dir' => $this->_path))); } public function tearDown() From a203e6322b16823b126f0538313d79855ced7560 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 9 Jun 2021 07:47:40 +0200 Subject: [PATCH 179/223] implementing key/value store of Persistance in Database storage --- CHANGELOG.md | 1 + lib/Data/AbstractData.php | 20 +++++++++- lib/Data/Database.php | 71 +++++++++++++++++++-------------- lib/Data/Filesystem.php | 30 -------------- lib/Data/GoogleCloudStorage.php | 9 +++-- tst/ControllerTest.php | 1 + tst/ControllerWithDbTest.php | 4 ++ tst/Data/DatabaseTest.php | 15 +++++++ 8 files changed, 86 insertions(+), 65 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c546bd11..d964a57a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * CHANGED: Upgrading libraries to: random_compat 2.0.20 * CHANGED: Removed automatic `.ini` configuration file migration (#808) * CHANGED: Removed configurable `dir` for `traffic` & `purge` limiters (#419) + * CHANGED: Server salt, traffic and purge limiter now stored in the storage backend (#419) * **1.3.5 (2021-04-05)** * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan * ADDED: Make the project info configurable (#681) diff --git a/lib/Data/AbstractData.php b/lib/Data/AbstractData.php index 3de4bab7..6f2dee53 100644 --- a/lib/Data/AbstractData.php +++ b/lib/Data/AbstractData.php @@ -28,6 +28,15 @@ abstract class AbstractData */ protected static $_instance = null; + /** + * cache for the traffic limiter + * + * @access private + * @static + * @var array + */ + protected static $_traffic_limiter_cache = array(); + /** * Enforce singleton, disable constructor * @@ -138,7 +147,16 @@ abstract class AbstractData * @param int $time * @return void */ - abstract public function purgeValues($namespace, $time); + public function purgeValues($namespace, $time) + { + if ($namespace === 'traffic_limiter') { + foreach (self::$_traffic_limiter_cache as $key => $last_access) { + if ($last_access <= $time) { + unset(self::$_traffic_limiter_cache[$key]); + } + } + } + } /** * Save a value. diff --git a/lib/Data/Database.php b/lib/Data/Database.php index 2a1bbcbe..ca0cc799 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -423,23 +423,6 @@ class Database extends AbstractData ); } - /** - * Purge outdated entries. - * - * @access public - * @param string $namespace - * @param int $time - * @return void - */ - public function purgeValues($namespace, $time) - { - switch ($namespace) { - case 'traffic_limiter': - ; - break; - } - } - /** * Save a value. * @@ -451,20 +434,19 @@ class Database extends AbstractData */ public function setValue($value, $namespace, $key = '') { - switch ($namespace) { - case 'purge_limiter': - ; - break; - case 'salt': - ; - break; - case 'traffic_limiter': - ; - break; - default: + if ($namespace === 'traffic_limiter') { + self::$_traffic_limiter_cache[$key] = $value; + try { + $value = Json::encode(self::$_traffic_limiter_cache); + } catch (Exception $e) { return false; - break; + } } + return self::_exec( + 'UPDATE ' . self::_sanitizeIdentifier('config') . + ' SET value = ? WHERE id = ?', + array($value, strtoupper($namespace)) + ); } /** @@ -477,7 +459,36 @@ class Database extends AbstractData */ public function getValue($namespace, $key = '') { + $configKey = strtoupper($namespace); + $value = $this->_getConfig($configKey); + if ($value === '') { + // initialize the row, so that setValue can rely on UPDATE queries + self::_exec( + 'INSERT INTO ' . self::_sanitizeIdentifier('config') . + ' VALUES(?,?)', + array($configKey, '') + ); + // migrate filesystem based salt into database + $file = 'data' . DIRECTORY_SEPARATOR . 'salt.php'; + if ($namespace === 'salt' && is_readable($file)) { + $value = Filesystem::getInstance(array('dir' => 'data'))->getValue('salt'); + $this->setValue($value, 'salt'); + @unlink($file); + return $value; + } + } + if ($value && $namespace === 'traffic_limiter') { + try { + self::$_traffic_limiter_cache = Json::decode($value); + } catch (Exception $e) { + self::$_traffic_limiter_cache = array(); + } + if (array_key_exists($key, self::$_traffic_limiter_cache)) { + return self::$_traffic_limiter_cache[$key]; + } + } + return (string) $value; } /** @@ -629,7 +640,7 @@ class Database extends AbstractData 'SELECT value FROM ' . self::_sanitizeIdentifier('config') . ' WHERE id = ?', array($key), true ); - return $row['value']; + return $row ? $row['value']: ''; } /** diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 8b443ad4..384c72d1 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -38,15 +38,6 @@ class Filesystem extends AbstractData */ private static $_path = 'data'; - /** - * cache for the traffic limiter - * - * @access private - * @static - * @var array - */ - private static $_traffic_limiter_cache = array(); - /** * get instance of singleton * @@ -249,27 +240,6 @@ class Filesystem extends AbstractData ); } - /** - * Purge outdated entries. - * - * @access public - * @param string $namespace - * @param int $time - * @return void - */ - public function purgeValues($namespace, $time) - { - switch ($namespace) { - case 'traffic_limiter': - foreach (self::$_traffic_limiter_cache as $key => $last_access) { - if ($last_access <= $time) { - unset(self::$_traffic_limiter_cache[$key]); - } - } - break; - } - } - /** * Save a value. * diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index f6fc4898..2521957b 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -227,10 +227,11 @@ class GoogleCloudStorage extends AbstractData */ public function purgeValues($namespace, $time) { - switch ($namespace) { - case 'traffic_limiter': - ; - break; + if ($namespace === 'traffic_limiter') { + // TODO implement purging of keys in namespace that are <= $time + // if GCS has no easy way to iterate all keys, consider using the + // self::$_traffic_limiter_cache in a similar way as the other + // implementations. } } diff --git a/tst/ControllerTest.php b/tst/ControllerTest.php index 165ae089..0aa7d794 100644 --- a/tst/ControllerTest.php +++ b/tst/ControllerTest.php @@ -17,6 +17,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase /* Setup Routine */ $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data'; $this->_data = Filesystem::getInstance(array('dir' => $this->_path)); + ServerSalt::setStore($this->_data); TrafficLimiter::setStore($this->_data); $this->reset(); } diff --git a/tst/ControllerWithDbTest.php b/tst/ControllerWithDbTest.php index 90dee920..bc8cd7be 100644 --- a/tst/ControllerWithDbTest.php +++ b/tst/ControllerWithDbTest.php @@ -1,6 +1,8 @@ _options['dsn'] = 'sqlite:' . $this->_path . DIRECTORY_SEPARATOR . 'tst.sq3'; $this->_data = Database::getInstance($this->_options); + ServerSalt::setStore($this->_data); + TrafficLimiter::setStore($this->_data); $this->reset(); } diff --git a/tst/Data/DatabaseTest.php b/tst/Data/DatabaseTest.php index 0d48eb6a..f9cd2652 100644 --- a/tst/Data/DatabaseTest.php +++ b/tst/Data/DatabaseTest.php @@ -2,6 +2,8 @@ use PrivateBin\Controller; use PrivateBin\Data\Database; +use PrivateBin\Data\Filesystem; +use PrivateBin\Persistence\ServerSalt; class DatabaseTest extends PHPUnit_Framework_TestCase { @@ -31,6 +33,19 @@ class DatabaseTest extends PHPUnit_Framework_TestCase } } + public function testSaltMigration() + { + ServerSalt::setStore(Filesystem::getInstance(array('dir' => 'data'))); + $salt = ServerSalt::get(); + $file = 'data' . DIRECTORY_SEPARATOR . 'salt.php'; + $this->assertFileExists($file, 'ServerSalt got initialized and stored on disk'); + $this->assertNotEquals($salt, ''); + ServerSalt::setStore($this->_model); + ServerSalt::get(); + $this->assertFileNotExists($file, 'legacy ServerSalt got removed'); + $this->assertEquals($salt, ServerSalt::get(), 'ServerSalt got preserved & migrated'); + } + public function testDatabaseBasedDataStoreWorks() { $this->_model->delete(Helper::getPasteId()); From 7b2f0ff302a24c15a7597c23e3bf03adfabc2dca Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 9 Jun 2021 19:16:22 +0200 Subject: [PATCH 180/223] apply StyleCI recommendation --- lib/Data/Database.php | 4 ++-- lib/Persistence/TrafficLimiter.php | 4 ++-- tst/Persistence/TrafficLimiterTest.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Data/Database.php b/lib/Data/Database.php index ca0cc799..ae4da190 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -460,7 +460,7 @@ class Database extends AbstractData public function getValue($namespace, $key = '') { $configKey = strtoupper($namespace); - $value = $this->_getConfig($configKey); + $value = $this->_getConfig($configKey); if ($value === '') { // initialize the row, so that setValue can rely on UPDATE queries self::_exec( @@ -640,7 +640,7 @@ class Database extends AbstractData 'SELECT value FROM ' . self::_sanitizeIdentifier('config') . ' WHERE id = ?', array($key), true ); - return $row ? $row['value']: ''; + return $row ? $row['value'] : ''; } /** diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 11468614..930272df 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -171,8 +171,8 @@ class TrafficLimiter extends AbstractPersistence // this hash is used as an array key, hence a shorter algo is used $hash = self::getHash('sha256'); - $now = time(); - $tl = (int) self::$_store->getValue('traffic_limiter', $hash); + $now = time(); + $tl = (int) self::$_store->getValue('traffic_limiter', $hash); self::$_store->purgeValues('traffic_limiter', $now - self::$_limit); if ($tl > 0 && ($tl + self::$_limit >= $now)) { $result = false; diff --git a/tst/Persistence/TrafficLimiterTest.php b/tst/Persistence/TrafficLimiterTest.php index 2e81d83a..aedbf889 100644 --- a/tst/Persistence/TrafficLimiterTest.php +++ b/tst/Persistence/TrafficLimiterTest.php @@ -12,7 +12,7 @@ class TrafficLimiterTest extends PHPUnit_Framework_TestCase { /* Setup Routine */ $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'trafficlimit'; - $store = Filesystem::getInstance(array('dir' => $this->_path)); + $store = Filesystem::getInstance(array('dir' => $this->_path)); ServerSalt::setStore($store); TrafficLimiter::setStore($store); } From 1232717334aa2ff65edf3381a21152bb6e1b02cd Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Wed, 9 Jun 2021 22:27:34 +0200 Subject: [PATCH 181/223] added purgeValues to GCS --- lib/Data/GoogleCloudStorage.php | 37 ++++++++++++++++++++--------- tst/Data/GoogleCloudStorageTest.php | 22 ++++++++++++----- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index 2521957b..75bb8a65 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -2,6 +2,7 @@ namespace PrivateBin\Data; +use DateTime; use Exception; use Google\Cloud\Core\Exception\NotFoundException; use Google\Cloud\Storage\StorageClient; @@ -9,6 +10,8 @@ use PrivateBin\Json; class GoogleCloudStorage extends AbstractData { + const DATETIME_FORMAT = 'Y-m-d\TH:i:s.u\Z'; + /** * returns a Google Cloud Storage data backend. * @@ -218,20 +221,32 @@ class GoogleCloudStorage extends AbstractData } /** - * Purge outdated entries. - * - * @access public - * @param string $namespace - * @param int $time - * @return void + * @inheritDoc */ public function purgeValues($namespace, $time) { - if ($namespace === 'traffic_limiter') { - // TODO implement purging of keys in namespace that are <= $time - // if GCS has no easy way to iterate all keys, consider using the - // self::$_traffic_limiter_cache in a similar way as the other - // implementations. + $prefix = 'config/' . $namespace . '/'; + try { + foreach ($this->_bucket->objects(array('prefix' => $prefix)) as $object) { + $info = $object->info(); + $timeCreated = false; + if (key_exists('timeCreated', $info)) { + $timeCreated = DateTime::createFromFormat(GoogleCloudStorage::DATETIME_FORMAT, $info['timeCreated']); + } + if ($timeCreated && ($timeCreated->getTimestamp() < $time)) { + try { + $object->delete(); + } catch (NotFoundException $e) { + // deleted by another instance. + } + } else { + if (!$timeCreated) { + error_log('failed to parse create timestamp ' . $info['timeCreated'] . ' of object ' . $object->name()); + } + } + } + } catch (NotFoundException $e) { + // no objects in the bucket yet } } diff --git a/tst/Data/GoogleCloudStorageTest.php b/tst/Data/GoogleCloudStorageTest.php index 30a7d5eb..1c5190de 100644 --- a/tst/Data/GoogleCloudStorageTest.php +++ b/tst/Data/GoogleCloudStorageTest.php @@ -43,7 +43,6 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase foreach (self::$_bucket->objects() as $object) { $object->delete(); } - error_reporting(E_ALL); } public static function tearDownAfterClass() @@ -145,17 +144,26 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase $this->_model->setValue($salt, 'salt', 'master'); $storedSalt = $this->_model->getValue('salt', 'master'); $this->assertEquals($salt, $storedSalt); + $this->_model->purgeValues('salt', time() + 60); + $this->assertFalse($this->_model->getValue('salt', 'master')); $client = hash_hmac('sha512', '127.0.0.1', $salt); $expire = time(); $this->_model->setValue($expire, 'traffic_limiter', $client); $storedExpired = $this->_model->getValue('traffic_limiter', $client); $this->assertEquals($expire, $storedExpired); + $this->assertEquals($expire, $storedExpired); + $this->_model->purgeValues('traffic_limiter', time() - 60); + $this->assertEquals($storedExpired, $this->_model->getValue('traffic_limiter', $client)); + $this->_model->purgeValues('traffic_limiter', time() + 60); + $this->assertFalse($this->_model->getValue('traffic_limiter', $client)); $purgeAt = $expire + (15 * 60); $this->_model->setValue($purgeAt, 'purge_limiter', 'at'); $storedPurgedAt = $this->_model->getValue('purge_limiter', 'at'); $this->assertEquals($purgeAt, $storedPurgedAt); + $this->_model->purgeValues('purge_limiter', time() + 60); + $this->assertFalse($this->_model->getValue('purge_limiter', 'at')); } } @@ -431,11 +439,13 @@ class StorageObjectStub extends StorageObject public function __construct(ConnectionInterface $connection, $name, $bucket, $generation = null, array $info = array(), $encryptionKey = null, $encryptionKeySHA256 = null) { - $this->_name = $name; - $this->_bucket = $bucket; - $this->_generation = $generation; - $this->_info = $info; - $this->_connection = $connection; + $this->_name = $name; + $this->_bucket = $bucket; + $this->_generation = $generation; + $this->_info = $info; + $this->_connection = $connection; + $timeCreated = new Datetime(); + $this->_info['metadata']['timeCreated'] = $timeCreated->format(GoogleCloudStorage::DATETIME_FORMAT); } public function acl() From 1b88eef3569f39c0596d2fb5b39d23301f65af0f Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Thu, 10 Jun 2021 21:39:15 +0200 Subject: [PATCH 182/223] improved implementation of GoogleStorageBucket --- lib/Data/GoogleCloudStorage.php | 55 +++++++++++++++++------------ tst/Data/GoogleCloudStorageTest.php | 43 +++++++++++++++++++--- 2 files changed, 71 insertions(+), 27 deletions(-) diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index 75bb8a65..6bbea600 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -2,7 +2,6 @@ namespace PrivateBin\Data; -use DateTime; use Exception; use Google\Cloud\Core\Exception\NotFoundException; use Google\Cloud\Storage\StorageClient; @@ -225,23 +224,22 @@ class GoogleCloudStorage extends AbstractData */ public function purgeValues($namespace, $time) { - $prefix = 'config/' . $namespace . '/'; + $path = 'config/' . $namespace; try { - foreach ($this->_bucket->objects(array('prefix' => $prefix)) as $object) { - $info = $object->info(); - $timeCreated = false; - if (key_exists('timeCreated', $info)) { - $timeCreated = DateTime::createFromFormat(GoogleCloudStorage::DATETIME_FORMAT, $info['timeCreated']); + foreach ($this->_bucket->objects(array('prefix' => $path)) as $object) { + $name = $object->name(); + if (strlen($name) > strlen($path) && substr($name, strlen($path), 1) !== '/') { + continue; } - if ($timeCreated && ($timeCreated->getTimestamp() < $time)) { - try { - $object->delete(); - } catch (NotFoundException $e) { - // deleted by another instance. - } - } else { - if (!$timeCreated) { - error_log('failed to parse create timestamp ' . $info['timeCreated'] . ' of object ' . $object->name()); + $info = $object->info(); + if (key_exists('metadata', $info) && key_exists('value', $info['metadata'])) { + $value = $info['metadata']['value']; + if (is_numeric($value) && intval($value) < $time) { + try { + $object->delete(); + } catch (NotFoundException $e) { + // deleted by another instance. + } } } } @@ -251,15 +249,24 @@ class GoogleCloudStorage extends AbstractData } /** - * This is the simplest thing that could possibly work. - * will be to tested for runtime performance. + * For GoogleCloudStorage, the value will also be stored in the metadata for the + * namespaces traffic_limiter and purge_limiter. * @inheritDoc */ public function setValue($value, $namespace, $key = '') { - $key = 'config/' . $namespace . '/' . $key; + if ($key === '') { + $key = 'config/' . $namespace; + } else { + $key = 'config/' . $namespace . '/' . $key; + } + $data = Json::encode($value); + $metadata = array('namespace' => $namespace); + if ($namespace != 'salt') { + $metadata['value'] = strval($value); + } try { $this->_bucket->upload($data, array( 'name' => $key, @@ -267,7 +274,7 @@ class GoogleCloudStorage extends AbstractData 'predefinedAcl' => 'private', 'metadata' => array( 'content-type' => 'application/json', - 'metadata' => array('namespace' => $namespace), + 'metadata' => $metadata, ), )); } catch (Exception $e) { @@ -279,13 +286,15 @@ class GoogleCloudStorage extends AbstractData } /** - * This is the simplest thing that could possibly work. - * will be to tested for runtime performance. * @inheritDoc */ public function getValue($namespace, $key = '') { - $key = 'config/' . $namespace . '/' . $key; + if ($key === '') { + $key = 'config/' . $namespace; + } else { + $key = 'config/' . $namespace . '/' . $key; + } try { $o = $this->_bucket->object($key); $data = $o->downloadAsString(); diff --git a/tst/Data/GoogleCloudStorageTest.php b/tst/Data/GoogleCloudStorageTest.php index 1c5190de..7945e2b1 100644 --- a/tst/Data/GoogleCloudStorageTest.php +++ b/tst/Data/GoogleCloudStorageTest.php @@ -141,8 +141,8 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase public function testKeyValueStore() { $salt = bin2hex(random_bytes(256)); - $this->_model->setValue($salt, 'salt', 'master'); - $storedSalt = $this->_model->getValue('salt', 'master'); + $this->_model->setValue($salt, 'salt', ''); + $storedSalt = $this->_model->getValue('salt', ''); $this->assertEquals($salt, $storedSalt); $this->_model->purgeValues('salt', time() + 60); $this->assertFalse($this->_model->getValue('salt', 'master')); @@ -159,12 +159,47 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase $this->assertFalse($this->_model->getValue('traffic_limiter', $client)); $purgeAt = $expire + (15 * 60); - $this->_model->setValue($purgeAt, 'purge_limiter', 'at'); - $storedPurgedAt = $this->_model->getValue('purge_limiter', 'at'); + $this->_model->setValue($purgeAt, 'purge_limiter', ''); + $storedPurgedAt = $this->_model->getValue('purge_limiter', ''); $this->assertEquals($purgeAt, $storedPurgedAt); $this->_model->purgeValues('purge_limiter', time() + 60); $this->assertFalse($this->_model->getValue('purge_limiter', 'at')); } + + /** + * @throws Exception + */ + public function testKeyValuePurgeTrafficLimiter() + { + $salt = bin2hex(random_bytes(256)); + $client = hash_hmac('sha512', '127.0.0.1', $salt); + $expire = time(); + $this->_model->setValue($expire, 'traffic_limiter', $client); + $storedExpired = $this->_model->getValue('traffic_limiter', $client); + $this->assertEquals($expire, $storedExpired); + + $this->_model->purgeValues('traffic_limiter', time() - 60); + $this->assertEquals($storedExpired, $this->_model->getValue('traffic_limiter', $client)); + + $this->_model->purgeValues('traffic_limiter', time() + 60); + $this->assertFalse($this->_model->getValue('traffic_limiter', $client)); + } + + public function testKeyValuePurgeTrafficLimiterWithKey() + { + $salt = bin2hex(random_bytes(256)); + $client = hash_hmac('sha512', '127.0.0.1', $salt); + $expire = time(); + $this->_model->setValue($expire, 'traffic_limiter', $client); + $storedExpired = $this->_model->getValue('traffic_limiter', $client); + $this->assertEquals($expire, $storedExpired); + + $this->_model->purgeValues('traffic_limiter', time() - 60); + $this->assertEquals($storedExpired, $this->_model->getValue('traffic_limiter', $client)); + + $this->_model->purgeValues('traffic_limiter', time() + 60); + $this->assertFalse($this->_model->getValue('traffic_limiter', $client)); + } } /** From e294145a2bdf52753ad0ca55d8091e8160068490 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 13 Jun 2021 08:26:05 +0200 Subject: [PATCH 183/223] ip-lib doesn't except on the matches interfaces --- lib/Persistence/TrafficLimiter.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 930272df..4f11ec7b 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -13,7 +13,6 @@ namespace PrivateBin\Persistence; -use Exception; use IPLib\Factory; use PrivateBin\Configuration; @@ -133,13 +132,7 @@ class TrafficLimiter extends AbstractPersistence return false; } - // Ip-lib throws an exception when something goes wrong, if so we want to catch it and set contained to false - try { - return $address->matches($range); - } catch (Exception $e) { - // If something is wrong with matching the ip, we assume it doesn't match - return false; - } + return $address->matches($range); } /** @@ -149,7 +142,6 @@ class TrafficLimiter extends AbstractPersistence * * @access public * @static - * @throws Exception * @return bool */ public static function canPass() From 93135e0abf92ebce8cafee5299769e1434f24bf2 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 13 Jun 2021 10:44:26 +0200 Subject: [PATCH 184/223] improving code coverage --- lib/Controller.php | 27 +- lib/Data/Database.php | 78 ++-- lib/Data/GoogleCloudStorage.php | 17 +- lib/FormatV2.php | 5 + lib/Persistence/PurgeLimiter.php | 1 - lib/Persistence/ServerSalt.php | 5 +- lib/Request.php | 13 +- tst/Bootstrap.php | 595 +++++++++++++++++++++++++++- tst/ControllerTest.php | 27 +- tst/ControllerWithGcsTest.php | 59 +++ tst/Data/DatabaseTest.php | 42 ++ tst/Data/FilesystemTest.php | 1 + tst/Data/GoogleCloudStorageTest.php | 585 +-------------------------- tst/ModelTest.php | 154 +++++++ 14 files changed, 949 insertions(+), 660 deletions(-) create mode 100644 tst/ControllerWithGcsTest.php diff --git a/lib/Controller.php b/lib/Controller.php index 4a1aa0d7..fb919ca1 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -195,22 +195,17 @@ class Controller */ private function _create() { - try { - // Ensure last paste from visitors IP address was more than configured amount of seconds ago. - ServerSalt::setStore($this->_model->getStore()); - TrafficLimiter::setConfiguration($this->_conf); - TrafficLimiter::setStore($this->_model->getStore()); - if (!TrafficLimiter::canPass()) { - $this->_return_message( - 1, I18n::_( - 'Please wait %d seconds between each post.', - $this->_conf->getKey('limit', 'traffic') - ) - ); - return; - } - } catch (Exception $e) { - $this->_return_message(1, I18n::_($e->getMessage())); + // Ensure last paste from visitors IP address was more than configured amount of seconds ago. + ServerSalt::setStore($this->_model->getStore()); + TrafficLimiter::setConfiguration($this->_conf); + TrafficLimiter::setStore($this->_model->getStore()); + if (!TrafficLimiter::canPass()) { + $this->_return_message( + 1, I18n::_( + 'Please wait %d seconds between each post.', + $this->_conf->getKey('limit', 'traffic') + ) + ); return; } diff --git a/lib/Data/Database.php b/lib/Data/Database.php index ae4da190..a15b8621 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -198,21 +198,25 @@ class Database extends AbstractData $opendiscussion = $paste['adata'][2]; $burnafterreading = $paste['adata'][3]; } - return self::_exec( - 'INSERT INTO ' . self::_sanitizeIdentifier('paste') . - ' VALUES(?,?,?,?,?,?,?,?,?)', - array( - $pasteid, - $isVersion1 ? $paste['data'] : Json::encode($paste), - $created, - $expire_date, - (int) $opendiscussion, - (int) $burnafterreading, - Json::encode($meta), - $attachment, - $attachmentname, - ) - ); + try { + return self::_exec( + 'INSERT INTO ' . self::_sanitizeIdentifier('paste') . + ' VALUES(?,?,?,?,?,?,?,?,?)', + array( + $pasteid, + $isVersion1 ? $paste['data'] : Json::encode($paste), + $created, + $expire_date, + (int) $opendiscussion, + (int) $burnafterreading, + Json::encode($meta), + $attachment, + $attachmentname, + ) + ); + } catch (Exception $e) { + return false; + } } /** @@ -348,19 +352,23 @@ class Database extends AbstractData $meta[$key] = null; } } - return self::_exec( - 'INSERT INTO ' . self::_sanitizeIdentifier('comment') . - ' VALUES(?,?,?,?,?,?,?)', - array( - $commentid, - $pasteid, - $parentid, - $data, - $meta['nickname'], - $meta[$iconKey], - $meta[$createdKey], - ) - ); + try { + return self::_exec( + 'INSERT INTO ' . self::_sanitizeIdentifier('comment') . + ' VALUES(?,?,?,?,?,?,?)', + array( + $commentid, + $pasteid, + $parentid, + $data, + $meta['nickname'], + $meta[$iconKey], + $meta[$createdKey], + ) + ); + } catch (Exception $e) { + return false; + } } /** @@ -416,11 +424,15 @@ class Database extends AbstractData */ public function existsComment($pasteid, $parentid, $commentid) { - return (bool) self::_select( - 'SELECT dataid FROM ' . self::_sanitizeIdentifier('comment') . - ' WHERE pasteid = ? AND parentid = ? AND dataid = ?', - array($pasteid, $parentid, $commentid), true - ); + try { + return (bool) self::_select( + 'SELECT dataid FROM ' . self::_sanitizeIdentifier('comment') . + ' WHERE pasteid = ? AND parentid = ? AND dataid = ?', + array($pasteid, $parentid, $commentid), true + ); + } catch (Exception $e) { + return false; + } } /** diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index 6bbea600..20667695 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -34,12 +34,9 @@ class GoogleCloudStorage extends AbstractData if (is_array($options) && array_key_exists('prefix', $options)) { $prefix = $options['prefix']; } - if (is_array($options) && array_key_exists('client', $options)) { - $client = $options['client']; - } if (!(self::$_instance instanceof self)) { - self::$_instance = new self($bucket, $prefix, $client); + self::$_instance = new self($bucket, $prefix); } return self::$_instance; } @@ -48,16 +45,12 @@ class GoogleCloudStorage extends AbstractData protected $_bucket = null; protected $_prefix = 'pastes'; - public function __construct($bucket, $prefix, $client = null) + public function __construct($bucket, $prefix) { parent::__construct(); - if ($client == null) { - $this->_client = new StorageClient(array('suppressKeyFileNotice' => true)); - } else { - // use given client for test purposes - $this->_client = $client; - } - + $this->_client = class_exists('StorageClientStub', false) ? + new \StorageClientStub(array()) : + new StorageClient(array('suppressKeyFileNotice' => true)); $this->_bucket = $this->_client->bucket($bucket); if ($prefix != null) { $this->_prefix = $prefix; diff --git a/lib/FormatV2.php b/lib/FormatV2.php index a06aa5d3..d2055f31 100644 --- a/lib/FormatV2.php +++ b/lib/FormatV2.php @@ -52,6 +52,11 @@ class FormatV2 } } + // Make sure adata is an array. + if (!is_array($message['adata'])) { + return false; + } + $cipherParams = $isComment ? $message['adata'] : $message['adata'][0]; // Make sure some fields are base64 data: diff --git a/lib/Persistence/PurgeLimiter.php b/lib/Persistence/PurgeLimiter.php index 6b608170..89d5d601 100644 --- a/lib/Persistence/PurgeLimiter.php +++ b/lib/Persistence/PurgeLimiter.php @@ -59,7 +59,6 @@ class PurgeLimiter extends AbstractPersistence * * @access public * @static - * @throws \Exception * @return bool */ public static function canPurge() diff --git a/lib/Persistence/ServerSalt.php b/lib/Persistence/ServerSalt.php index 93f5486e..14f7bd11 100644 --- a/lib/Persistence/ServerSalt.php +++ b/lib/Persistence/ServerSalt.php @@ -12,7 +12,6 @@ namespace PrivateBin\Persistence; -use Exception; use PrivateBin\Data\AbstractData; /** @@ -54,8 +53,7 @@ class ServerSalt extends AbstractPersistence */ public static function generate() { - $randomSalt = bin2hex(random_bytes(256)); - return $randomSalt; + return bin2hex(random_bytes(256)); } /** @@ -63,7 +61,6 @@ class ServerSalt extends AbstractPersistence * * @access public * @static - * @throws Exception * @return string */ public static function get() diff --git a/lib/Request.php b/lib/Request.php index 5776cabe..df517bb4 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -108,6 +108,8 @@ class Request case 'DELETE': case 'PUT': case 'POST': + // it might be a creation or a deletion, the latter is detected below + $this->_operation = 'create'; $this->_params = Json::decode( file_get_contents(self::$_inputStream) ); @@ -125,15 +127,10 @@ class Request } // prepare operation, depending on current parameters - if ( - array_key_exists('ct', $this->_params) && - !empty($this->_params['ct']) - ) { - $this->_operation = 'create'; - } elseif (array_key_exists('pasteid', $this->_params) && !empty($this->_params['pasteid'])) { + if (array_key_exists('pasteid', $this->_params) && !empty($this->_params['pasteid'])) { if (array_key_exists('deletetoken', $this->_params) && !empty($this->_params['deletetoken'])) { $this->_operation = 'delete'; - } else { + } else if ($this->_operation != 'create') { $this->_operation = 'read'; } } elseif (array_key_exists('jsonld', $this->_params) && !empty($this->_params['jsonld'])) { @@ -172,7 +169,7 @@ class Request $data['meta'] = $meta; } foreach ($required_keys as $key) { - $data[$key] = $this->getParam($key); + $data[$key] = $this->getParam($key, $key == 'v' ? 1 : ''); } // forcing a cast to int or float $data['v'] = $data['v'] + 0; diff --git a/tst/Bootstrap.php b/tst/Bootstrap.php index b5393510..bdf8a384 100644 --- a/tst/Bootstrap.php +++ b/tst/Bootstrap.php @@ -1,5 +1,14 @@ _config = $config; + $this->_connection = new ConnectionInterfaceStub(); + } + + public function bucket($name, $userProject = false) + { + if (!key_exists($name, $this->_buckets)) { + $b = new BucketStub($this->_connection, $name, array(), $this); + $this->_buckets[$name] = $b; + } + return $this->_buckets[$name]; + } + + /** + * @throws \Google\Cloud\Core\Exception\NotFoundException + */ + public function deleteBucket($name) + { + if (key_exists($name, $this->_buckets)) { + unset($this->_buckets[$name]); + } else { + throw new NotFoundException(); + } + } + + public function buckets(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function registerStreamWrapper($protocol = null) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function unregisterStreamWrapper($protocol = null) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function signedUrlUploader($uri, $data, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function timestamp(\DateTimeInterface $timestamp, $nanoSeconds = null) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getServiceAccount(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function hmacKeys(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function hmacKey($accessId, $projectId = null, array $metadata = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function createHmacKey($serviceAccountEmail, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function createBucket($name, array $options = array()) + { + if (key_exists($name, $this->_buckets)) { + throw new BadRequestException('already exists'); + } + $b = new BucketStub($this->_connection, $name, array(), $this); + $this->_buckets[$name] = $b; + return $b; + } +} + +/** + * Class BucketStub stubs a GCS bucket. + */ +class BucketStub extends Bucket +{ + public $_objects; + private $_name; + private $_info; + private $_connection; + private $_client; + + public function __construct(ConnectionInterface $connection, $name, array $info = array(), $client = null) + { + $this->_name = $name; + $this->_info = $info; + $this->_connection = $connection; + $this->_objects = array(); + $this->_client = $client; + } + + public function acl() + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function defaultAcl() + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function exists() + { + return true; + } + + public function upload($data, array $options = array()) + { + if (!is_string($data) || !key_exists('name', $options)) { + throw new BadMethodCallException('not supported by this stub'); + } + + $name = $options['name']; + $generation = '1'; + $o = new StorageObjectStub($this->_connection, $name, $this, $generation, $options); + $this->_objects[$options['name']] = $o; + $o->setData($data); + } + + public function uploadAsync($data, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getResumableUploader($data, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getStreamableUploader($data, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function object($name, array $options = array()) + { + if (key_exists($name, $this->_objects)) { + return $this->_objects[$name]; + } else { + return new StorageObjectStub($this->_connection, $name, $this, null, $options); + } + } + + public function objects(array $options = array()) + { + $prefix = key_exists('prefix', $options) ? $options['prefix'] : ''; + + return new CallbackFilterIterator( + new ArrayIterator($this->_objects), + function ($current, $key, $iterator) use ($prefix) { + return substr($key, 0, strlen($prefix)) == $prefix; + } + ); + } + + public function createNotification($topic, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function notification($id) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function notifications(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function delete(array $options = array()) + { + $this->_client->deleteBucket($this->_name); + } + + public function update(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function compose(array $sourceObjects, $name, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function info(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function reload(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function name() + { + return $this->_name; + } + + public static function lifecycle(array $lifecycle = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function currentLifecycle(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function isWritable($file = null) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function iam() + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function lockRetentionPolicy(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function signedUrl($expires, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function generateSignedPostPolicyV4($objectName, $expires, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } +} + +/** + * Class StorageObjectStub stubs a GCS storage object. + */ +class StorageObjectStub extends StorageObject +{ + private $_name; + private $_data; + private $_info; + private $_bucket; + private $_generation; + private $_exists = false; + private $_connection; + + public function __construct(ConnectionInterface $connection, $name, $bucket, $generation = null, array $info = array(), $encryptionKey = null, $encryptionKeySHA256 = null) + { + $this->_name = $name; + $this->_bucket = $bucket; + $this->_generation = $generation; + $this->_info = $info; + $this->_connection = $connection; + $timeCreated = new Datetime(); + $this->_info['metadata']['timeCreated'] = $timeCreated->format(GoogleCloudStorage::DATETIME_FORMAT); + } + + public function acl() + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function exists(array $options = array()) + { + return key_exists($this->_name, $this->_bucket->_objects); + } + + /** + * @throws NotFoundException + */ + public function delete(array $options = array()) + { + if (key_exists($this->_name, $this->_bucket->_objects)) { + unset($this->_bucket->_objects[$this->_name]); + } else { + throw new NotFoundException('key ' . $this->_name . ' not found.'); + } + } + + /** + * @throws NotFoundException + */ + public function update(array $metadata, array $options = array()) + { + if (!$this->_exists) { + throw new NotFoundException('key ' . $this->_name . ' not found.'); + } + $this->_info = $metadata; + } + + public function copy($destination, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function rewrite($destination, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function rename($name, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + /** + * @throws NotFoundException + */ + public function downloadAsString(array $options = array()) + { + if (!$this->_exists) { + throw new NotFoundException('key ' . $this->_name . ' not found.'); + } + return $this->_data; + } + + public function downloadToFile($path, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function downloadAsStream(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function downloadAsStreamAsync(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function signedUrl($expires, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function signedUploadUrl($expires, array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function beginSignedUploadSession(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function info(array $options = array()) + { + return key_exists('metadata',$this->_info) ? $this->_info['metadata'] : array(); + } + + public function reload(array $options = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function name() + { + return $this->_name; + } + + public function identity() + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function gcsUri() + { + return sprintf( + 'gs://%s/%s', + $this->_bucket->name(), + $this->_name + ); + } + + public function setData($data) + { + $this->_data = $data; + $this->_exists = true; + } +} + +/** + * Class ConnectionInterfaceStub required for the stubs. + */ +class ConnectionInterfaceStub implements ConnectionInterface +{ + public function deleteAcl(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getAcl(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function listAcl(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function insertAcl(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function patchAcl(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function deleteBucket(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getBucket(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function listBuckets(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function insertBucket(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getBucketIamPolicy(array $args) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function setBucketIamPolicy(array $args) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function testBucketIamPermissions(array $args) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function patchBucket(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function deleteObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function copyObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function rewriteObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function composeObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function listObjects(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function patchObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function downloadObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function insertObject(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getNotification(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function deleteNotification(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function insertNotification(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function listNotifications(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getServiceAccount(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function lockRetentionPolicy(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function createHmacKey(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function deleteHmacKey(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function getHmacKey(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function updateHmacKey(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } + + public function listHmacKeys(array $args = array()) + { + throw new BadMethodCallException('not supported by this stub'); + } +} + +/** + * Class Helper provides unit tests pastes and comments of various formats + */ class Helper { /** @@ -155,7 +744,11 @@ class Helper public static function getPastePost($version = 2, array $meta = array()) { $example = self::getPaste($version, $meta); - $example['meta'] = array('expire' => $example['meta']['expire']); + if ($version == 2) { + $example['meta'] = array('expire' => $example['meta']['expire']); + } else { + unset($example['meta']['postdate']); + } return $example; } diff --git a/tst/ControllerTest.php b/tst/ControllerTest.php index 0aa7d794..5c951273 100644 --- a/tst/ControllerTest.php +++ b/tst/ControllerTest.php @@ -48,6 +48,8 @@ class ControllerTest extends PHPUnit_Framework_TestCase */ public function testView() { + $_SERVER['QUERY_STRING'] = Helper::getPasteId(); + $_GET[Helper::getPasteId()] = ''; ob_start(); new Controller; $content = ob_get_contents(); @@ -470,6 +472,29 @@ class ControllerTest extends PHPUnit_Framework_TestCase $this->assertFalse($this->_data->exists(Helper::getPasteId()), 'paste exists after posting data'); } + /** + * @runInSeparateProcess + */ + public function testCreateInvalidFormat() + { + $options = parse_ini_file(CONF, true); + $options['traffic']['limit'] = 0; + Helper::createIniFile(CONF, $options); + $file = tempnam(sys_get_temp_dir(), 'FOO'); + file_put_contents($file, Helper::getPasteJson(1)); + Request::setInputStream($file); + $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; + $_SERVER['REQUEST_METHOD'] = 'POST'; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new Controller; + $content = ob_get_contents(); + ob_end_clean(); + $response = json_decode($content, true); + $this->assertEquals(1, $response['status'], 'outputs error status'); + $this->assertFalse($this->_data->exists(Helper::getPasteId()), 'paste exists after posting data'); + } + /** * @runInSeparateProcess */ @@ -518,7 +543,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase ob_end_clean(); $response = json_decode($content, true); $this->assertEquals(1, $response['status'], 'outputs error status'); - $this->assertFalse($this->_data->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'paste exists after posting data'); + $this->assertFalse($this->_data->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment exists after posting data'); } /** diff --git a/tst/ControllerWithGcsTest.php b/tst/ControllerWithGcsTest.php new file mode 100644 index 00000000..39833417 --- /dev/null +++ b/tst/ControllerWithGcsTest.php @@ -0,0 +1,59 @@ +false)); + $handler = HttpHandlerFactory::build($httpClient); + + $name = 'pb-'; + $alphabet = 'abcdefghijklmnopqrstuvwxyz'; + for ($i = 0; $i < 29; ++$i) { + $name .= $alphabet[rand(0, strlen($alphabet) - 1)]; + } + self::$_client = new StorageClientStub(array()); + self::$_bucket = self::$_client->createBucket($name); + } + + public function setUp() + { + /* Setup Routine */ + $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data'; + if (!is_dir($this->_path)) { + mkdir($this->_path); + } + $this->_options = array( + 'bucket' => self::$_bucket->name(), + 'prefix' => 'pastes', + ); + $this->_data = GoogleCloudStorage::getInstance($this->_options); + ServerSalt::setStore($this->_data); + TrafficLimiter::setStore($this->_data); + $this->reset(); + } + + public function reset() + { + parent::reset(); + // but then inject a db config + $options = parse_ini_file(CONF, true); + $options['model'] = array( + 'class' => 'GoogleCloudStorage', + ); + $options['model_options'] = $this->_options; + Helper::createIniFile(CONF, $options); + } +} diff --git a/tst/Data/DatabaseTest.php b/tst/Data/DatabaseTest.php index f9cd2652..1cfc0bea 100644 --- a/tst/Data/DatabaseTest.php +++ b/tst/Data/DatabaseTest.php @@ -302,6 +302,48 @@ class DatabaseTest extends PHPUnit_Framework_TestCase Helper::rmDir($this->_path); } + public function testCorruptMeta() + { + mkdir($this->_path); + $path = $this->_path . DIRECTORY_SEPARATOR . 'meta-test.sq3'; + if (is_file($path)) { + unlink($path); + } + $this->_options['dsn'] = 'sqlite:' . $path; + $this->_options['tbl'] = 'baz_'; + $model = Database::getInstance($this->_options); + $paste = Helper::getPaste(1, array('expire_date' => 1344803344)); + unset($paste['meta']['formatter'], $paste['meta']['opendiscussion'], $paste['meta']['salt']); + $model->delete(Helper::getPasteId()); + + $db = new PDO( + $this->_options['dsn'], + $this->_options['usr'], + $this->_options['pwd'], + $this->_options['opt'] + ); + $statement = $db->prepare('INSERT INTO baz_paste VALUES(?,?,?,?,?,?,?,?,?)'); + $statement->execute( + array( + Helper::getPasteId(), + $paste['data'], + $paste['meta']['postdate'], + $paste['meta']['expire_date'], + 0, + 0, + '{', + null, + null, + ) + ); + $statement->closeCursor(); + + $this->assertTrue($model->exists(Helper::getPasteId()), 'paste exists after storing it'); + $this->assertEquals($paste, $model->read(Helper::getPasteId())); + + Helper::rmDir($this->_path); + } + public function testTableUpgrade() { mkdir($this->_path); diff --git a/tst/Data/FilesystemTest.php b/tst/Data/FilesystemTest.php index 37e03f36..684c2940 100644 --- a/tst/Data/FilesystemTest.php +++ b/tst/Data/FilesystemTest.php @@ -117,6 +117,7 @@ class FilesystemTest extends PHPUnit_Framework_TestCase $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist'); $this->assertFalse($this->_model->create(Helper::getPasteId(), $paste), 'unable to store broken paste'); $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does still not exist'); + $this->assertFalse($this->_model->setValue('foo', 'non existing namespace'), 'rejects setting value in non existing namespace'); } public function testCommentErrorDetection() diff --git a/tst/Data/GoogleCloudStorageTest.php b/tst/Data/GoogleCloudStorageTest.php index 7945e2b1..557984ef 100644 --- a/tst/Data/GoogleCloudStorageTest.php +++ b/tst/Data/GoogleCloudStorageTest.php @@ -1,12 +1,6 @@ _model = GoogleCloudStorage::getInstance(array( 'bucket' => self::$_bucket->name(), 'prefix' => 'pastes', - 'client' => self::$_client, )); + )); } public function tearDown() @@ -201,580 +195,3 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase $this->assertFalse($this->_model->getValue('traffic_limiter', $client)); } } - -/** - * Class StorageClientStub provides a limited stub for performing the unit test - */ -class StorageClientStub extends StorageClient -{ - private $_config = null; - private $_connection = null; - private $_buckets = array(); - - public function __construct(array $config = array()) - { - $this->_config = $config; - $this->_connection = new ConnectionInterfaceStub(); - } - - public function bucket($name, $userProject = false) - { - if (!key_exists($name, $this->_buckets)) { - $b = new BucketStub($this->_connection, $name, array(), $this); - $this->_buckets[$name] = $b; - } - return $this->_buckets[$name]; - } - - /** - * @throws \Google\Cloud\Core\Exception\NotFoundException - */ - public function deleteBucket($name) - { - if (key_exists($name, $this->_buckets)) { - unset($this->_buckets[$name]); - } else { - throw new NotFoundException(); - } - } - - public function buckets(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function registerStreamWrapper($protocol = null) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function unregisterStreamWrapper($protocol = null) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function signedUrlUploader($uri, $data, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function timestamp(\DateTimeInterface $timestamp, $nanoSeconds = null) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function getServiceAccount(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function hmacKeys(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function hmacKey($accessId, $projectId = null, array $metadata = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function createHmacKey($serviceAccountEmail, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function createBucket($name, array $options = array()) - { - if (key_exists($name, $this->_buckets)) { - throw new BadRequestException('already exists'); - } - $b = new BucketStub($this->_connection, $name, array(), $this); - $this->_buckets[$name] = $b; - return $b; - } -} - -/** - * Class BucketStub stubs a GCS bucket. - */ -class BucketStub extends Bucket -{ - public $_objects; - private $_name; - private $_info; - private $_connection; - private $_client; - - public function __construct(ConnectionInterface $connection, $name, array $info = array(), $client = null) - { - $this->_name = $name; - $this->_info = $info; - $this->_connection = $connection; - $this->_objects = array(); - $this->_client = $client; - } - - public function acl() - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function defaultAcl() - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function exists() - { - return true; - } - - public function upload($data, array $options = array()) - { - if (!is_string($data) || !key_exists('name', $options)) { - throw new BadMethodCallException('not supported by this stub'); - } - - $name = $options['name']; - $generation = '1'; - $o = new StorageObjectStub($this->_connection, $name, $this, $generation, $options); - $this->_objects[$options['name']] = $o; - $o->setData($data); - } - - public function uploadAsync($data, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function getResumableUploader($data, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function getStreamableUploader($data, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function object($name, array $options = array()) - { - if (key_exists($name, $this->_objects)) { - return $this->_objects[$name]; - } else { - return new StorageObjectStub($this->_connection, $name, $this, null, $options); - } - } - - public function objects(array $options = array()) - { - $prefix = key_exists('prefix', $options) ? $options['prefix'] : ''; - - return new CallbackFilterIterator( - new ArrayIterator($this->_objects), - function ($current, $key, $iterator) use ($prefix) { - return substr($key, 0, strlen($prefix)) == $prefix; - } - ); - } - - public function createNotification($topic, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function notification($id) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function notifications(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function delete(array $options = array()) - { - $this->_client->deleteBucket($this->_name); - } - - public function update(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function compose(array $sourceObjects, $name, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function info(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function reload(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function name() - { - return $this->_name; - } - - public static function lifecycle(array $lifecycle = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function currentLifecycle(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function isWritable($file = null) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function iam() - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function lockRetentionPolicy(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function signedUrl($expires, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function generateSignedPostPolicyV4($objectName, $expires, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } -} - -/** - * Class StorageObjectStub stubs a GCS storage object. - */ -class StorageObjectStub extends StorageObject -{ - private $_name; - private $_data; - private $_info; - private $_bucket; - private $_generation; - private $_exists = false; - private $_connection; - - public function __construct(ConnectionInterface $connection, $name, $bucket, $generation = null, array $info = array(), $encryptionKey = null, $encryptionKeySHA256 = null) - { - $this->_name = $name; - $this->_bucket = $bucket; - $this->_generation = $generation; - $this->_info = $info; - $this->_connection = $connection; - $timeCreated = new Datetime(); - $this->_info['metadata']['timeCreated'] = $timeCreated->format(GoogleCloudStorage::DATETIME_FORMAT); - } - - public function acl() - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function exists(array $options = array()) - { - return key_exists($this->_name, $this->_bucket->_objects); - } - - /** - * @throws NotFoundException - */ - public function delete(array $options = array()) - { - if (key_exists($this->_name, $this->_bucket->_objects)) { - unset($this->_bucket->_objects[$this->_name]); - } else { - throw new NotFoundException('key ' . $this->_name . ' not found.'); - } - } - - /** - * @throws NotFoundException - */ - public function update(array $metadata, array $options = array()) - { - if (!$this->_exists) { - throw new NotFoundException('key ' . $this->_name . ' not found.'); - } - $this->_info = $metadata; - } - - public function copy($destination, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function rewrite($destination, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function rename($name, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - /** - * @throws NotFoundException - */ - public function downloadAsString(array $options = array()) - { - if (!$this->_exists) { - throw new NotFoundException('key ' . $this->_name . ' not found.'); - } - return $this->_data; - } - - public function downloadToFile($path, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function downloadAsStream(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function downloadAsStreamAsync(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function signedUrl($expires, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function signedUploadUrl($expires, array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function beginSignedUploadSession(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function info(array $options = array()) - { - return key_exists('metadata',$this->_info) ? $this->_info['metadata'] : array(); - } - - public function reload(array $options = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function name() - { - return $this->_name; - } - - public function identity() - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function gcsUri() - { - return sprintf( - 'gs://%s/%s', - $this->_bucket->name(), - $this->_name - ); - } - - public function setData($data) - { - $this->_data = $data; - $this->_exists = true; - } -} - -/** - * Class ConnectionInterfaceStub required for the stubs. - */ -class ConnectionInterfaceStub implements ConnectionInterface -{ - public function deleteAcl(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function getAcl(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function listAcl(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function insertAcl(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function patchAcl(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function deleteBucket(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function getBucket(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function listBuckets(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function insertBucket(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function getBucketIamPolicy(array $args) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function setBucketIamPolicy(array $args) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function testBucketIamPermissions(array $args) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function patchBucket(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function deleteObject(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function copyObject(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function rewriteObject(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function composeObject(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function getObject(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function listObjects(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function patchObject(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function downloadObject(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function insertObject(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function getNotification(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function deleteNotification(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function insertNotification(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function listNotifications(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function getServiceAccount(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function lockRetentionPolicy(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function createHmacKey(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function deleteHmacKey(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function getHmacKey(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function updateHmacKey(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } - - public function listHmacKeys(array $args = array()) - { - throw new BadMethodCallException('not supported by this stub'); - } -} diff --git a/tst/ModelTest.php b/tst/ModelTest.php index 478d4c10..fb82442e 100644 --- a/tst/ModelTest.php +++ b/tst/ModelTest.php @@ -102,6 +102,58 @@ class ModelTest extends PHPUnit_Framework_TestCase $this->assertEquals(array(), $paste->getComments(), 'comment was deleted with paste'); } + public function testPasteV1() + { + $pasteData = Helper::getPaste(1); + unset($pasteData['meta']['formatter']); + + $path = $this->_path . DIRECTORY_SEPARATOR . 'v1-test.sq3'; + if (is_file($path)) { + unlink($path); + } + $options = parse_ini_file(CONF_SAMPLE, true); + $options['purge']['limit'] = 0; + $options['model'] = array( + 'class' => 'Database', + ); + $options['model_options'] = array( + 'dsn' => 'sqlite:' . $path, + 'usr' => null, + 'pwd' => null, + 'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION), + ); + Helper::createIniFile(CONF, $options); + $model = new Model(new Configuration); + $model->getPaste('0000000000000000')->exists(); // triggers database table creation + $model->getPaste(Helper::getPasteId())->delete(); // deletes the cache + + $db = new PDO( + $options['model_options']['dsn'], + $options['model_options']['usr'], + $options['model_options']['pwd'], + $options['model_options']['opt'] + ); + $statement = $db->prepare('INSERT INTO paste VALUES(?,?,?,?,?,?,?,?,?)'); + $statement->execute( + array( + Helper::getPasteId(), + $pasteData['data'], + $pasteData['meta']['postdate'], + 0, + 0, + 0, + json_encode($pasteData['meta']), + null, + null, + ) + ); + $statement->closeCursor(); + + $paste = $model->getPaste(Helper::getPasteId()); + $paste->getDeleteToken(); + $this->assertEquals('plaintext', $paste->get()['meta']['formatter'], 'paste got created with default formatter'); + } + public function testCommentDefaults() { $comment = new Comment( @@ -133,6 +185,96 @@ class ModelTest extends PHPUnit_Framework_TestCase $paste->store(); } + /** + * @expectedException Exception + * @expectedExceptionCode 76 + */ + public function testStoreFail() + { + $path = $this->_path . DIRECTORY_SEPARATOR . 'model-store-test.sq3'; + if (is_file($path)) { + unlink($path); + } + $options = parse_ini_file(CONF_SAMPLE, true); + $options['purge']['limit'] = 0; + $options['model'] = array( + 'class' => 'Database', + ); + $options['model_options'] = array( + 'dsn' => 'sqlite:' . $path, + 'usr' => null, + 'pwd' => null, + 'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION), + ); + Helper::createIniFile(CONF, $options); + $model = new Model(new Configuration); + + $pasteData = Helper::getPastePost(); + $model->getPaste(Helper::getPasteId())->delete(); + $model->getPaste(Helper::getPasteId())->exists(); + + $db = new PDO( + $options['model_options']['dsn'], + $options['model_options']['usr'], + $options['model_options']['pwd'], + $options['model_options']['opt'] + ); + $statement = $db->prepare('DROP TABLE paste'); + $statement->execute(); + $statement->closeCursor(); + + $paste = $model->getPaste(); + $paste->setData($pasteData); + $paste->store(); + } + + /** + * @expectedException Exception + * @expectedExceptionCode 70 + */ + public function testCommentStoreFail() + { + $path = $this->_path . DIRECTORY_SEPARATOR . 'model-test.sq3'; + if (is_file($path)) { + unlink($path); + } + $options = parse_ini_file(CONF_SAMPLE, true); + $options['purge']['limit'] = 0; + $options['model'] = array( + 'class' => 'Database', + ); + $options['model_options'] = array( + 'dsn' => 'sqlite:' . $path, + 'usr' => null, + 'pwd' => null, + 'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION), + ); + Helper::createIniFile(CONF, $options); + $model = new Model(new Configuration); + + $pasteData = Helper::getPastePost(); + $commentData = Helper::getCommentPost(); + $model->getPaste(Helper::getPasteId())->delete(); + + $paste = $model->getPaste(); + $paste->setData($pasteData); + $paste->store(); + + $db = new PDO( + $options['model_options']['dsn'], + $options['model_options']['usr'], + $options['model_options']['pwd'], + $options['model_options']['opt'] + ); + $statement = $db->prepare('DROP TABLE comment'); + $statement->execute(); + $statement->closeCursor(); + + $comment = $paste->getComment(Helper::getPasteId()); + $comment->setData($commentData); + $comment->store(); + } + /** * @expectedException Exception * @expectedExceptionCode 69 @@ -195,6 +337,18 @@ class ModelTest extends PHPUnit_Framework_TestCase $paste->get(); } + /** + * @expectedException Exception + * @expectedExceptionCode 75 + */ + public function testInvalidPasteFormat() + { + $pasteData = Helper::getPastePost(); + $pasteData['adata'][1] = 'format does not exist'; + $paste = $this->_model->getPaste(); + $paste->setData($pasteData); + } + /** * @expectedException Exception * @expectedExceptionCode 60 From 1f2dddd9d85c3feb0dd4c210a41bc369252de3c1 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 13 Jun 2021 10:53:01 +0200 Subject: [PATCH 185/223] address Codacy issues --- lib/Data/AbstractData.php | 8 ++++---- lib/Data/Database.php | 12 ++++++------ lib/Data/Filesystem.php | 10 +++++----- lib/Persistence/ServerSalt.php | 9 --------- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/lib/Data/AbstractData.php b/lib/Data/AbstractData.php index 6f2dee53..52a85a41 100644 --- a/lib/Data/AbstractData.php +++ b/lib/Data/AbstractData.php @@ -35,7 +35,7 @@ abstract class AbstractData * @static * @var array */ - protected static $_traffic_limiter_cache = array(); + protected static $_last_cache = array(); /** * Enforce singleton, disable constructor @@ -150,9 +150,9 @@ abstract class AbstractData public function purgeValues($namespace, $time) { if ($namespace === 'traffic_limiter') { - foreach (self::$_traffic_limiter_cache as $key => $last_access) { - if ($last_access <= $time) { - unset(self::$_traffic_limiter_cache[$key]); + foreach (self::$_last_cache as $key => $last_submission) { + if ($last_submission <= $time) { + unset(self::$_last_cache[$key]); } } } diff --git a/lib/Data/Database.php b/lib/Data/Database.php index a15b8621..dea1be6d 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -447,9 +447,9 @@ class Database extends AbstractData public function setValue($value, $namespace, $key = '') { if ($namespace === 'traffic_limiter') { - self::$_traffic_limiter_cache[$key] = $value; + self::$_last_cache[$key] = $value; try { - $value = Json::encode(self::$_traffic_limiter_cache); + $value = Json::encode(self::$_last_cache); } catch (Exception $e) { return false; } @@ -492,12 +492,12 @@ class Database extends AbstractData } if ($value && $namespace === 'traffic_limiter') { try { - self::$_traffic_limiter_cache = Json::decode($value); + self::$_last_cache = Json::decode($value); } catch (Exception $e) { - self::$_traffic_limiter_cache = array(); + self::$_last_cache = array(); } - if (array_key_exists($key, self::$_traffic_limiter_cache)) { - return self::$_traffic_limiter_cache[$key]; + if (array_key_exists($key, self::$_last_cache)) { + return self::$_last_cache[$key]; } } return (string) $value; diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 384c72d1..9b8e7ba5 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -263,10 +263,10 @@ class Filesystem extends AbstractData ' Date: Sun, 13 Jun 2021 11:02:53 +0200 Subject: [PATCH 186/223] address Scrutinizer issues --- lib/Data/GoogleCloudStorage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index 20667695..d678db3b 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -224,7 +224,7 @@ class GoogleCloudStorage extends AbstractData if (strlen($name) > strlen($path) && substr($name, strlen($path), 1) !== '/') { continue; } - $info = $object->info(); + $info = $object->info(); if (key_exists('metadata', $info) && key_exists('value', $info['metadata'])) { $value = $info['metadata']['value']; if (is_numeric($value) && intval($value) < $time) { @@ -293,7 +293,7 @@ class GoogleCloudStorage extends AbstractData $data = $o->downloadAsString(); return Json::decode($data); } catch (NotFoundException $e) { - return false; + return ''; } } From bbcf57de0ef1d1ae9b4a9281f630b25712f3b129 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 13 Jun 2021 11:08:38 +0200 Subject: [PATCH 187/223] address Scrutinizer issues --- tst/Data/GoogleCloudStorageTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tst/Data/GoogleCloudStorageTest.php b/tst/Data/GoogleCloudStorageTest.php index 557984ef..24897434 100644 --- a/tst/Data/GoogleCloudStorageTest.php +++ b/tst/Data/GoogleCloudStorageTest.php @@ -139,7 +139,7 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase $storedSalt = $this->_model->getValue('salt', ''); $this->assertEquals($salt, $storedSalt); $this->_model->purgeValues('salt', time() + 60); - $this->assertFalse($this->_model->getValue('salt', 'master')); + $this->assertEquals('', $this->_model->getValue('salt', 'master')); $client = hash_hmac('sha512', '127.0.0.1', $salt); $expire = time(); @@ -150,14 +150,14 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase $this->_model->purgeValues('traffic_limiter', time() - 60); $this->assertEquals($storedExpired, $this->_model->getValue('traffic_limiter', $client)); $this->_model->purgeValues('traffic_limiter', time() + 60); - $this->assertFalse($this->_model->getValue('traffic_limiter', $client)); + $this->assertEquals('', $this->_model->getValue('traffic_limiter', $client)); $purgeAt = $expire + (15 * 60); $this->_model->setValue($purgeAt, 'purge_limiter', ''); $storedPurgedAt = $this->_model->getValue('purge_limiter', ''); $this->assertEquals($purgeAt, $storedPurgedAt); $this->_model->purgeValues('purge_limiter', time() + 60); - $this->assertFalse($this->_model->getValue('purge_limiter', 'at')); + $this->assertEquals('', $this->_model->getValue('purge_limiter', 'at')); } /** From fa4fe2852d09e39234bdf5618fb884a4c7160486 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 13 Jun 2021 11:12:19 +0200 Subject: [PATCH 188/223] address Scrutinizer issues --- tst/Data/GoogleCloudStorageTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tst/Data/GoogleCloudStorageTest.php b/tst/Data/GoogleCloudStorageTest.php index 24897434..827297ac 100644 --- a/tst/Data/GoogleCloudStorageTest.php +++ b/tst/Data/GoogleCloudStorageTest.php @@ -176,7 +176,7 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase $this->assertEquals($storedExpired, $this->_model->getValue('traffic_limiter', $client)); $this->_model->purgeValues('traffic_limiter', time() + 60); - $this->assertFalse($this->_model->getValue('traffic_limiter', $client)); + $this->assertEquals('', $this->_model->getValue('traffic_limiter', $client)); } public function testKeyValuePurgeTrafficLimiterWithKey() @@ -192,6 +192,6 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase $this->assertEquals($storedExpired, $this->_model->getValue('traffic_limiter', $client)); $this->_model->purgeValues('traffic_limiter', time() + 60); - $this->assertFalse($this->_model->getValue('traffic_limiter', $client)); + $this->assertEquals('', $this->_model->getValue('traffic_limiter', $client)); } } From 68b097087d8bb6af219967031447859019d8af56 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 13 Jun 2021 11:16:29 +0200 Subject: [PATCH 189/223] apply StyleCI recommendation --- lib/Request.php | 4 ++-- tst/Bootstrap.php | 2 -- tst/ModelTest.php | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/Request.php b/lib/Request.php index df517bb4..858f1313 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -110,7 +110,7 @@ class Request case 'POST': // it might be a creation or a deletion, the latter is detected below $this->_operation = 'create'; - $this->_params = Json::decode( + $this->_params = Json::decode( file_get_contents(self::$_inputStream) ); break; @@ -130,7 +130,7 @@ class Request if (array_key_exists('pasteid', $this->_params) && !empty($this->_params['pasteid'])) { if (array_key_exists('deletetoken', $this->_params) && !empty($this->_params['deletetoken'])) { $this->_operation = 'delete'; - } else if ($this->_operation != 'create') { + } elseif ($this->_operation != 'create') { $this->_operation = 'read'; } } elseif (array_key_exists('jsonld', $this->_params) && !empty($this->_params['jsonld'])) { diff --git a/tst/Bootstrap.php b/tst/Bootstrap.php index bdf8a384..97f9405d 100644 --- a/tst/Bootstrap.php +++ b/tst/Bootstrap.php @@ -1,13 +1,11 @@ _model->getPaste(); + $paste = $this->_model->getPaste(); $paste->setData($pasteData); } From 078c5785ddf09dfaac3c3c01e7848664685a69ee Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 13 Jun 2021 12:40:06 +0200 Subject: [PATCH 190/223] fix unit tests on php < 7.3 --- lib/Data/Database.php | 26 ++++++++++++++++---------- tst/ModelTest.php | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/Data/Database.php b/lib/Data/Database.php index dea1be6d..1d1327fd 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -233,11 +233,14 @@ class Database extends AbstractData } self::$_cache[$pasteid] = false; - $paste = self::_select( - 'SELECT * FROM ' . self::_sanitizeIdentifier('paste') . - ' WHERE dataid = ?', array($pasteid), true - ); - + try { + $paste = self::_select( + 'SELECT * FROM ' . self::_sanitizeIdentifier('paste') . + ' WHERE dataid = ?', array($pasteid), true + ); + } catch (Exception $e) { + $paste = false; + } if ($paste === false) { return false; } @@ -643,15 +646,18 @@ class Database extends AbstractData * @access private * @static * @param string $key - * @throws PDOException * @return string */ private static function _getConfig($key) { - $row = self::_select( - 'SELECT value FROM ' . self::_sanitizeIdentifier('config') . - ' WHERE id = ?', array($key), true - ); + try { + $row = self::_select( + 'SELECT value FROM ' . self::_sanitizeIdentifier('config') . + ' WHERE id = ?', array($key), true + ); + } catch (PDOException $e) { + return ''; + } return $row ? $row['value'] : ''; } diff --git a/tst/ModelTest.php b/tst/ModelTest.php index 327e7013..94321244 100644 --- a/tst/ModelTest.php +++ b/tst/ModelTest.php @@ -259,6 +259,7 @@ class ModelTest extends PHPUnit_Framework_TestCase $paste = $model->getPaste(); $paste->setData($pasteData); $paste->store(); + $paste->exists(); $db = new PDO( $options['model_options']['dsn'], From d0248d55d356914479e670c76342b9daaa535634 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 13 Jun 2021 12:43:18 +0200 Subject: [PATCH 191/223] address Scrutinizer issues --- lib/Data/GoogleCloudStorage.php | 2 +- lib/Json.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index d678db3b..c7dfcb96 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -291,7 +291,7 @@ class GoogleCloudStorage extends AbstractData try { $o = $this->_bucket->object($key); $data = $o->downloadAsString(); - return Json::decode($data); + return (string) Json::decode($data); } catch (NotFoundException $e) { return ''; } diff --git a/lib/Json.php b/lib/Json.php index b6567ed5..5f4efcf3 100644 --- a/lib/Json.php +++ b/lib/Json.php @@ -44,13 +44,13 @@ class Json * @static * @param string $input * @throws Exception - * @return array + * @return mixed */ public static function decode($input) { - $array = json_decode($input, true); + $output = json_decode($input, true); self::_detectError(); - return $array; + return $output; } /** From 9357f122b7c72bbf27ed0d018355b8d762decb97 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 13 Jun 2021 12:49:59 +0200 Subject: [PATCH 192/223] address Scrutinizer issues --- lib/Data/GoogleCloudStorage.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index c7dfcb96..3f5c8e2b 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -21,7 +21,6 @@ class GoogleCloudStorage extends AbstractData */ public static function getInstance(array $options) { - $client = null; $bucket = null; $prefix = 'pastes'; From b4c75b541ba37896896d0b01d2ecdf4bb4b036ca Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Sun, 13 Jun 2021 21:16:30 +0200 Subject: [PATCH 193/223] removed json encoding from get/setValue --- lib/Data/GoogleCloudStorage.php | 9 +++----- tst/Data/GoogleCloudStorageTest.php | 33 ++++++++--------------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index 3f5c8e2b..1c26a140 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -253,14 +253,12 @@ class GoogleCloudStorage extends AbstractData $key = 'config/' . $namespace . '/' . $key; } - $data = Json::encode($value); - $metadata = array('namespace' => $namespace); if ($namespace != 'salt') { $metadata['value'] = strval($value); } try { - $this->_bucket->upload($data, array( + $this->_bucket->upload($value, array( 'name' => $key, 'chunkSize' => 262144, 'predefinedAcl' => 'private', @@ -288,9 +286,8 @@ class GoogleCloudStorage extends AbstractData $key = 'config/' . $namespace . '/' . $key; } try { - $o = $this->_bucket->object($key); - $data = $o->downloadAsString(); - return (string) Json::decode($data); + $o = $this->_bucket->object($key); + return $o->downloadAsString(); } catch (NotFoundException $e) { return ''; } diff --git a/tst/Data/GoogleCloudStorageTest.php b/tst/Data/GoogleCloudStorageTest.php index 827297ac..3b101c40 100644 --- a/tst/Data/GoogleCloudStorageTest.php +++ b/tst/Data/GoogleCloudStorageTest.php @@ -143,20 +143,21 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase $client = hash_hmac('sha512', '127.0.0.1', $salt); $expire = time(); - $this->_model->setValue($expire, 'traffic_limiter', $client); + $this->_model->setValue(strval($expire), 'traffic_limiter', $client); $storedExpired = $this->_model->getValue('traffic_limiter', $client); - $this->assertEquals($expire, $storedExpired); - $this->assertEquals($expire, $storedExpired); + $this->assertEquals(strval($expire), $storedExpired); + $this->_model->purgeValues('traffic_limiter', time() - 60); $this->assertEquals($storedExpired, $this->_model->getValue('traffic_limiter', $client)); $this->_model->purgeValues('traffic_limiter', time() + 60); $this->assertEquals('', $this->_model->getValue('traffic_limiter', $client)); $purgeAt = $expire + (15 * 60); - $this->_model->setValue($purgeAt, 'purge_limiter', ''); + $this->_model->setValue(strval($purgeAt), 'purge_limiter', ''); $storedPurgedAt = $this->_model->getValue('purge_limiter', ''); - $this->assertEquals($purgeAt, $storedPurgedAt); - $this->_model->purgeValues('purge_limiter', time() + 60); + $this->assertEquals(strval($purgeAt), $storedPurgedAt); + $this->_model->purgeValues('purge_limiter', $purgeAt + 60); + $this->assertEquals('', $this->_model->getValue('purge_limiter', '')); $this->assertEquals('', $this->_model->getValue('purge_limiter', 'at')); } @@ -168,25 +169,9 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase $salt = bin2hex(random_bytes(256)); $client = hash_hmac('sha512', '127.0.0.1', $salt); $expire = time(); - $this->_model->setValue($expire, 'traffic_limiter', $client); + $this->_model->setValue(strval($expire), 'traffic_limiter', $client); $storedExpired = $this->_model->getValue('traffic_limiter', $client); - $this->assertEquals($expire, $storedExpired); - - $this->_model->purgeValues('traffic_limiter', time() - 60); - $this->assertEquals($storedExpired, $this->_model->getValue('traffic_limiter', $client)); - - $this->_model->purgeValues('traffic_limiter', time() + 60); - $this->assertEquals('', $this->_model->getValue('traffic_limiter', $client)); - } - - public function testKeyValuePurgeTrafficLimiterWithKey() - { - $salt = bin2hex(random_bytes(256)); - $client = hash_hmac('sha512', '127.0.0.1', $salt); - $expire = time(); - $this->_model->setValue($expire, 'traffic_limiter', $client); - $storedExpired = $this->_model->getValue('traffic_limiter', $client); - $this->assertEquals($expire, $storedExpired); + $this->assertEquals(strval($expire), $storedExpired); $this->_model->purgeValues('traffic_limiter', time() - 60); $this->assertEquals($storedExpired, $this->_model->getValue('traffic_limiter', $client)); From 3327645fd40bc0791b6111087b3e2b66399514ff Mon Sep 17 00:00:00 2001 From: El RIDO Date: Mon, 14 Jun 2021 06:44:30 +0200 Subject: [PATCH 194/223] updated doc blocks, comments, fixed indentations, moved some constant strings --- lib/Data/AbstractData.php | 6 +++--- lib/Data/Database.php | 2 +- lib/Data/Filesystem.php | 27 +++++++++++++++++++-------- lib/Data/GoogleCloudStorage.php | 2 -- tst/Bootstrap.php | 2 +- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/Data/AbstractData.php b/lib/Data/AbstractData.php index 52a85a41..591b91fd 100644 --- a/lib/Data/AbstractData.php +++ b/lib/Data/AbstractData.php @@ -15,7 +15,7 @@ namespace PrivateBin\Data; /** * AbstractData * - * Abstract model for PrivateBin data access, implemented as a singleton. + * Abstract model for data access, implemented as a singleton. */ abstract class AbstractData { @@ -40,7 +40,7 @@ abstract class AbstractData /** * Enforce singleton, disable constructor * - * Instantiate using {@link getInstance()}, privatebin is a singleton object. + * Instantiate using {@link getInstance()}, this object implements the singleton pattern. * * @access protected */ @@ -51,7 +51,7 @@ abstract class AbstractData /** * Enforce singleton, disable cloning * - * Instantiate using {@link getInstance()}, privatebin is a singleton object. + * Instantiate using {@link getInstance()}, this object implements the singleton pattern. * * @access private */ diff --git a/lib/Data/Database.php b/lib/Data/Database.php index 1d1327fd..0c66d330 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -234,7 +234,7 @@ class Database extends AbstractData self::$_cache[$pasteid] = false; try { - $paste = self::_select( + $paste = self::_select( 'SELECT * FROM ' . self::_sanitizeIdentifier('paste') . ' WHERE dataid = ?', array($pasteid), true ); diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 9b8e7ba5..25cca459 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -23,12 +23,19 @@ use PrivateBin\Json; class Filesystem extends AbstractData { /** - * first line in file, to protect its contents + * first line in paste or comment files, to protect their contents from browsing exposed data directories * * @const string */ const PROTECTION_LINE = '_info = $info; $this->_connection = $connection; $timeCreated = new Datetime(); - $this->_info['metadata']['timeCreated'] = $timeCreated->format(GoogleCloudStorage::DATETIME_FORMAT); + $this->_info['metadata']['timeCreated'] = $timeCreated->format('Y-m-d\TH:i:s.u\Z'); } public function acl() From af54e70359ae5994abc9f505e33cea6fdccf639c Mon Sep 17 00:00:00 2001 From: El RIDO Date: Mon, 14 Jun 2021 06:48:46 +0200 Subject: [PATCH 195/223] apply StyleCI recommendation --- tst/Bootstrap.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tst/Bootstrap.php b/tst/Bootstrap.php index 9d9f07cd..70aafddd 100644 --- a/tst/Bootstrap.php +++ b/tst/Bootstrap.php @@ -6,7 +6,6 @@ use Google\Cloud\Storage\Bucket; use Google\Cloud\Storage\Connection\ConnectionInterface; use Google\Cloud\Storage\StorageClient; use Google\Cloud\Storage\StorageObject; -use PrivateBin\Data\GoogleCloudStorage; use PrivateBin\Persistence\ServerSalt; error_reporting(E_ALL | E_STRICT); From ae1e4e3edbd583a472eb5ad683b7bab28ad596e0 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 16 Jun 2021 04:39:24 +0200 Subject: [PATCH 196/223] clarify use of getDeleteToken() method in unit test --- tst/ModelTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tst/ModelTest.php b/tst/ModelTest.php index 94321244..a88e0296 100644 --- a/tst/ModelTest.php +++ b/tst/ModelTest.php @@ -150,7 +150,7 @@ class ModelTest extends PHPUnit_Framework_TestCase $statement->closeCursor(); $paste = $model->getPaste(Helper::getPasteId()); - $paste->getDeleteToken(); + $this->assertNotEmpty($paste->getDeleteToken(), 'excercise the condition to load the data from storage'); $this->assertEquals('plaintext', $paste->get()['meta']['formatter'], 'paste got created with default formatter'); } From 3d9ba10fcb10d0222956110dd9f170a80fff1a7e Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 16 Jun 2021 05:19:45 +0200 Subject: [PATCH 197/223] more consistent AbstractData implementation --- lib/Data/GoogleCloudStorage.php | 112 +++++++++++++++++++------------- 1 file changed, 66 insertions(+), 46 deletions(-) diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index d6189e1e..cc4a4c68 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -9,6 +9,33 @@ use PrivateBin\Json; class GoogleCloudStorage extends AbstractData { + /** + * GCS client + * + * @access private + * @static + * @var StorageClient + */ + private static $_client = null; + + /** + * GCS bucket + * + * @access private + * @static + * @var Bucket + */ + private static $_bucket = null; + + /** + * object prefix + * + * @access private + * @static + * @var string + */ + private static $_prefix = 'pastes'; + /** * returns a Google Cloud Storage data backend. * @@ -19,9 +46,12 @@ class GoogleCloudStorage extends AbstractData */ public static function getInstance(array $options) { - $bucket = null; - $prefix = 'pastes'; + // if needed initialize the singleton + if (!(self::$_instance instanceof self)) { + self::$_instance = new self; + } + $bucket = null; if (getenv('PRIVATEBIN_GCS_BUCKET')) { $bucket = getenv('PRIVATEBIN_GCS_BUCKET'); } @@ -29,46 +59,36 @@ class GoogleCloudStorage extends AbstractData $bucket = $options['bucket']; } if (is_array($options) && array_key_exists('prefix', $options)) { - $prefix = $options['prefix']; + self::$_prefix = $options['prefix']; } - if (!(self::$_instance instanceof self)) { - self::$_instance = new self($bucket, $prefix); + if (empty(self::$_client)) { + self::$_client = class_exists('StorageClientStub', false) ? + new \StorageClientStub(array()) : + new StorageClient(array('suppressKeyFileNotice' => true)); } + self::$_bucket = self::$_client->bucket($bucket); + return self::$_instance; } - protected $_client = null; - protected $_bucket = null; - protected $_prefix = 'pastes'; - - public function __construct($bucket, $prefix) - { - parent::__construct(); - $this->_client = class_exists('StorageClientStub', false) ? - new \StorageClientStub(array()) : - new StorageClient(array('suppressKeyFileNotice' => true)); - $this->_bucket = $this->_client->bucket($bucket); - if ($prefix != null) { - $this->_prefix = $prefix; - } - } - /** - * returns the google storage object key for $pasteid in $this->_bucket. + * returns the google storage object key for $pasteid in self::$_bucket. + * + * @access private * @param $pasteid string to get the key for * @return string */ private function _getKey($pasteid) { - if ($this->_prefix != '') { - return $this->_prefix . '/' . $pasteid; + if (self::$_prefix != '') { + return self::$_prefix . '/' . $pasteid; } return $pasteid; } /** - * Uploads the payload in the $this->_bucket under the specified key. + * Uploads the payload in the self::$_bucket under the specified key. * The entire payload is stored as a JSON document. The metadata is replicated * as the GCS object's metadata except for the fields attachment, attachmentname * and salt. @@ -77,7 +97,7 @@ class GoogleCloudStorage extends AbstractData * @param $payload array to store * @return bool true if successful, otherwise false. */ - private function upload($key, $payload) + private function _upload($key, $payload) { $metadata = array_key_exists('meta', $payload) ? $payload['meta'] : array(); unset($metadata['attachment'], $metadata['attachmentname'], $metadata['salt']); @@ -85,7 +105,7 @@ class GoogleCloudStorage extends AbstractData $metadata[$k] = strval($v); } try { - $this->_bucket->upload(Json::encode($payload), array( + self::$_bucket->upload(Json::encode($payload), array( 'name' => $key, 'chunkSize' => 262144, 'predefinedAcl' => 'private', @@ -95,7 +115,7 @@ class GoogleCloudStorage extends AbstractData ), )); } catch (Exception $e) { - error_log('failed to upload ' . $key . ' to ' . $this->_bucket->name() . ', ' . + error_log('failed to upload ' . $key . ' to ' . self::$_bucket->name() . ', ' . trim(preg_replace('/\s\s+/', ' ', $e->getMessage()))); return false; } @@ -111,7 +131,7 @@ class GoogleCloudStorage extends AbstractData return false; } - return $this->upload($this->_getKey($pasteid), $paste); + return $this->_upload($this->_getKey($pasteid), $paste); } /** @@ -120,13 +140,13 @@ class GoogleCloudStorage extends AbstractData public function read($pasteid) { try { - $o = $this->_bucket->object($this->_getKey($pasteid)); + $o = self::$_bucket->object($this->_getKey($pasteid)); $data = $o->downloadAsString(); return Json::decode($data); } catch (NotFoundException $e) { return false; } catch (Exception $e) { - error_log('failed to read ' . $pasteid . ' from ' . $this->_bucket->name() . ', ' . + error_log('failed to read ' . $pasteid . ' from ' . self::$_bucket->name() . ', ' . trim(preg_replace('/\s\s+/', ' ', $e->getMessage()))); return false; } @@ -140,9 +160,9 @@ class GoogleCloudStorage extends AbstractData $name = $this->_getKey($pasteid); try { - foreach ($this->_bucket->objects(array('prefix' => $name . '/discussion/')) as $comment) { + foreach (self::$_bucket->objects(array('prefix' => $name . '/discussion/')) as $comment) { try { - $this->_bucket->object($comment->name())->delete(); + self::$_bucket->object($comment->name())->delete(); } catch (NotFoundException $e) { // ignore if already deleted. } @@ -152,7 +172,7 @@ class GoogleCloudStorage extends AbstractData } try { - $this->_bucket->object($name)->delete(); + self::$_bucket->object($name)->delete(); } catch (NotFoundException $e) { // ignore if already deleted } @@ -163,7 +183,7 @@ class GoogleCloudStorage extends AbstractData */ public function exists($pasteid) { - $o = $this->_bucket->object($this->_getKey($pasteid)); + $o = self::$_bucket->object($this->_getKey($pasteid)); return $o->exists(); } @@ -176,7 +196,7 @@ class GoogleCloudStorage extends AbstractData return false; } $key = $this->_getKey($pasteid) . '/discussion/' . $parentid . '/' . $commentid; - return $this->upload($key, $comment); + return $this->_upload($key, $comment); } /** @@ -187,8 +207,8 @@ class GoogleCloudStorage extends AbstractData $comments = array(); $prefix = $this->_getKey($pasteid) . '/discussion/'; try { - foreach ($this->_bucket->objects(array('prefix' => $prefix)) as $key) { - $comment = JSON::decode($this->_bucket->object($key->name())->downloadAsString()); + foreach (self::$_bucket->objects(array('prefix' => $prefix)) as $key) { + $comment = JSON::decode(self::$_bucket->object($key->name())->downloadAsString()); $comment['id'] = basename($key->name()); $slot = $this->getOpenSlot($comments, (int) $comment['meta']['created']); $comments[$slot] = $comment; @@ -205,7 +225,7 @@ class GoogleCloudStorage extends AbstractData public function existsComment($pasteid, $parentid, $commentid) { $name = $this->_getKey($pasteid) . '/discussion/' . $parentid . '/' . $commentid; - $o = $this->_bucket->object($name); + $o = self::$_bucket->object($name); return $o->exists(); } @@ -216,7 +236,7 @@ class GoogleCloudStorage extends AbstractData { $path = 'config/' . $namespace; try { - foreach ($this->_bucket->objects(array('prefix' => $path)) as $object) { + foreach (self::$_bucket->objects(array('prefix' => $path)) as $object) { $name = $object->name(); if (strlen($name) > strlen($path) && substr($name, strlen($path), 1) !== '/') { continue; @@ -256,7 +276,7 @@ class GoogleCloudStorage extends AbstractData $metadata['value'] = strval($value); } try { - $this->_bucket->upload($value, array( + self::$_bucket->upload($value, array( 'name' => $key, 'chunkSize' => 262144, 'predefinedAcl' => 'private', @@ -266,7 +286,7 @@ class GoogleCloudStorage extends AbstractData ), )); } catch (Exception $e) { - error_log('failed to set key ' . $key . ' to ' . $this->_bucket->name() . ', ' . + error_log('failed to set key ' . $key . ' to ' . self::$_bucket->name() . ', ' . trim(preg_replace('/\s\s+/', ' ', $e->getMessage()))); return false; } @@ -284,7 +304,7 @@ class GoogleCloudStorage extends AbstractData $key = 'config/' . $namespace . '/' . $key; } try { - $o = $this->_bucket->object($key); + $o = self::$_bucket->object($key); return $o->downloadAsString(); } catch (NotFoundException $e) { return ''; @@ -299,12 +319,12 @@ class GoogleCloudStorage extends AbstractData $expired = array(); $now = time(); - $prefix = $this->_prefix; + $prefix = self::$_prefix; if ($prefix != '') { - $prefix = $prefix . '/'; + $prefix .= '/'; } try { - foreach ($this->_bucket->objects(array('prefix' => $prefix)) as $object) { + foreach (self::$_bucket->objects(array('prefix' => $prefix)) as $object) { $metadata = $object->info()['metadata']; if ($metadata != null && array_key_exists('expire_date', $metadata)) { $expire_at = intval($metadata['expire_date']); From fd08d991fe073cce7aee254ebaf48c246c833225 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 16 Jun 2021 05:32:45 +0200 Subject: [PATCH 198/223] log errors storing persistance --- lib/Persistence/PurgeLimiter.php | 7 +++++-- lib/Persistence/ServerSalt.php | 4 +++- lib/Persistence/TrafficLimiter.php | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/Persistence/PurgeLimiter.php b/lib/Persistence/PurgeLimiter.php index 89d5d601..ef377703 100644 --- a/lib/Persistence/PurgeLimiter.php +++ b/lib/Persistence/PurgeLimiter.php @@ -73,7 +73,10 @@ class PurgeLimiter extends AbstractPersistence if ($pl + self::$_limit >= $now) { return false; } - self::$_store->setValue((string) $now, 'purge_limiter'); - return true; + $hasStored = self::$_store->setValue((string) $now, 'purge_limiter'); + if (!$hasStored) { + error_log('failed to store the purge limiter, skipping purge cycle to avoid getting stuck in a purge loop'); + } + return $hasStored; } } diff --git a/lib/Persistence/ServerSalt.php b/lib/Persistence/ServerSalt.php index 50e1cd65..1095498c 100644 --- a/lib/Persistence/ServerSalt.php +++ b/lib/Persistence/ServerSalt.php @@ -65,7 +65,9 @@ class ServerSalt extends AbstractPersistence self::$_salt = $salt; } else { self::$_salt = self::generate(); - self::$_store->setValue(self::$_salt, 'salt'); + if (!self::$_store->setValue(self::$_salt, 'salt')) { + error_log('failed to store the server salt, delete tokens, traffic limiter and user icons won\'t work'); + } } return self::$_salt; } diff --git a/lib/Persistence/TrafficLimiter.php b/lib/Persistence/TrafficLimiter.php index 4f11ec7b..9e896c1d 100644 --- a/lib/Persistence/TrafficLimiter.php +++ b/lib/Persistence/TrafficLimiter.php @@ -172,7 +172,9 @@ class TrafficLimiter extends AbstractPersistence $tl = time(); $result = true; } - self::$_store->setValue((string) $tl, 'traffic_limiter', $hash); + if (!self::$_store->setValue((string) $tl, 'traffic_limiter', $hash)) { + error_log('failed to store the traffic limiter, it probably contains outdated information'); + } return $result; } } From be164bb6a939e0293db4a869f6a3eb238fb6a1cb Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 16 Jun 2021 05:43:18 +0200 Subject: [PATCH 199/223] apply StyleCI recommendation --- lib/Data/GoogleCloudStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index cc4a4c68..9cd7f255 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -74,7 +74,7 @@ class GoogleCloudStorage extends AbstractData /** * returns the google storage object key for $pasteid in self::$_bucket. - * + * * @access private * @param $pasteid string to get the key for * @return string From 9c09018e6ed30d51b99b3647cae2905c1ab391da Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 16 Jun 2021 05:50:41 +0200 Subject: [PATCH 200/223] address Scrutinizer issues --- lib/Data/Filesystem.php | 9 +++++---- lib/Data/GoogleCloudStorage.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 25cca459..577ad34f 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -99,12 +99,13 @@ class Filesystem extends AbstractData */ public function read($pasteid) { - if (!$this->exists($pasteid)) { + if ( + !$this->exists($pasteid) || + !$paste = self::_get(self::_dataid2path($pasteid) . $pasteid . '.php') + ) { return false; } - return self::upgradePreV1Format( - self::_get(self::_dataid2path($pasteid) . $pasteid . '.php') - ); + return self::upgradePreV1Format($paste); } /** diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index 9cd7f255..f1102305 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -23,7 +23,7 @@ class GoogleCloudStorage extends AbstractData * * @access private * @static - * @var Bucket + * @var \Google\Cloud\Storage\Bucket */ private static $_bucket = null; From 1fd998f325d72ad0273c714ad39a441a41492730 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 16 Jun 2021 05:57:26 +0200 Subject: [PATCH 201/223] address Scrutinizer issues --- lib/Data/GoogleCloudStorage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php index f1102305..2e8e2c5d 100644 --- a/lib/Data/GoogleCloudStorage.php +++ b/lib/Data/GoogleCloudStorage.php @@ -4,6 +4,7 @@ namespace PrivateBin\Data; use Exception; use Google\Cloud\Core\Exception\NotFoundException; +use Google\Cloud\Storage\Bucket; use Google\Cloud\Storage\StorageClient; use PrivateBin\Json; @@ -23,7 +24,7 @@ class GoogleCloudStorage extends AbstractData * * @access private * @static - * @var \Google\Cloud\Storage\Bucket + * @var Bucket */ private static $_bucket = null; From 5f28acf62975e3b5bd5c83d33cd22dffacfcd03f Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Thu, 8 Jul 2021 22:59:50 +0200 Subject: [PATCH 202/223] New translations en.json (Lithuanian) --- i18n/lt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/lt.json b/i18n/lt.json index bc287bc5..10b62d84 100644 --- a/i18n/lt.json +++ b/i18n/lt.json @@ -185,5 +185,5 @@ "Encrypted note on PrivateBin": "Šifruoti užrašai ties PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Norėdami matyti užrašus, aplankykite šį tinklalapį. Pasidalinus šiuo URL adresu su kitais žmonėmis, jiems taip pat bus leidžiama prieiga prie šių užrašų.", "URL shortener may expose your decrypt key in URL.": "URL trumpinimo įrankis gali atskleisti URL adrese jūsų iššifravimo raktą.", - "Save paste": "Save paste" + "Save paste": "Įrašyti įdėjimą" } From ea663f7491f4610b96c73c4adab08555ec2e874a Mon Sep 17 00:00:00 2001 From: rugk Date: Thu, 5 Aug 2021 19:28:43 +0200 Subject: [PATCH 203/223] Clarify download instruction from GitHub releases Fixes https://github.com/PrivateBin/PrivateBin/issues/822 --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 70abf18e..0e728237 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,7 +1,7 @@ # Installation **TL;DR:** Download the -[latest release archive](https://github.com/PrivateBin/PrivateBin/releases/latest) +[latest release archive](https://github.com/PrivateBin/PrivateBin/releases/latest) (with the link labelled as „Source code (…)“) and extract it in your web hosts folder where you want to install your PrivateBin instance. We try to provide a mostly safe default configuration, but we urge you to check the [security section](#hardening-and-security) below and the [configuration From 18972ae0fad10afb206b6edb4a5434dea2b5bf4a Mon Sep 17 00:00:00 2001 From: El RIDO Date: Thu, 19 Aug 2021 10:18:08 +0200 Subject: [PATCH 204/223] luckily the PHP ini parser doesn't interpret this as an empty block, replacing the one defined above --- cfg/conf.sample.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php index d362f3f2..7194ee57 100644 --- a/cfg/conf.sample.php +++ b/cfg/conf.sample.php @@ -161,7 +161,7 @@ class = Filesystem [model_options] dir = PATH "data" -[model] +;[model] ; example of a Google Cloud Storage configuration ;class = GoogleCloudStorage ;[model_options] From eb10d4d35e7c19ee660e43238623403c8d6576e0 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Thu, 19 Aug 2021 10:21:21 +0200 Subject: [PATCH 205/223] be more flexible with configuration paths 1. only consider CONFIG_PATH environment variable, if non-empty 2. fall back to search in PATH (defined in index.php), if CONFIG_PATH doesn't contain a readable configuration file --- lib/Configuration.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/Configuration.php b/lib/Configuration.php index 7c4eb106..81138004 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -101,15 +101,20 @@ class Configuration */ public function __construct() { - $config = array(); - $basePath = (getenv('CONFIG_PATH') !== false ? getenv('CONFIG_PATH') : PATH . 'cfg') . DIRECTORY_SEPARATOR; - $configFile = $basePath . 'conf.php'; - - if (is_readable($configFile)) { - $config = parse_ini_file($configFile, true); - foreach (array('main', 'model', 'model_options') as $section) { - if (!array_key_exists($section, $config)) { - throw new Exception(I18n::_('PrivateBin requires configuration section [%s] to be present in configuration file.', $section), 2); + $config = $basePaths = array(); + $configPath = getenv('CONFIG_PATH'); + if ($configPath !== false && !empty($configPath)) { + $basePaths[] = $configPath; + } + $basePaths[] = PATH . 'cfg'; + foreach ($basePaths as $basePath) { + $configFile = $basePath . DIRECTORY_SEPARATOR . 'conf.php'; + if (is_readable($configFile)) { + $config = parse_ini_file($configFile, true); + foreach (array('main', 'model', 'model_options') as $section) { + if (!array_key_exists($section, $config)) { + throw new Exception(I18n::_('PrivateBin requires configuration section [%s] to be present in configuration file.', $section), 2); + } } } } From ff3b6689581ff61cd68c752f161279183aa63150 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Thu, 19 Aug 2021 11:04:31 +0200 Subject: [PATCH 206/223] apply StyleCI recommendation --- lib/Configuration.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Configuration.php b/lib/Configuration.php index 81138004..19c2a3b0 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -101,7 +101,7 @@ class Configuration */ public function __construct() { - $config = $basePaths = array(); + $config = $basePaths = array(); $configPath = getenv('CONFIG_PATH'); if ($configPath !== false && !empty($configPath)) { $basePaths[] = $configPath; @@ -116,6 +116,7 @@ class Configuration throw new Exception(I18n::_('PrivateBin requires configuration section [%s] to be present in configuration file.', $section), 2); } } + break; } } From df2f5931cd2e5a57819121c54777469b31b55d7f Mon Sep 17 00:00:00 2001 From: El RIDO Date: Thu, 19 Aug 2021 19:28:52 +0200 Subject: [PATCH 207/223] improve readability, kudos @rugk --- lib/Configuration.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Configuration.php b/lib/Configuration.php index 19c2a3b0..d8ef346b 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -101,7 +101,8 @@ class Configuration */ public function __construct() { - $config = $basePaths = array(); + $basePaths = array(); + $config = array(); $configPath = getenv('CONFIG_PATH'); if ($configPath !== false && !empty($configPath)) { $basePaths[] = $configPath; From 3c068cd6c3e01c9fb164755dacb39472cc388ff4 Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Fri, 3 Sep 2021 17:57:02 +0200 Subject: [PATCH 208/223] New translations en.json (Turkish) --- i18n/tr.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/i18n/tr.json b/i18n/tr.json index 5f3c6c0a..9e28cc69 100644 --- a/i18n/tr.json +++ b/i18n/tr.json @@ -26,14 +26,14 @@ "%s requires a modern browser to work.": "%s requires a modern browser to work.", "New": "Yeni", "Send": "Gönder", - "Clone": "Clone", + "Clone": "Kopyala", "Raw text": "Raw text", - "Expires": "Expires", + "Expires": "Süre Sonu", "Burn after reading": "Burn after reading", - "Open discussion": "Open discussion", + "Open discussion": "Açık Tartışmalar", "Password (recommended)": "Password (recommended)", - "Discussion": "Discussion", - "Toggle navigation": "Toggle navigation", + "Discussion": "Tartışma", + "Toggle navigation": "Gezinmeyi değiştir", "%d seconds": [ "%d second (singular)", "%d seconds (1st plural)", @@ -113,10 +113,10 @@ "Could not delete the paste, it was not stored in burn after reading mode.": "Could not delete the paste, it was not stored in burn after reading mode.", "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.": "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.", "Could not decrypt comment; Wrong key?": "Could not decrypt comment; Wrong key?", - "Reply": "Reply", - "Anonymous": "Anonymous", + "Reply": "Cevapla", + "Anonymous": "Anonim", "Avatar generated from IP address": "Avatar generated from IP address", - "Add comment": "Add comment", + "Add comment": "Yorum ekle", "Optional nickname…": "Optional nickname…", "Post comment": "Post comment", "Sending comment…": "Sending comment…", From c5c3a0e743253a2b9567561ae951471914328bbb Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Fri, 3 Sep 2021 18:58:00 +0200 Subject: [PATCH 209/223] New translations en.json (Turkish) --- i18n/tr.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/i18n/tr.json b/i18n/tr.json index 9e28cc69..0abbc37d 100644 --- a/i18n/tr.json +++ b/i18n/tr.json @@ -118,16 +118,16 @@ "Avatar generated from IP address": "Avatar generated from IP address", "Add comment": "Yorum ekle", "Optional nickname…": "Optional nickname…", - "Post comment": "Post comment", + "Post comment": "Yorumu gönder", "Sending comment…": "Sending comment…", - "Comment posted.": "Comment posted.", + "Comment posted.": "Yorum gönderildi.", "Could not refresh display: %s": "Could not refresh display: %s", "unknown status": "unknown status", "server error or not responding": "server error or not responding", "Could not post comment: %s": "Could not post comment: %s", "Sending paste…": "Sending paste…", "Your paste is %s (Hit [Ctrl]+[c] to copy)": "Your paste is %s (Hit [Ctrl]+[c] to copy)", - "Delete data": "Delete data", + "Delete data": "Veriyi sil", "Could not create paste: %s": "Could not create paste: %s", "Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)": "Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)", "B": "B", @@ -155,33 +155,33 @@ "Options": "Options", "Shorten URL": "Shorten URL", "Editor": "Editor", - "Preview": "Preview", + "Preview": "Ön izleme", "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.": "%s requires the PATH to end in a \"%s\". Please update the PATH in your index.php.", "Decrypt": "Decrypt", - "Enter password": "Enter password", - "Loading…": "Loading…", + "Enter password": "Şifreyi girin", + "Loading…": "Yükleniyor…", "Decrypting paste…": "Decrypting paste…", "Preparing new paste…": "Preparing new paste…", "In case this message never disappears please have a look at this FAQ for information to troubleshoot.": "In case this message never disappears please have a look at this FAQ for information to troubleshoot.", "+++ no paste text +++": "+++ no paste text +++", "Could not get paste data: %s": "Could not get paste data: %s", - "QR code": "QR code", + "QR code": "QR kodu", "This website is using an insecure HTTP connection! Please use it only for testing.": "This website is using an insecure HTTP connection! Please use it only for testing.", "For more information see this FAQ entry.": "For more information see this FAQ entry.", "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.": "Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.", "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.": "Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.", "waiting on user to provide a password": "waiting on user to provide a password", "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.": "Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.", - "Retry": "Retry", + "Retry": "Yeniden Dene", "Showing raw text…": "Showing raw text…", - "Notice:": "Notice:", + "Notice:": "Bildirim:", "This link will expire after %s.": "This link will expire after %s.", "This link can only be accessed once, do not use back or refresh button in your browser.": "This link can only be accessed once, do not use back or refresh button in your browser.", - "Link:": "Link:", + "Link:": "Bağlantı:", "Recipient may become aware of your timezone, convert time to UTC?": "Recipient may become aware of your timezone, convert time to UTC?", "Use Current Timezone": "Use Current Timezone", "Convert To UTC": "Convert To UTC", - "Close": "Close", + "Close": "Kapat", "Encrypted note on PrivateBin": "Encrypted note on PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.", "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", From def58480b3a9fb88625dfa7b2117bc69d363ab3e Mon Sep 17 00:00:00 2001 From: PrivateBin Translator Bot <72346835+privatebin-translator@users.noreply.github.com> Date: Mon, 27 Sep 2021 10:21:34 +0200 Subject: [PATCH 210/223] New translations en.json (Occitan) --- i18n/oc.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i18n/oc.json b/i18n/oc.json index a3106864..6a0a69ce 100644 --- a/i18n/oc.json +++ b/i18n/oc.json @@ -184,6 +184,6 @@ "Close": "Tampar", "Encrypted note on PrivateBin": "Nòtas chifradas sus PrivateBin", "Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.": "Visitatz aqueste ligam per veire la nòta. Fornir lo ligam a qualqu’un mai li permet tanben d’accedir a la nòta.", - "URL shortener may expose your decrypt key in URL.": "URL shortener may expose your decrypt key in URL.", - "Save paste": "Save paste" + "URL shortener may expose your decrypt key in URL.": "Los espleches d’acorchiment d’URL pòdon expausar la clau de deschiframent dins l’URL.", + "Save paste": "Enregistrar lo tèxt" } From 3ba6483bf3173ca018c0147b3fc79d0bb6045464 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:27:57 +0200 Subject: [PATCH 211/223] Try caching composer stuff Especially the GCM stuff may be quite large, so caching may be a good idea. I tried following https://github.com/shivammathur/setup-php#cache-composer-dependencies --- .github/workflows/tests.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 73fa11aa..85046240 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,17 +20,40 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} extensions: gd, sqlite3 + + # composer cache - name: Remove composer lock run: rm composer.lock + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + # http://man7.org/linux/man-pages/man1/date.1.html + # https://github.com/actions/cache#creating-a-cache-key + - name: Get Date + id: get-date + run: | + echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" + shell: bash + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + # composer - name: Setup PHPunit run: composer install -n - name: Install Google Cloud Storage run: composer require google/cloud-storage + + # testing - name: Run unit tests run: ../vendor/bin/phpunit --no-coverage working-directory: tst From a8f7840d2548f063b53d0990e37990c30cb1587e Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:29:48 +0200 Subject: [PATCH 212/223] Only restore cache from current date then --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 85046240..465003a1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,7 +45,7 @@ jobs: with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}- # composer - name: Setup PHPunit From 507a10adc58a4bb6f3696718af875c1ac83fe768 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:32:57 +0200 Subject: [PATCH 213/223] Use composer.json instead of composer.lock In a cache --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 465003a1..3c979bce 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,7 +44,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}- # composer From 3f7bceb86246d2825e5376fa06f96392f4e0256c Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:38:21 +0200 Subject: [PATCH 214/223] Also cache PHP extensions See https://github.com/shivammathur/cache-extensions#workflow --- .github/workflows/tests.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3c979bce..271cfc57 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,15 +17,33 @@ jobs: matrix: php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }} + env: + extensions: gd, sqlite3 steps: - name: Checkout uses: actions/checkout@v2 + # cache PHP extensions + - name: Setup cache environment + id: extcache + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.extensions }} + key: ${{ runner.os }}-phpextensions + + - name: Cache extensions + uses: actions/cache@v2 + with: + path: ${{ steps.extcache.outputs.dir }} + key: ${{ steps.extcache.outputs.key }} + restore-keys: ${{ env.extensions }} + - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - extensions: gd, sqlite3 + extensions: ${{ env.extensions }} # composer cache - name: Remove composer lock From e2ae0da4e1d310447c2847ea7cdde84e3109bc40 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:41:54 +0200 Subject: [PATCH 215/223] Style cleanup adding newlines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seems to be the unofficial GitHub Actions YAML style and arguably makes things a lot more readable if you have a lot of steps… --- .github/workflows/tests.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 271cfc57..5cf16eee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,6 +2,7 @@ name: Tests on: [push] jobs: + Composer: runs-on: ubuntu-latest steps: @@ -11,6 +12,7 @@ jobs: run: composer validate - name: Install dependencies run: composer install --prefer-dist --no-dev + PHPunit: runs-on: ubuntu-latest strategy: @@ -19,7 +21,10 @@ jobs: name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }} env: extensions: gd, sqlite3 + steps: + + # let's get started! - name: Checkout uses: actions/checkout@v2 @@ -48,9 +53,11 @@ jobs: # composer cache - name: Remove composer lock run: rm composer.lock + - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" + # http://man7.org/linux/man-pages/man1/date.1.html # https://github.com/actions/cache#creating-a-cache-key - name: Get Date @@ -58,6 +65,7 @@ jobs: run: | echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" shell: bash + - name: Cache dependencies uses: actions/cache@v2 with: @@ -75,20 +83,26 @@ jobs: - name: Run unit tests run: ../vendor/bin/phpunit --no-coverage working-directory: tst + Mocha: runs-on: ubuntu-latest steps: + - name: Checkout uses: actions/checkout@v2 + - name: Setup Node uses: actions/setup-node@v1 with: node-version: '12' + - name: Setup Mocha run: npm install -g mocha + - name: Setup Node modules run: npm install working-directory: js + - name: Run unit tests run: mocha working-directory: js From a372ee92e950a164e15f162af37ceccd09fe81a5 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:43:54 +0200 Subject: [PATCH 216/223] Fix wrong cache key --- .github/workflows/tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5cf16eee..a991262a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,6 +21,7 @@ jobs: name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }} env: extensions: gd, sqlite3 + extensions-cache-key: ${{ runner.os }}-phpextensions steps: @@ -35,14 +36,14 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: ${{ env.extensions }} - key: ${{ runner.os }}-phpextensions + key: ${{ env.extensions-cache-key }} - name: Cache extensions uses: actions/cache@v2 with: path: ${{ steps.extcache.outputs.dir }} key: ${{ steps.extcache.outputs.key }} - restore-keys: ${{ env.extensions }} + restore-keys: ${{ env.extensions-cache-key }} - name: Setup PHP uses: shivammathur/setup-php@v2 From b80732f8e20bc1e2fb824b5edcdb87efab16580e Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:55:08 +0200 Subject: [PATCH 217/223] Add caching for NodeJS --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a991262a..250aedb4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -93,9 +93,11 @@ jobs: uses: actions/checkout@v2 - name: Setup Node - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '12' + cache: 'npm' + cache-dependency-path: 'js/package-lock.json' - name: Setup Mocha run: npm install -g mocha From 5f4fe52eabad233631549b72022eedc00bfdce2c Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:56:44 +0200 Subject: [PATCH 218/223] Use package-json instead of package-lock.json for cache --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 250aedb4..37c89539 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -97,7 +97,7 @@ jobs: with: node-version: '12' cache: 'npm' - cache-dependency-path: 'js/package-lock.json' + cache-dependency-path: 'js/package.json' - name: Setup Mocha run: npm install -g mocha From ab11fbeb471b7662721970da0f17c72a18fe3eff Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 01:01:24 +0200 Subject: [PATCH 219/223] Fix syntax error Apparently in envs the OS etc. syntax is not supported, so we need to use it like this. --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 37c89539..8c3b1c0e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }} env: extensions: gd, sqlite3 - extensions-cache-key: ${{ runner.os }}-phpextensions + extensions-cache-key-name: phpextensions steps: @@ -36,14 +36,14 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: ${{ env.extensions }} - key: ${{ env.extensions-cache-key }} + key: ${{ runner.os }}-${{ env.extensions-cache-key }} - name: Cache extensions uses: actions/cache@v2 with: path: ${{ steps.extcache.outputs.dir }} key: ${{ steps.extcache.outputs.key }} - restore-keys: ${{ env.extensions-cache-key }} + restore-keys: ${{ runner.os }}-${{ env.extensions-cache-key }} - name: Setup PHP uses: shivammathur/setup-php@v2 From f43a41c11792fcdb7fd48937663da37a912c8945 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 01:07:57 +0200 Subject: [PATCH 220/223] Update tests.yml --- .github/workflows/tests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8c3b1c0e..0ef19464 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,6 +50,14 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: ${{ env.extensions }} + + # Setup GitHub CI PHP problem matchers + # https://github.com/shivammathur/setup-php#problem-matchers + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: Setup problem matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" # composer cache - name: Remove composer lock From f4e68fcc04a8f2567ab230f11645f85664e7e1f1 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 01:12:08 +0200 Subject: [PATCH 221/223] style: better YAML comments --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8c3b1c0e..c10595ea 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -74,9 +74,10 @@ jobs: key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}- - # composer + # composer installation - name: Setup PHPunit run: composer install -n + - name: Install Google Cloud Storage run: composer require google/cloud-storage From a988be7431dd176bdfacea5a5bcdde4489ed1ddb Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 6 Oct 2021 20:13:09 +0200 Subject: [PATCH 222/223] Add CI for automatic PHP8 updates Adds a simple CI for pushing the master branches changes to the php8 branch. Useful/discussed for https://github.com/PrivateBin/PrivateBin/issues/707 --- .github/workflows/refresh-php8.yml | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/refresh-php8.yml diff --git a/.github/workflows/refresh-php8.yml b/.github/workflows/refresh-php8.yml new file mode 100644 index 00000000..bf43df45 --- /dev/null +++ b/.github/workflows/refresh-php8.yml @@ -0,0 +1,40 @@ +# This is a basic workflow to help you get started with Actions + +name: Refresh PHP 8 branch + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ master ] + + schedule: + - cron: '42 2 * * *' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Checkout php8 branch + run: git checkout php8 + + - name: Merge master changes into php8 + run: git merge master + + - name: Push new changes + uses: github-actions-x/commit@v2.8 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + push-branch: 'php8' + From c7cd450f9b71eb7df1b4d70dd84be54b5bd83f2d Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 6 Oct 2021 20:19:03 +0200 Subject: [PATCH 223/223] Remove useless boilerplate comments --- .github/workflows/refresh-php8.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/refresh-php8.yml b/.github/workflows/refresh-php8.yml index bf43df45..5160e227 100644 --- a/.github/workflows/refresh-php8.yml +++ b/.github/workflows/refresh-php8.yml @@ -1,29 +1,17 @@ -# This is a basic workflow to help you get started with Actions - name: Refresh PHP 8 branch -# Controls when the workflow will run on: - # Triggers the workflow on push or pull request events but only for the master branch push: - branches: [ master ] - + branches: [ master ] schedule: - cron: '42 2 * * *' - - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" build: - # The type of runner that the job will run on runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Checkout php8 branch