From 14c8b2fa252602744b7eacbfa5175ff359149be5 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 3 May 2026 08:49:43 +0200 Subject: [PATCH] fix syntaxhighlighting format, requires non-strict DOMpurify the strict settings removed the pre-tags, lists, etc. that are used by the prettify library to format source code --- js/privatebin.js | 7 ++++--- lib/Configuration.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index e9b0c33c..5d2047eb 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -444,8 +444,9 @@ jQuery.PrivateBin = (function($) { * @name Helper.urls2links * @function * @param {HTMLElement} element + * @param {bool} strict - optional */ - me.urls2links = function(element) + me.urls2links = function(element, strict = true) { element.html( DOMPurify.sanitize( @@ -453,7 +454,7 @@ jQuery.PrivateBin = (function($) { /(((https?|ftp):\/\/[\w?!=&.\/-;#@~%+*-]+(?![\w\s?!&.\/;#~%"=-]>))|((magnet):[\w?=&.\/-;#@~%+*-]+))/ig, '$1' ), - purifyHtmlConfigStrictSubset + strict ? purifyHtmlConfigStrictSubset : purifyHtmlConfig ) ); }; @@ -2743,7 +2744,7 @@ jQuery.PrivateBin = (function($) { // = 'plaintext' $prettyPrint.text(text); } - Helper.urls2links($prettyPrint); + Helper.urls2links($prettyPrint, format !== 'syntaxhighlighting'); $prettyPrint.css('white-space', 'pre-wrap'); $prettyPrint.css('word-break', 'normal'); $prettyPrint.removeClass('prettyprint'); diff --git a/lib/Configuration.php b/lib/Configuration.php index 27f5506b..d15829a7 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -122,7 +122,7 @@ class Configuration 'js/kjua-0.10.0.js' => 'sha512-BYj4xggowR7QD150VLSTRlzH62YPfhpIM+b/1EUEr7RQpdWAGKulxWnOvjFx1FUlba4m6ihpNYuQab51H6XlYg==', 'js/legacy.js' => 'sha512-RQEo1hxpNc37i+jz/D9/JiAZhG8GFx3+SNxjYnI7jUgirDIqrCSj6QPAAZeaidditcWzsJ3jxfEj5lVm7ZwTRQ==', 'js/prettify.js' => 'sha512-puO0Ogy++IoA2Pb9IjSxV1n4+kQkKXYAEUtVzfZpQepyDPyXk8hokiYDS7ybMogYlyyEIwMLpZqVhCkARQWLMg==', - 'js/privatebin.js' => 'sha512-p9zI8Ybt1CGqZ6NIHCQlxLg0nED6FpemmcSCZsUBsS4JXRWlV8lYv9NrdvS0Gxad0DPRNjOwvsN+n7o2E9BmAg==', + 'js/privatebin.js' => 'sha512-kRRgq+R3dUScoqqjTQo+re+T+FrsaukqMO7qSMen2fq0Rcgz2S0GnR52sqKukbDDKRr/dDba01WWPccduYr+Jg==', 'js/purify-3.4.1.js' => 'sha512-280a/Vb6fVFsYaeRrkuDp4EDmdYlt2XS+dlDEO/U9qljPrAraA2bIzHTNmP+9dpwPDDwTML+RS+h5iaagPwTzA==', 'js/showdown-2.1.0.js' => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==', 'js/zlib-1.3.2.js' => 'sha512-RAhJgxg9siMIA8ky4c10Rc2zUgnK80olHB8Tt1IOYWY4Eh1WmrviQkDn+sgBlb38ZHq3tzufGC41kP360gmosQ==',