MCPcopy
hub / github.com/cure53/DOMPurify / unicodeEscape

Function unicodeEscape

demos/lib/Mental.js:6991–7031  ·  view source on GitHub ↗
(first)

Source from the content-addressed store, hash-verified

6989 }
6990
6991 function unicodeEscape(first) {
6992 pos++;
6993 var chr1 = code.charCodeAt(pos), chr2 = code.charAt(pos + 1), chr3 = code.charAt(pos + 2), chr4 = code.charAt(pos + 3), chr5 = code.charAt(pos + 4), hex;
6994 if (chr1 !== 0x75) {
6995 error("Invalid unicode escape. Expected u.");
6996 }
6997 hex = +('0x' + chr2 + chr3 + chr4 + chr5);
6998 if ((hex === hex && hex !== hex) || /[^a-f0-9]/i.test(''+chr2+chr3+chr4+chr5)) {
6999 error("Invalid unicode escape. Expected valid hex sequence.");
7000 }
7001 if (first) {
7002 if (hex > 0x60 && hex < 0x7b) {
7003 } else if (hex > 0x40 && hex < 0x5b) {
7004 } else if (hex === 0x5f || hex === 0x24) {
7005 } else if (!isValidVariable(hex)) {
7006 error('illegal unicode escape');
7007 }
7008 } else {
7009 if (hex > 0x60 && hex < 0x7b) {
7010 } else if (hex > 0x2f && hex < 0x3a) {
7011 } else if (hex > 0x40 && hex < 0x5b) {
7012 } else if (hex === 0x5f || hex === 0x24) {
7013 } else if (!isValidVariablePart(hex)) {
7014 error('illegal unicode escape');
7015 }
7016 }
7017 pos += 5;
7018 if (first) {
7019 if (pos < len) {
7020 outputLine += '\\u' + chr2 + chr3 + chr4 + chr5;
7021 nonKeyword();
7022 return false;
7023 } else {
7024 outputLine += '\\u' + chr2 + chr3 + chr4 + chr5 + '$';
7025 identifierStates();
7026 identifierAsi();
7027 }
7028 } else {
7029 outputLine += '\\u' + chr2 + chr3 + chr4 + chr5;
7030 }
7031 }
7032
7033 function keyword(iLen) {
7034 state = -1;

Callers 3

identifierFunction · 0.85
nonKeywordFunction · 0.85
rewriteFunction · 0.85

Calls 6

errorFunction · 0.85
isValidVariableFunction · 0.85
isValidVariablePartFunction · 0.85
nonKeywordFunction · 0.85
identifierStatesFunction · 0.85
identifierAsiFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…