forked from jquery/jquery-migrate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanipulation.js
25 lines (22 loc) · 986 Bytes
/
manipulation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { migratePatchFunc, migrateWarn } from "../main.js";
import "../disablePatches.js";
var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
makeMarkup = function( html ) {
var doc = window.document.implementation.createHTMLDocument( "" );
doc.body.innerHTML = html;
return doc.body && doc.body.innerHTML;
},
warnIfChanged = function( html ) {
var changed = html.replace( rxhtmlTag, "<$1></$2>" );
if ( changed !== html && makeMarkup( html ) !== makeMarkup( changed ) ) {
migrateWarn( "self-closed-tags",
"HTML tags must be properly nested and closed: " + html );
}
};
migratePatchFunc( jQuery, "htmlPrefilter", function( html ) {
warnIfChanged( html );
return html.replace( rxhtmlTag, "<$1></$2>" );
}, "self-closed-tags" );
// This patch needs to be disabled by default as it re-introduces
// security issues (CVE-2020-11022, CVE-2020-11023).
jQuery.migrateDisablePatches( "self-closed-tags" );