Path: blob/main/crypto/heimdal/lib/wind/rfc4518.py
34914 views
#!/usr/local/bin/python1# -*- coding: iso-8859-1 -*-23# $Id$45# Copyright (c) 2004, 2008 Kungliga Tekniska Högskolan6# (Royal Institute of Technology, Stockholm, Sweden).7# All rights reserved.8#9# Redistribution and use in source and binary forms, with or without10# modification, are permitted provided that the following conditions11# are met:12#13# 1. Redistributions of source code must retain the above copyright14# notice, this list of conditions and the following disclaimer.15#16# 2. Redistributions in binary form must reproduce the above copyright17# notice, this list of conditions and the following disclaimer in the18# documentation and/or other materials provided with the distribution.19#20# 3. Neither the name of the Institute nor the names of its contributors21# may be used to endorse or promote products derived from this software22# without specific prior written permission.23#24# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND25# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE26# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE27# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE28# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL29# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS30# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)31# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT32# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY33# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF34# SUCH DAMAGE.3536import re37import string3839def read():40"""return a dict of tables from rfc4518"""4142ret = {}4344#2.2. Map45#46# SOFT HYPHEN (U+00AD) and MONGOLIAN TODO SOFT HYPHEN (U+1806) code47# points are mapped to nothing. COMBINING GRAPHEME JOINER (U+034F) and48# VARIATION SELECTORs (U+180B-180D, FF00-FE0F) code points are also49# mapped to nothing. The OBJECT REPLACEMENT CHARACTER (U+FFFC) is50# mapped to nothing.5152t = []53t.append(" 00AD; ; Map to nothing")54t.append(" 1806; ; Map to nothing")55t.append(" 034F; ; Map to nothing")5657t.append(" 180B; ; Map to nothing")58t.append(" 180C; ; Map to nothing")59t.append(" 180D; ; Map to nothing")6061t.append(" FE00; ; Map to nothing")62t.append(" FE01; ; Map to nothing")63t.append(" FE02; ; Map to nothing")64t.append(" FE03; ; Map to nothing")65t.append(" FE04; ; Map to nothing")66t.append(" FE05; ; Map to nothing")67t.append(" FE06; ; Map to nothing")68t.append(" FE07; ; Map to nothing")69t.append(" FE08; ; Map to nothing")70t.append(" FE09; ; Map to nothing")71t.append(" FE0A; ; Map to nothing")72t.append(" FE0B; ; Map to nothing")73t.append(" FE0C; ; Map to nothing")74t.append(" FE0D; ; Map to nothing")75t.append(" FE0E; ; Map to nothing")76t.append(" FE0F; ; Map to nothing")7778t.append(" FFFC; ; Map to nothing")7980# CHARACTER TABULATION (U+0009), LINE FEED (LF) (U+000A), LINE81# TABULATION (U+000B), FORM FEED (FF) (U+000C), CARRIAGE RETURN (CR)82# (U+000D), and NEXT LINE (NEL) (U+0085) are mapped to SPACE (U+0020).8384t.append(" 0009; 0020 ; Map to SPACE")85t.append(" 000A; 0020 ; Map to SPACE")86t.append(" 000B; 0020 ; Map to SPACE")87t.append(" 000C; 0020 ; Map to SPACE")88t.append(" 000D; 0020 ; Map to SPACE")89t.append(" 0085; 0020 ; Map to SPACE")9091# All other control code (e.g., Cc) points or code points with a92# control function (e.g., Cf) are mapped to nothing. The following is93# a complete list of these code points: U+0000-0008, 000E-001F, 007F-94# 0084, 0086-009F, 06DD, 070F, 180E, 200C-200F, 202A-202E, 2060-2063,95# 206A-206F, FEFF, FFF9-FFFB, 1D173-1D17A, E0001, E0020-E007F.9697t.append(" 0000-0008; ; Map to nothing")98t.append(" 000E-001F; ; Map to nothing")99t.append(" 007F-0084; ; Map to nothing")100t.append(" 0086-009F; ; Map to nothing")101t.append(" 06DD; ; Map to nothing")102t.append(" 070F; ; Map to nothing")103t.append(" 180E; ; Map to nothing")104t.append(" 200C-200F; ; Map to nothing")105t.append(" 202A-202E; ; Map to nothing")106t.append(" 2060-2063; ; Map to nothing")107t.append(" 206A-206F; ; Map to nothing")108t.append(" FEFF; ; Map to nothing")109t.append(" FFF9-FFFB; ; Map to nothing")110t.append(" 1D173-1D17A; ; Map to nothing")111t.append(" E0001; ; Map to nothing")112t.append(" E0020-E007F; ; Map to nothing")113114# ZERO WIDTH SPACE (U+200B) is mapped to nothing. All other code115# points with Separator (space, line, or paragraph) property (e.g., Zs,116# Zl, or Zp) are mapped to SPACE (U+0020). The following is a complete117# list of these code points: U+0020, 00A0, 1680, 2000-200A, 2028-2029,118# 202F, 205F, 3000.119120t.append(" 200B; ; Map to nothing")121t.append(" 0020; 0020; Map to SPACE")122t.append(" 00A0; 0020; Map to SPACE")123t.append(" 1680; 0020; Map to SPACE")124t.append(" 2000-200A; 0020; Map to SPACE")125t.append(" 2028-2029; 0020; Map to SPACE")126t.append(" 202F; 0020; Map to SPACE")127t.append(" 205F; 0020; Map to SPACE")128t.append(" 3000; 0020; Map to SPACE")129130ret["rfc4518-map"] = t131132# For case ignore, numeric, and stored prefix string matching rules,133# characters are case folded per B.2 of [RFC3454].134135t = []136137#2.4. Prohibit138139# The REPLACEMENT CHARACTER (U+FFFD) code point is prohibited.140141t.append(" FFFD;")142143ret["rfc4518-error"] = t144145t = []146147148149return ret150151152