Просмотр исходного кода

avoid use of bleeding edge function

only supported in Firefox & Chrome >= 120 & node >= 19.9.0 & 18.17.0
El RIDO 2 лет назад
Родитель
Сommit
cc0b6e387a
4 измененных файлов с 7 добавлено и 10 удалено
  1. 5 1
      js/privatebin.js
  2. 0 7
      js/test/PasteStatus.js
  3. 1 1
      tpl/bootstrap.php
  4. 1 1
      tpl/page.php

+ 5 - 1
js/privatebin.js

@@ -2119,7 +2119,11 @@ jQuery.PrivateBin = (function($, RawDeflate) {
             if (typeof response === 'string' && response.length > 0) {
                 const shortUrlMatcher = /https?:\/\/[^\s]+/g;
                 const shortUrl = (response.match(shortUrlMatcher) || []).filter(function(a) {
-                    return URL.canParse(a);
+                    try {
+                        return !!new URL(a);
+                    } catch (error) {
+                        return false;
+                    }
                 }).sort(function(a, b) {
                     return a.length - b.length;
                 })[0];

+ 0 - 7
js/test/PasteStatus.js

@@ -56,13 +56,6 @@ describe('PasteStatus', function () {
                     ('#' + encodeURI(fragment)) : ''),
                     clean = jsdom();
 
-                // not available in node before v19.9.0, v18.17.0
-                if (typeof URL.canParse !== 'function') {
-                    URL.canParse = function(a) {
-                        return true;
-                    }
-                }
-
                 $('body').html('<div><div id="pastelink"></div></div>');
                 $.PrivateBin.PasteStatus.init();
                 $.PrivateBin.PasteStatus.createPasteNotification('', '');

+ 1 - 1
tpl/bootstrap.php

@@ -73,7 +73,7 @@ endif;
 ?>
 		<script type="text/javascript" data-cfasync="false" src="js/purify-3.0.6.js" integrity="sha512-N3y6/HOk3pbsw3lFh4O8CKKEVwu1B2CF8kinhjURf8Yqa5OfSUt+/arozxFW+TUPOPw3TsDCRT/0u7BGRTEVUw==" 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-ga7H5TIOKUp1pst8C7AxGjnnuTe96WETRcjkLVY3jRjYYIlyGo+dT/sf4/6gjhMUc6tT8WHLtI5xBijTSCe6+w==" crossorigin="anonymous"></script>
+		<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-ePzjzvXfIalrLQTWjuUNwbychokUjVUftwM0ozScap4mjS8wuM4SLLZwbPX3G70LB/hBQxGP2DTWFKFdwigsvQ==" 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" />

+ 1 - 1
tpl/page.php

@@ -51,7 +51,7 @@ endif;
 ?>
 		<script type="text/javascript" data-cfasync="false" src="js/purify-3.0.6.js" integrity="sha512-N3y6/HOk3pbsw3lFh4O8CKKEVwu1B2CF8kinhjURf8Yqa5OfSUt+/arozxFW+TUPOPw3TsDCRT/0u7BGRTEVUw==" 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-ga7H5TIOKUp1pst8C7AxGjnnuTe96WETRcjkLVY3jRjYYIlyGo+dT/sf4/6gjhMUc6tT8WHLtI5xBijTSCe6+w==" crossorigin="anonymous"></script>
+		<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-ePzjzvXfIalrLQTWjuUNwbychokUjVUftwM0ozScap4mjS8wuM4SLLZwbPX3G70LB/hBQxGP2DTWFKFdwigsvQ==" 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" />