Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python3..../email
File: headerregistry.py
"""Representing and manipulating email headers via custom objects.
[0] Fix | Delete
[1] Fix | Delete
This module provides an implementation of the HeaderRegistry API.
[2] Fix | Delete
The implementation is designed to flexibly follow RFC5322 rules.
[3] Fix | Delete
[4] Fix | Delete
Eventually HeaderRegistry will be a public API, but it isn't yet,
[5] Fix | Delete
and will probably change some before that happens.
[6] Fix | Delete
[7] Fix | Delete
"""
[8] Fix | Delete
from types import MappingProxyType
[9] Fix | Delete
[10] Fix | Delete
from email import utils
[11] Fix | Delete
from email import errors
[12] Fix | Delete
from email import _header_value_parser as parser
[13] Fix | Delete
[14] Fix | Delete
class Address:
[15] Fix | Delete
[16] Fix | Delete
def __init__(self, display_name='', username='', domain='', addr_spec=None):
[17] Fix | Delete
"""Create an object representing a full email address.
[18] Fix | Delete
[19] Fix | Delete
An address can have a 'display_name', a 'username', and a 'domain'. In
[20] Fix | Delete
addition to specifying the username and domain separately, they may be
[21] Fix | Delete
specified together by using the addr_spec keyword *instead of* the
[22] Fix | Delete
username and domain keywords. If an addr_spec string is specified it
[23] Fix | Delete
must be properly quoted according to RFC 5322 rules; an error will be
[24] Fix | Delete
raised if it is not.
[25] Fix | Delete
[26] Fix | Delete
An Address object has display_name, username, domain, and addr_spec
[27] Fix | Delete
attributes, all of which are read-only. The addr_spec and the string
[28] Fix | Delete
value of the object are both quoted according to RFC5322 rules, but
[29] Fix | Delete
without any Content Transfer Encoding.
[30] Fix | Delete
[31] Fix | Delete
"""
[32] Fix | Delete
# This clause with its potential 'raise' may only happen when an
[33] Fix | Delete
# application program creates an Address object using an addr_spec
[34] Fix | Delete
# keyword. The email library code itself must always supply username
[35] Fix | Delete
# and domain.
[36] Fix | Delete
if addr_spec is not None:
[37] Fix | Delete
if username or domain:
[38] Fix | Delete
raise TypeError("addrspec specified when username and/or "
[39] Fix | Delete
"domain also specified")
[40] Fix | Delete
a_s, rest = parser.get_addr_spec(addr_spec)
[41] Fix | Delete
if rest:
[42] Fix | Delete
raise ValueError("Invalid addr_spec; only '{}' "
[43] Fix | Delete
"could be parsed from '{}'".format(
[44] Fix | Delete
a_s, addr_spec))
[45] Fix | Delete
if a_s.all_defects:
[46] Fix | Delete
raise a_s.all_defects[0]
[47] Fix | Delete
username = a_s.local_part
[48] Fix | Delete
domain = a_s.domain
[49] Fix | Delete
self._display_name = display_name
[50] Fix | Delete
self._username = username
[51] Fix | Delete
self._domain = domain
[52] Fix | Delete
[53] Fix | Delete
@property
[54] Fix | Delete
def display_name(self):
[55] Fix | Delete
return self._display_name
[56] Fix | Delete
[57] Fix | Delete
@property
[58] Fix | Delete
def username(self):
[59] Fix | Delete
return self._username
[60] Fix | Delete
[61] Fix | Delete
@property
[62] Fix | Delete
def domain(self):
[63] Fix | Delete
return self._domain
[64] Fix | Delete
[65] Fix | Delete
@property
[66] Fix | Delete
def addr_spec(self):
[67] Fix | Delete
"""The addr_spec (username@domain) portion of the address, quoted
[68] Fix | Delete
according to RFC 5322 rules, but with no Content Transfer Encoding.
[69] Fix | Delete
"""
[70] Fix | Delete
nameset = set(self.username)
[71] Fix | Delete
if len(nameset) > len(nameset-parser.DOT_ATOM_ENDS):
[72] Fix | Delete
lp = parser.quote_string(self.username)
[73] Fix | Delete
else:
[74] Fix | Delete
lp = self.username
[75] Fix | Delete
if self.domain:
[76] Fix | Delete
return lp + '@' + self.domain
[77] Fix | Delete
if not lp:
[78] Fix | Delete
return '<>'
[79] Fix | Delete
return lp
[80] Fix | Delete
[81] Fix | Delete
def __repr__(self):
[82] Fix | Delete
return "{}(display_name={!r}, username={!r}, domain={!r})".format(
[83] Fix | Delete
self.__class__.__name__,
[84] Fix | Delete
self.display_name, self.username, self.domain)
[85] Fix | Delete
[86] Fix | Delete
def __str__(self):
[87] Fix | Delete
nameset = set(self.display_name)
[88] Fix | Delete
if len(nameset) > len(nameset-parser.SPECIALS):
[89] Fix | Delete
disp = parser.quote_string(self.display_name)
[90] Fix | Delete
else:
[91] Fix | Delete
disp = self.display_name
[92] Fix | Delete
if disp:
[93] Fix | Delete
addr_spec = '' if self.addr_spec=='<>' else self.addr_spec
[94] Fix | Delete
return "{} <{}>".format(disp, addr_spec)
[95] Fix | Delete
return self.addr_spec
[96] Fix | Delete
[97] Fix | Delete
def __eq__(self, other):
[98] Fix | Delete
if type(other) != type(self):
[99] Fix | Delete
return False
[100] Fix | Delete
return (self.display_name == other.display_name and
[101] Fix | Delete
self.username == other.username and
[102] Fix | Delete
self.domain == other.domain)
[103] Fix | Delete
[104] Fix | Delete
[105] Fix | Delete
class Group:
[106] Fix | Delete
[107] Fix | Delete
def __init__(self, display_name=None, addresses=None):
[108] Fix | Delete
"""Create an object representing an address group.
[109] Fix | Delete
[110] Fix | Delete
An address group consists of a display_name followed by colon and a
[111] Fix | Delete
list of addresses (see Address) terminated by a semi-colon. The Group
[112] Fix | Delete
is created by specifying a display_name and a possibly empty list of
[113] Fix | Delete
Address objects. A Group can also be used to represent a single
[114] Fix | Delete
address that is not in a group, which is convenient when manipulating
[115] Fix | Delete
lists that are a combination of Groups and individual Addresses. In
[116] Fix | Delete
this case the display_name should be set to None. In particular, the
[117] Fix | Delete
string representation of a Group whose display_name is None is the same
[118] Fix | Delete
as the Address object, if there is one and only one Address object in
[119] Fix | Delete
the addresses list.
[120] Fix | Delete
[121] Fix | Delete
"""
[122] Fix | Delete
self._display_name = display_name
[123] Fix | Delete
self._addresses = tuple(addresses) if addresses else tuple()
[124] Fix | Delete
[125] Fix | Delete
@property
[126] Fix | Delete
def display_name(self):
[127] Fix | Delete
return self._display_name
[128] Fix | Delete
[129] Fix | Delete
@property
[130] Fix | Delete
def addresses(self):
[131] Fix | Delete
return self._addresses
[132] Fix | Delete
[133] Fix | Delete
def __repr__(self):
[134] Fix | Delete
return "{}(display_name={!r}, addresses={!r}".format(
[135] Fix | Delete
self.__class__.__name__,
[136] Fix | Delete
self.display_name, self.addresses)
[137] Fix | Delete
[138] Fix | Delete
def __str__(self):
[139] Fix | Delete
if self.display_name is None and len(self.addresses)==1:
[140] Fix | Delete
return str(self.addresses[0])
[141] Fix | Delete
disp = self.display_name
[142] Fix | Delete
if disp is not None:
[143] Fix | Delete
nameset = set(disp)
[144] Fix | Delete
if len(nameset) > len(nameset-parser.SPECIALS):
[145] Fix | Delete
disp = parser.quote_string(disp)
[146] Fix | Delete
adrstr = ", ".join(str(x) for x in self.addresses)
[147] Fix | Delete
adrstr = ' ' + adrstr if adrstr else adrstr
[148] Fix | Delete
return "{}:{};".format(disp, adrstr)
[149] Fix | Delete
[150] Fix | Delete
def __eq__(self, other):
[151] Fix | Delete
if type(other) != type(self):
[152] Fix | Delete
return False
[153] Fix | Delete
return (self.display_name == other.display_name and
[154] Fix | Delete
self.addresses == other.addresses)
[155] Fix | Delete
[156] Fix | Delete
[157] Fix | Delete
# Header Classes #
[158] Fix | Delete
[159] Fix | Delete
class BaseHeader(str):
[160] Fix | Delete
[161] Fix | Delete
"""Base class for message headers.
[162] Fix | Delete
[163] Fix | Delete
Implements generic behavior and provides tools for subclasses.
[164] Fix | Delete
[165] Fix | Delete
A subclass must define a classmethod named 'parse' that takes an unfolded
[166] Fix | Delete
value string and a dictionary as its arguments. The dictionary will
[167] Fix | Delete
contain one key, 'defects', initialized to an empty list. After the call
[168] Fix | Delete
the dictionary must contain two additional keys: parse_tree, set to the
[169] Fix | Delete
parse tree obtained from parsing the header, and 'decoded', set to the
[170] Fix | Delete
string value of the idealized representation of the data from the value.
[171] Fix | Delete
(That is, encoded words are decoded, and values that have canonical
[172] Fix | Delete
representations are so represented.)
[173] Fix | Delete
[174] Fix | Delete
The defects key is intended to collect parsing defects, which the message
[175] Fix | Delete
parser will subsequently dispose of as appropriate. The parser should not,
[176] Fix | Delete
insofar as practical, raise any errors. Defects should be added to the
[177] Fix | Delete
list instead. The standard header parsers register defects for RFC
[178] Fix | Delete
compliance issues, for obsolete RFC syntax, and for unrecoverable parsing
[179] Fix | Delete
errors.
[180] Fix | Delete
[181] Fix | Delete
The parse method may add additional keys to the dictionary. In this case
[182] Fix | Delete
the subclass must define an 'init' method, which will be passed the
[183] Fix | Delete
dictionary as its keyword arguments. The method should use (usually by
[184] Fix | Delete
setting them as the value of similarly named attributes) and remove all the
[185] Fix | Delete
extra keys added by its parse method, and then use super to call its parent
[186] Fix | Delete
class with the remaining arguments and keywords.
[187] Fix | Delete
[188] Fix | Delete
The subclass should also make sure that a 'max_count' attribute is defined
[189] Fix | Delete
that is either None or 1. XXX: need to better define this API.
[190] Fix | Delete
[191] Fix | Delete
"""
[192] Fix | Delete
[193] Fix | Delete
def __new__(cls, name, value):
[194] Fix | Delete
kwds = {'defects': []}
[195] Fix | Delete
cls.parse(value, kwds)
[196] Fix | Delete
if utils._has_surrogates(kwds['decoded']):
[197] Fix | Delete
kwds['decoded'] = utils._sanitize(kwds['decoded'])
[198] Fix | Delete
self = str.__new__(cls, kwds['decoded'])
[199] Fix | Delete
del kwds['decoded']
[200] Fix | Delete
self.init(name, **kwds)
[201] Fix | Delete
return self
[202] Fix | Delete
[203] Fix | Delete
def init(self, name, *, parse_tree, defects):
[204] Fix | Delete
self._name = name
[205] Fix | Delete
self._parse_tree = parse_tree
[206] Fix | Delete
self._defects = defects
[207] Fix | Delete
[208] Fix | Delete
@property
[209] Fix | Delete
def name(self):
[210] Fix | Delete
return self._name
[211] Fix | Delete
[212] Fix | Delete
@property
[213] Fix | Delete
def defects(self):
[214] Fix | Delete
return tuple(self._defects)
[215] Fix | Delete
[216] Fix | Delete
def __reduce__(self):
[217] Fix | Delete
return (
[218] Fix | Delete
_reconstruct_header,
[219] Fix | Delete
(
[220] Fix | Delete
self.__class__.__name__,
[221] Fix | Delete
self.__class__.__bases__,
[222] Fix | Delete
str(self),
[223] Fix | Delete
),
[224] Fix | Delete
self.__dict__)
[225] Fix | Delete
[226] Fix | Delete
@classmethod
[227] Fix | Delete
def _reconstruct(cls, value):
[228] Fix | Delete
return str.__new__(cls, value)
[229] Fix | Delete
[230] Fix | Delete
def fold(self, *, policy):
[231] Fix | Delete
"""Fold header according to policy.
[232] Fix | Delete
[233] Fix | Delete
The parsed representation of the header is folded according to
[234] Fix | Delete
RFC5322 rules, as modified by the policy. If the parse tree
[235] Fix | Delete
contains surrogateescaped bytes, the bytes are CTE encoded using
[236] Fix | Delete
the charset 'unknown-8bit".
[237] Fix | Delete
[238] Fix | Delete
Any non-ASCII characters in the parse tree are CTE encoded using
[239] Fix | Delete
charset utf-8. XXX: make this a policy setting.
[240] Fix | Delete
[241] Fix | Delete
The returned value is an ASCII-only string possibly containing linesep
[242] Fix | Delete
characters, and ending with a linesep character. The string includes
[243] Fix | Delete
the header name and the ': ' separator.
[244] Fix | Delete
[245] Fix | Delete
"""
[246] Fix | Delete
# At some point we need to put fws here iif it was in the source.
[247] Fix | Delete
header = parser.Header([
[248] Fix | Delete
parser.HeaderLabel([
[249] Fix | Delete
parser.ValueTerminal(self.name, 'header-name'),
[250] Fix | Delete
parser.ValueTerminal(':', 'header-sep')]),
[251] Fix | Delete
])
[252] Fix | Delete
if self._parse_tree:
[253] Fix | Delete
header.append(
[254] Fix | Delete
parser.CFWSList([parser.WhiteSpaceTerminal(' ', 'fws')]))
[255] Fix | Delete
header.append(self._parse_tree)
[256] Fix | Delete
return header.fold(policy=policy)
[257] Fix | Delete
[258] Fix | Delete
[259] Fix | Delete
def _reconstruct_header(cls_name, bases, value):
[260] Fix | Delete
return type(cls_name, bases, {})._reconstruct(value)
[261] Fix | Delete
[262] Fix | Delete
[263] Fix | Delete
class UnstructuredHeader:
[264] Fix | Delete
[265] Fix | Delete
max_count = None
[266] Fix | Delete
value_parser = staticmethod(parser.get_unstructured)
[267] Fix | Delete
[268] Fix | Delete
@classmethod
[269] Fix | Delete
def parse(cls, value, kwds):
[270] Fix | Delete
kwds['parse_tree'] = cls.value_parser(value)
[271] Fix | Delete
kwds['decoded'] = str(kwds['parse_tree'])
[272] Fix | Delete
[273] Fix | Delete
[274] Fix | Delete
class UniqueUnstructuredHeader(UnstructuredHeader):
[275] Fix | Delete
[276] Fix | Delete
max_count = 1
[277] Fix | Delete
[278] Fix | Delete
[279] Fix | Delete
class DateHeader:
[280] Fix | Delete
[281] Fix | Delete
"""Header whose value consists of a single timestamp.
[282] Fix | Delete
[283] Fix | Delete
Provides an additional attribute, datetime, which is either an aware
[284] Fix | Delete
datetime using a timezone, or a naive datetime if the timezone
[285] Fix | Delete
in the input string is -0000. Also accepts a datetime as input.
[286] Fix | Delete
The 'value' attribute is the normalized form of the timestamp,
[287] Fix | Delete
which means it is the output of format_datetime on the datetime.
[288] Fix | Delete
"""
[289] Fix | Delete
[290] Fix | Delete
max_count = None
[291] Fix | Delete
[292] Fix | Delete
# This is used only for folding, not for creating 'decoded'.
[293] Fix | Delete
value_parser = staticmethod(parser.get_unstructured)
[294] Fix | Delete
[295] Fix | Delete
@classmethod
[296] Fix | Delete
def parse(cls, value, kwds):
[297] Fix | Delete
if not value:
[298] Fix | Delete
kwds['defects'].append(errors.HeaderMissingRequiredValue())
[299] Fix | Delete
kwds['datetime'] = None
[300] Fix | Delete
kwds['decoded'] = ''
[301] Fix | Delete
kwds['parse_tree'] = parser.TokenList()
[302] Fix | Delete
return
[303] Fix | Delete
if isinstance(value, str):
[304] Fix | Delete
value = utils.parsedate_to_datetime(value)
[305] Fix | Delete
kwds['datetime'] = value
[306] Fix | Delete
kwds['decoded'] = utils.format_datetime(kwds['datetime'])
[307] Fix | Delete
kwds['parse_tree'] = cls.value_parser(kwds['decoded'])
[308] Fix | Delete
[309] Fix | Delete
def init(self, *args, **kw):
[310] Fix | Delete
self._datetime = kw.pop('datetime')
[311] Fix | Delete
super().init(*args, **kw)
[312] Fix | Delete
[313] Fix | Delete
@property
[314] Fix | Delete
def datetime(self):
[315] Fix | Delete
return self._datetime
[316] Fix | Delete
[317] Fix | Delete
[318] Fix | Delete
class UniqueDateHeader(DateHeader):
[319] Fix | Delete
[320] Fix | Delete
max_count = 1
[321] Fix | Delete
[322] Fix | Delete
[323] Fix | Delete
class AddressHeader:
[324] Fix | Delete
[325] Fix | Delete
max_count = None
[326] Fix | Delete
[327] Fix | Delete
@staticmethod
[328] Fix | Delete
def value_parser(value):
[329] Fix | Delete
address_list, value = parser.get_address_list(value)
[330] Fix | Delete
assert not value, 'this should not happen'
[331] Fix | Delete
return address_list
[332] Fix | Delete
[333] Fix | Delete
@classmethod
[334] Fix | Delete
def parse(cls, value, kwds):
[335] Fix | Delete
if isinstance(value, str):
[336] Fix | Delete
# We are translating here from the RFC language (address/mailbox)
[337] Fix | Delete
# to our API language (group/address).
[338] Fix | Delete
kwds['parse_tree'] = address_list = cls.value_parser(value)
[339] Fix | Delete
groups = []
[340] Fix | Delete
for addr in address_list.addresses:
[341] Fix | Delete
groups.append(Group(addr.display_name,
[342] Fix | Delete
[Address(mb.display_name or '',
[343] Fix | Delete
mb.local_part or '',
[344] Fix | Delete
mb.domain or '')
[345] Fix | Delete
for mb in addr.all_mailboxes]))
[346] Fix | Delete
defects = list(address_list.all_defects)
[347] Fix | Delete
else:
[348] Fix | Delete
# Assume it is Address/Group stuff
[349] Fix | Delete
if not hasattr(value, '__iter__'):
[350] Fix | Delete
value = [value]
[351] Fix | Delete
groups = [Group(None, [item]) if not hasattr(item, 'addresses')
[352] Fix | Delete
else item
[353] Fix | Delete
for item in value]
[354] Fix | Delete
defects = []
[355] Fix | Delete
kwds['groups'] = groups
[356] Fix | Delete
kwds['defects'] = defects
[357] Fix | Delete
kwds['decoded'] = ', '.join([str(item) for item in groups])
[358] Fix | Delete
if 'parse_tree' not in kwds:
[359] Fix | Delete
kwds['parse_tree'] = cls.value_parser(kwds['decoded'])
[360] Fix | Delete
[361] Fix | Delete
def init(self, *args, **kw):
[362] Fix | Delete
self._groups = tuple(kw.pop('groups'))
[363] Fix | Delete
self._addresses = None
[364] Fix | Delete
super().init(*args, **kw)
[365] Fix | Delete
[366] Fix | Delete
@property
[367] Fix | Delete
def groups(self):
[368] Fix | Delete
return self._groups
[369] Fix | Delete
[370] Fix | Delete
@property
[371] Fix | Delete
def addresses(self):
[372] Fix | Delete
if self._addresses is None:
[373] Fix | Delete
self._addresses = tuple([address for group in self._groups
[374] Fix | Delete
for address in group.addresses])
[375] Fix | Delete
return self._addresses
[376] Fix | Delete
[377] Fix | Delete
[378] Fix | Delete
class UniqueAddressHeader(AddressHeader):
[379] Fix | Delete
[380] Fix | Delete
max_count = 1
[381] Fix | Delete
[382] Fix | Delete
[383] Fix | Delete
class SingleAddressHeader(AddressHeader):
[384] Fix | Delete
[385] Fix | Delete
@property
[386] Fix | Delete
def address(self):
[387] Fix | Delete
if len(self.addresses)!=1:
[388] Fix | Delete
raise ValueError(("value of single address header {} is not "
[389] Fix | Delete
"a single address").format(self.name))
[390] Fix | Delete
return self.addresses[0]
[391] Fix | Delete
[392] Fix | Delete
[393] Fix | Delete
class UniqueSingleAddressHeader(SingleAddressHeader):
[394] Fix | Delete
[395] Fix | Delete
max_count = 1
[396] Fix | Delete
[397] Fix | Delete
[398] Fix | Delete
class MIMEVersionHeader:
[399] Fix | Delete
[400] Fix | Delete
max_count = 1
[401] Fix | Delete
[402] Fix | Delete
value_parser = staticmethod(parser.parse_mime_version)
[403] Fix | Delete
[404] Fix | Delete
@classmethod
[405] Fix | Delete
def parse(cls, value, kwds):
[406] Fix | Delete
kwds['parse_tree'] = parse_tree = cls.value_parser(value)
[407] Fix | Delete
kwds['decoded'] = str(parse_tree)
[408] Fix | Delete
kwds['defects'].extend(parse_tree.all_defects)
[409] Fix | Delete
kwds['major'] = None if parse_tree.minor is None else parse_tree.major
[410] Fix | Delete
kwds['minor'] = parse_tree.minor
[411] Fix | Delete
if parse_tree.minor is not None:
[412] Fix | Delete
kwds['version'] = '{}.{}'.format(kwds['major'], kwds['minor'])
[413] Fix | Delete
else:
[414] Fix | Delete
kwds['version'] = None
[415] Fix | Delete
[416] Fix | Delete
def init(self, *args, **kw):
[417] Fix | Delete
self._version = kw.pop('version')
[418] Fix | Delete
self._major = kw.pop('major')
[419] Fix | Delete
self._minor = kw.pop('minor')
[420] Fix | Delete
super().init(*args, **kw)
[421] Fix | Delete
[422] Fix | Delete
@property
[423] Fix | Delete
def major(self):
[424] Fix | Delete
return self._major
[425] Fix | Delete
[426] Fix | Delete
@property
[427] Fix | Delete
def minor(self):
[428] Fix | Delete
return self._minor
[429] Fix | Delete
[430] Fix | Delete
@property
[431] Fix | Delete
def version(self):
[432] Fix | Delete
return self._version
[433] Fix | Delete
[434] Fix | Delete
[435] Fix | Delete
class ParameterizedMIMEHeader:
[436] Fix | Delete
[437] Fix | Delete
# Mixin that handles the params dict. Must be subclassed and
[438] Fix | Delete
# a property value_parser for the specific header provided.
[439] Fix | Delete
[440] Fix | Delete
max_count = 1
[441] Fix | Delete
[442] Fix | Delete
@classmethod
[443] Fix | Delete
def parse(cls, value, kwds):
[444] Fix | Delete
kwds['parse_tree'] = parse_tree = cls.value_parser(value)
[445] Fix | Delete
kwds['decoded'] = str(parse_tree)
[446] Fix | Delete
kwds['defects'].extend(parse_tree.all_defects)
[447] Fix | Delete
if parse_tree.params is None:
[448] Fix | Delete
kwds['params'] = {}
[449] Fix | Delete
else:
[450] Fix | Delete
# The MIME RFCs specify that parameter ordering is arbitrary.
[451] Fix | Delete
kwds['params'] = {utils._sanitize(name).lower():
[452] Fix | Delete
utils._sanitize(value)
[453] Fix | Delete
for name, value in parse_tree.params}
[454] Fix | Delete
[455] Fix | Delete
def init(self, *args, **kw):
[456] Fix | Delete
self._params = kw.pop('params')
[457] Fix | Delete
super().init(*args, **kw)
[458] Fix | Delete
[459] Fix | Delete
@property
[460] Fix | Delete
def params(self):
[461] Fix | Delete
return MappingProxyType(self._params)
[462] Fix | Delete
[463] Fix | Delete
[464] Fix | Delete
class ContentTypeHeader(ParameterizedMIMEHeader):
[465] Fix | Delete
[466] Fix | Delete
value_parser = staticmethod(parser.parse_content_type_header)
[467] Fix | Delete
[468] Fix | Delete
def init(self, *args, **kw):
[469] Fix | Delete
super().init(*args, **kw)
[470] Fix | Delete
self._maintype = utils._sanitize(self._parse_tree.maintype)
[471] Fix | Delete
self._subtype = utils._sanitize(self._parse_tree.subtype)
[472] Fix | Delete
[473] Fix | Delete
@property
[474] Fix | Delete
def maintype(self):
[475] Fix | Delete
return self._maintype
[476] Fix | Delete
[477] Fix | Delete
@property
[478] Fix | Delete
def subtype(self):
[479] Fix | Delete
return self._subtype
[480] Fix | Delete
[481] Fix | Delete
@property
[482] Fix | Delete
def content_type(self):
[483] Fix | Delete
return self.maintype + '/' + self.subtype
[484] Fix | Delete
[485] Fix | Delete
[486] Fix | Delete
class ContentDispositionHeader(ParameterizedMIMEHeader):
[487] Fix | Delete
[488] Fix | Delete
value_parser = staticmethod(parser.parse_content_disposition_header)
[489] Fix | Delete
[490] Fix | Delete
def init(self, *args, **kw):
[491] Fix | Delete
super().init(*args, **kw)
[492] Fix | Delete
cd = self._parse_tree.content_disposition
[493] Fix | Delete
self._content_disposition = cd if cd is None else utils._sanitize(cd)
[494] Fix | Delete
[495] Fix | Delete
@property
[496] Fix | Delete
def content_disposition(self):
[497] Fix | Delete
return self._content_disposition
[498] Fix | Delete
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function