vendor: 6,491 bytes, lines 1-225
1(function () { 2 3 window.wfi18n = { 4 __: function(text) { 5 if (window.WordfenceI18nStrings && text in window.WordfenceI18nStrings) { 6 return window.WordfenceI18nStrings[text]; 7 } 8 return text; 9 } 10 }; 11 12 if (typeof wp === 'object' && wp.i18n) { 13 window.wfi18n.sprintf = wp.i18n.sprintf; 14 return; 15 } 16 17 /** 18 * Code has been adapted from WordPress' i18n.js functions and is being used as a polyfill for WordPress 19 * versions before 5.0. 20 */ 21 var re = { 22 not_string: /[^s]/, 23 not_bool: /[^t]/, 24 not_type: /[^T]/, 25 not_primitive: /[^v]/, 26 number: /[diefg]/, 27 numeric_arg: /[bcdiefguxX]/, 28 json: /[j]/, 29 not_json: /[^j]/, 30 text: /^[^\x25]+/, 31 modulo: /^\x25{2}/, 32 placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/, 33 key: /^([a-z_][a-z_\d]*)/i, 34 key_access: /^\.([a-z_][a-z_\d]*)/i, 35 index_access: /^\[(\d+)\]/, 36 sign: /^[+-]/ 37 }; 38 39 function sprintf(key) { 40 // `arguments` is not an array, but should be fine for this call 41 return sprintf_format(sprintf_parse(key), arguments) 42 } 43 44 function vsprintf(fmt, argv) { 45 return sprintf.apply(null, [fmt].concat(argv || [])) 46 } 47 48 function sprintf_format(parse_tree, argv) { 49 var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign 50 for (i = 0; i < tree_length; i++) { 51 if (typeof parse_tree[i] === 'string') { 52 output += parse_tree[i] 53 } 54 else if (typeof parse_tree[i] === 'object') { 55 ph = parse_tree[i] // convenience purposes only 56 if (ph.keys) { // keyword argument 57 arg = argv[cursor] 58 for (k = 0; k < ph.keys.length; k++) { 59 if (arg == undefined) { 60 throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k-1])) 61 } 62 arg = arg[ph.keys[k]] 63 } 64 } 65 else if (ph.param_no) { // positional argument (explicit) 66 arg = argv[ph.param_no] 67 } 68 else { // positional argument (implicit) 69 arg = argv[cursor++] 70 } 71 72 if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) { 73 arg = arg() 74 } 75 76 if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) { 77 throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg)) 78 } 79 80 if (re.number.test(ph.type)) { 81 is_positive = arg >= 0 82 } 83 84 switch (ph.type) { 85 case 'b': 86 arg = parseInt(arg, 10).toString(2) 87 break 88 case 'c': 89 arg = String.fromCharCode(parseInt(arg, 10)) 90 break 91 case 'd': 92 case 'i': 93 arg = parseInt(arg, 10) 94 break 95 case 'j': 96 arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0) 97 break 98 case 'e': 99 arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential() 100 break 101 case 'f': 102 arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg) 103 break 104 case 'g': 105 arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg) 106 break 107 case 'o': 108 arg = (parseInt(arg, 10) >>> 0).toString(8) 109 break 110 case 's': 111 arg = String(arg) 112 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 113 break 114 case 't': 115 arg = String(!!arg) 116 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 117 break 118 case 'T': 119 arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase() 120 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 121 break 122 case 'u': 123 arg = parseInt(arg, 10) >>> 0 124 break 125 case 'v': 126 arg = arg.valueOf() 127 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 128 break 129 case 'x': 130 arg = (parseInt(arg, 10) >>> 0).toString(16) 131 break 132 case 'X': 133 arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase() 134 break 135 } 136 if (re.json.test(ph.type)) { 137 output += arg 138 } 139 else { 140 if (re.number.test(ph.type) && (!is_positive || ph.sign)) { 141 sign = is_positive ? '+' : '-' 142 arg = arg.toString().replace(re.sign, '') 143 } 144 else { 145 sign = '' 146 } 147 pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' ' 148 pad_length = ph.width - (sign + arg).length 149 pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : '' 150 output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg) 151 } 152 } 153 } 154 return output 155 } 156 157 var sprintf_cache = Object.create(null) 158 159 function sprintf_parse(fmt) { 160 if (sprintf_cache[fmt]) { 161 return sprintf_cache[fmt] 162 } 163 164 var _fmt = fmt, match, parse_tree = [], arg_names = 0 165 while (_fmt) { 166 if ((match = re.text.exec(_fmt)) !== null) { 167 parse_tree.push(match[0]) 168 } 169 else if ((match = re.modulo.exec(_fmt)) !== null) { 170 parse_tree.push('%') 171 } 172 else if ((match = re.placeholder.exec(_fmt)) !== null) { 173 if (match[2]) { 174 arg_names |= 1 175 var field_list = [], replacement_field = match[2], field_match = [] 176 if ((field_match = re.key.exec(replacement_field)) !== null) { 177 field_list.push(field_match[1]) 178 while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { 179 if ((field_match = re.key_access.exec(replacement_field)) !== null) { 180 field_list.push(field_match[1]) 181 } 182 else if ((field_match = re.index_access.exec(replacement_field)) !== null) { 183 field_list.push(field_match[1]) 184 } 185 else { 186 throw new SyntaxError('[sprintf] failed to parse named argument key') 187 } 188 } 189 } 190 else { 191 throw new SyntaxError('[sprintf] failed to parse named argument key') 192 } 193 match[2] = field_list 194 } 195 else { 196 arg_names |= 2 197 } 198 if (arg_names === 3) { 199 throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported') 200 } 201 202 parse_tree.push( 203 { 204 placeholder: match[0], 205 param_no: match[1], 206 keys: match[2], 207 sign: match[3], 208 pad_char: match[4], 209 align: match[5], 210 width: match[6], 211 precision: match[7], 212 type: match[8] 213 } 214 ) 215 } 216 else { 217 throw new SyntaxError('[sprintf] unexpected placeholder') 218 } 219 _fmt = _fmt.substring(match[0].length) 220 } 221 return sprintf_cache[fmt] = parse_tree 222 } 223 224 window.wfi18n.sprintf = sprintf; 225})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.