github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_tables.go (about)

     1  // Copyright (C) MongoDB, Inc. 2017-present.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License"); you may
     4  // not use this file except in compliance with the License. You may obtain
     5  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
     6  //
     7  // Based on github.com/golang/go by The Go Authors
     8  // See THIRD-PARTY-NOTICES for original license terms.
     9  
    10  package bsonrw
    11  
    12  import "unicode/utf8"
    13  
    14  // safeSet holds the value true if the ASCII character with the given array
    15  // position can be represented inside a JSON string without any further
    16  // escaping.
    17  //
    18  // All values are true except for the ASCII control characters (0-31), the
    19  // double quote ("), and the backslash character ("\").
    20  var safeSet = [utf8.RuneSelf]bool{
    21  	' ':      true,
    22  	'!':      true,
    23  	'"':      false,
    24  	'#':      true,
    25  	'$':      true,
    26  	'%':      true,
    27  	'&':      true,
    28  	'\'':     true,
    29  	'(':      true,
    30  	')':      true,
    31  	'*':      true,
    32  	'+':      true,
    33  	',':      true,
    34  	'-':      true,
    35  	'.':      true,
    36  	'/':      true,
    37  	'0':      true,
    38  	'1':      true,
    39  	'2':      true,
    40  	'3':      true,
    41  	'4':      true,
    42  	'5':      true,
    43  	'6':      true,
    44  	'7':      true,
    45  	'8':      true,
    46  	'9':      true,
    47  	':':      true,
    48  	';':      true,
    49  	'<':      true,
    50  	'=':      true,
    51  	'>':      true,
    52  	'?':      true,
    53  	'@':      true,
    54  	'A':      true,
    55  	'B':      true,
    56  	'C':      true,
    57  	'D':      true,
    58  	'E':      true,
    59  	'F':      true,
    60  	'G':      true,
    61  	'H':      true,
    62  	'I':      true,
    63  	'J':      true,
    64  	'K':      true,
    65  	'L':      true,
    66  	'M':      true,
    67  	'N':      true,
    68  	'O':      true,
    69  	'P':      true,
    70  	'Q':      true,
    71  	'R':      true,
    72  	'S':      true,
    73  	'T':      true,
    74  	'U':      true,
    75  	'V':      true,
    76  	'W':      true,
    77  	'X':      true,
    78  	'Y':      true,
    79  	'Z':      true,
    80  	'[':      true,
    81  	'\\':     false,
    82  	']':      true,
    83  	'^':      true,
    84  	'_':      true,
    85  	'`':      true,
    86  	'a':      true,
    87  	'b':      true,
    88  	'c':      true,
    89  	'd':      true,
    90  	'e':      true,
    91  	'f':      true,
    92  	'g':      true,
    93  	'h':      true,
    94  	'i':      true,
    95  	'j':      true,
    96  	'k':      true,
    97  	'l':      true,
    98  	'm':      true,
    99  	'n':      true,
   100  	'o':      true,
   101  	'p':      true,
   102  	'q':      true,
   103  	'r':      true,
   104  	's':      true,
   105  	't':      true,
   106  	'u':      true,
   107  	'v':      true,
   108  	'w':      true,
   109  	'x':      true,
   110  	'y':      true,
   111  	'z':      true,
   112  	'{':      true,
   113  	'|':      true,
   114  	'}':      true,
   115  	'~':      true,
   116  	'\u007f': true,
   117  }
   118  
   119  // htmlSafeSet holds the value true if the ASCII character with the given
   120  // array position can be safely represented inside a JSON string, embedded
   121  // inside of HTML <script> tags, without any additional escaping.
   122  //
   123  // All values are true except for the ASCII control characters (0-31), the
   124  // double quote ("), the backslash character ("\"), HTML opening and closing
   125  // tags ("<" and ">"), and the ampersand ("&").
   126  var htmlSafeSet = [utf8.RuneSelf]bool{
   127  	' ':      true,
   128  	'!':      true,
   129  	'"':      false,
   130  	'#':      true,
   131  	'$':      true,
   132  	'%':      true,
   133  	'&':      false,
   134  	'\'':     true,
   135  	'(':      true,
   136  	')':      true,
   137  	'*':      true,
   138  	'+':      true,
   139  	',':      true,
   140  	'-':      true,
   141  	'.':      true,
   142  	'/':      true,
   143  	'0':      true,
   144  	'1':      true,
   145  	'2':      true,
   146  	'3':      true,
   147  	'4':      true,
   148  	'5':      true,
   149  	'6':      true,
   150  	'7':      true,
   151  	'8':      true,
   152  	'9':      true,
   153  	':':      true,
   154  	';':      true,
   155  	'<':      false,
   156  	'=':      true,
   157  	'>':      false,
   158  	'?':      true,
   159  	'@':      true,
   160  	'A':      true,
   161  	'B':      true,
   162  	'C':      true,
   163  	'D':      true,
   164  	'E':      true,
   165  	'F':      true,
   166  	'G':      true,
   167  	'H':      true,
   168  	'I':      true,
   169  	'J':      true,
   170  	'K':      true,
   171  	'L':      true,
   172  	'M':      true,
   173  	'N':      true,
   174  	'O':      true,
   175  	'P':      true,
   176  	'Q':      true,
   177  	'R':      true,
   178  	'S':      true,
   179  	'T':      true,
   180  	'U':      true,
   181  	'V':      true,
   182  	'W':      true,
   183  	'X':      true,
   184  	'Y':      true,
   185  	'Z':      true,
   186  	'[':      true,
   187  	'\\':     false,
   188  	']':      true,
   189  	'^':      true,
   190  	'_':      true,
   191  	'`':      true,
   192  	'a':      true,
   193  	'b':      true,
   194  	'c':      true,
   195  	'd':      true,
   196  	'e':      true,
   197  	'f':      true,
   198  	'g':      true,
   199  	'h':      true,
   200  	'i':      true,
   201  	'j':      true,
   202  	'k':      true,
   203  	'l':      true,
   204  	'm':      true,
   205  	'n':      true,
   206  	'o':      true,
   207  	'p':      true,
   208  	'q':      true,
   209  	'r':      true,
   210  	's':      true,
   211  	't':      true,
   212  	'u':      true,
   213  	'v':      true,
   214  	'w':      true,
   215  	'x':      true,
   216  	'y':      true,
   217  	'z':      true,
   218  	'{':      true,
   219  	'|':      true,
   220  	'}':      true,
   221  	'~':      true,
   222  	'\u007f': true,
   223  }