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
This commit is contained in:
El RIDO 2026-05-03 08:49:43 +02:00
parent 89e80d419d
commit 14c8b2fa25
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
2 changed files with 5 additions and 4 deletions

View file

@ -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,
'<a href="$1" rel="nofollow noopener noreferrer">$1</a>'
),
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');

View file

@ -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==',