Ignore:
Timestamp:
11/25/21 22:08:24 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
8d391a1
Parents:
59329aa
Message:

primeNG components

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/node_modules/ws/lib/validation.js

    r59329aa re29cc2e  
    11'use strict';
     2
     3try {
     4  const isValidUTF8 = require('utf-8-validate');
     5
     6  exports.isValidUTF8 =
     7    typeof isValidUTF8 === 'object'
     8      ? isValidUTF8.Validation.isValidUTF8 // utf-8-validate@<3.0.0
     9      : isValidUTF8;
     10} catch (e) /* istanbul ignore next */ {
     11  exports.isValidUTF8 = () => true;
     12}
    213
    314/**
     
    819 * @public
    920 */
    10 function isValidStatusCode(code) {
     21exports.isValidStatusCode = (code) => {
    1122  return (
    1223    (code >= 1000 &&
    13       code <= 1014 &&
     24      code <= 1013 &&
    1425      code !== 1004 &&
    1526      code !== 1005 &&
     
    1728    (code >= 3000 && code <= 4999)
    1829  );
    19 }
    20 
    21 /**
    22  * Checks if a given buffer contains only correct UTF-8.
    23  * Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by
    24  * Markus Kuhn.
    25  *
    26  * @param {Buffer} buf The buffer to check
    27  * @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false`
    28  * @public
    29  */
    30 function _isValidUTF8(buf) {
    31   const len = buf.length;
    32   let i = 0;
    33 
    34   while (i < len) {
    35     if ((buf[i] & 0x80) === 0) {
    36       // 0xxxxxxx
    37       i++;
    38     } else if ((buf[i] & 0xe0) === 0xc0) {
    39       // 110xxxxx 10xxxxxx
    40       if (
    41         i + 1 === len ||
    42         (buf[i + 1] & 0xc0) !== 0x80 ||
    43         (buf[i] & 0xfe) === 0xc0 // Overlong
    44       ) {
    45         return false;
    46       }
    47 
    48       i += 2;
    49     } else if ((buf[i] & 0xf0) === 0xe0) {
    50       // 1110xxxx 10xxxxxx 10xxxxxx
    51       if (
    52         i + 2 >= len ||
    53         (buf[i + 1] & 0xc0) !== 0x80 ||
    54         (buf[i + 2] & 0xc0) !== 0x80 ||
    55         (buf[i] === 0xe0 && (buf[i + 1] & 0xe0) === 0x80) || // Overlong
    56         (buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0) // Surrogate (U+D800 - U+DFFF)
    57       ) {
    58         return false;
    59       }
    60 
    61       i += 3;
    62     } else if ((buf[i] & 0xf8) === 0xf0) {
    63       // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    64       if (
    65         i + 3 >= len ||
    66         (buf[i + 1] & 0xc0) !== 0x80 ||
    67         (buf[i + 2] & 0xc0) !== 0x80 ||
    68         (buf[i + 3] & 0xc0) !== 0x80 ||
    69         (buf[i] === 0xf0 && (buf[i + 1] & 0xf0) === 0x80) || // Overlong
    70         (buf[i] === 0xf4 && buf[i + 1] > 0x8f) ||
    71         buf[i] > 0xf4 // > U+10FFFF
    72       ) {
    73         return false;
    74       }
    75 
    76       i += 4;
    77     } else {
    78       return false;
    79     }
    80   }
    81 
    82   return true;
    83 }
    84 
    85 try {
    86   let isValidUTF8 = require('utf-8-validate');
    87 
    88   /* istanbul ignore if */
    89   if (typeof isValidUTF8 === 'object') {
    90     isValidUTF8 = isValidUTF8.Validation.isValidUTF8; // utf-8-validate@<3.0.0
    91   }
    92 
    93   module.exports = {
    94     isValidStatusCode,
    95     isValidUTF8(buf) {
    96       return buf.length < 150 ? _isValidUTF8(buf) : isValidUTF8(buf);
    97     }
    98   };
    99 } catch (e) /* istanbul ignore next */ {
    100   module.exports = {
    101     isValidStatusCode,
    102     isValidUTF8: _isValidUTF8
    103   };
    104 }
     30};
Note: See TracChangeset for help on using the changeset viewer.