소스 검색

Pass through non-strings in `escapeMarkup`

It is assumed that DOM elements or related objects will have been
escaped before they are passed back from templating functions. As
strings are typically blinding concatenated, like in our defaults,
it makes sense to escape the markup within them.

This is related to https://github.com/select2/select2/issues/3005.
Kevin Brown 10 년 전
부모
커밋
0f7a37b2d6
8개의 변경된 파일34개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      dist/js/select2.amd.full.js
  2. 5 0
      dist/js/select2.amd.js
  3. 5 0
      dist/js/select2.full.js
  4. 0 0
      dist/js/select2.full.min.js
  5. 5 0
      dist/js/select2.js
  6. 0 0
      dist/js/select2.min.js
  7. 5 0
      src/js/select2/utils.js
  8. 9 0
      tests/utils/escapeMarkup-tests.js

+ 5 - 0
dist/js/select2.amd.full.js

@@ -231,6 +231,11 @@ define(['jquery'], function ($) {define('select2/utils',[
       '/': '/'
     };
 
+    // Do not try to escape the markup if it's not a string
+    if (typeof markup !== 'string') {
+      return markup;
+    }
+
     return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
       return replaceMap[match];
     });

+ 5 - 0
dist/js/select2.amd.js

@@ -231,6 +231,11 @@ define(['jquery'], function ($) {define('select2/utils',[
       '/': '&#47;'
     };
 
+    // Do not try to escape the markup if it's not a string
+    if (typeof markup !== 'string') {
+      return markup;
+    }
+
     return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
       return replaceMap[match];
     });

+ 5 - 0
dist/js/select2.full.js

@@ -669,6 +669,11 @@ define('select2/utils',[
       '/': '&#47;'
     };
 
+    // Do not try to escape the markup if it's not a string
+    if (typeof markup !== 'string') {
+      return markup;
+    }
+
     return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
       return replaceMap[match];
     });

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/js/select2.full.min.js


+ 5 - 0
dist/js/select2.js

@@ -669,6 +669,11 @@ define('select2/utils',[
       '/': '&#47;'
     };
 
+    // Do not try to escape the markup if it's not a string
+    if (typeof markup !== 'string') {
+      return markup;
+    }
+
     return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
       return replaceMap[match];
     });

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/js/select2.min.js


+ 5 - 0
src/js/select2/utils.js

@@ -231,6 +231,11 @@ define([
       '/': '&#47;'
     };
 
+    // Do not try to escape the markup if it's not a string
+    if (typeof markup !== 'string') {
+      return markup;
+    }
+
     return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
       return replaceMap[match];
     });

+ 9 - 0
tests/utils/escapeMarkup-tests.js

@@ -25,3 +25,12 @@ test('quotes are killed as well', function (assert) {
   assert.equal(escaped.indexOf('\''), -1);
   assert.equal(escaped.indexOf('"'), -1);
 });
+
+test('DocumentFragment options pass through', function (assert) {
+  var frag = document.createDocumentFragment();
+  frag.innerHTML = '<strong>test</strong>';
+
+  var escaped = Utils.escapeMarkup(frag);
+
+  assert.equal(frag, escaped);
+});

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.