MCPcopy Index your code
hub / github.com/python/cpython / getdomain

Method getdomain

Lib/email/_parseaddr.py:403–424  ·  view source on GitHub ↗

Get the complete domain name from an address.

(self)

Source from the content-addressed store, hash-verified

401 return EMPTYSTRING.join(aslist) + domain
402
403 def getdomain(self):
404 """Get the complete domain name from an address."""
405 sdlist = []
406 while self.pos < len(self.field):
407 if self.field[self.pos] in self.LWS:
408 self.pos += 1
409 elif self.field[self.pos] == '(':
410 self.commentlist.append(self.getcomment())
411 elif self.field[self.pos] == '[':
412 sdlist.append(self.getdomainliteral())
413 elif self.field[self.pos] == '.':
414 self.pos += 1
415 sdlist.append('.')
416 elif self.field[self.pos] == '@':
417 # bpo-34155: Don't parse domains with two `@` like
418 # `a@malicious.org@important.com`.
419 return EMPTYSTRING
420 elif self.field[self.pos] in self.atomends:
421 break
422 else:
423 sdlist.append(self.getatom())
424 return EMPTYSTRING.join(sdlist)
425
426 def getdelimited(self, beginchar, endchars, allowcomments=True):
427 """Parse a header fragment delimited by special characters.

Callers 2

getrouteaddrMethod · 0.95
getaddrspecMethod · 0.95

Calls 5

getcommentMethod · 0.95
getdomainliteralMethod · 0.95
getatomMethod · 0.95
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected