[Python-checkins] python/dist/src/Lib/encodings idna.py, 1.2, 1.2.12.1

loewis at users.sourceforge.net loewis at users.sourceforge.net
Tue Aug 5 00:20:25 EDT 2003


Update of /cvsroot/python/python/dist/src/Lib/encodings
In directory sc8-pr-cvs1:/tmp/cvs-serv5231/Lib/encodings

Modified Files:
      Tag: release23-maint
	idna.py 
Log Message:
Support trailing dots in DNS names. Fixes #782510.


Index: idna.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/encodings/idna.py,v
retrieving revision 1.2
retrieving revision 1.2.12.1
diff -C2 -d -r1.2 -r1.2.12.1
*** idna.py	24 Apr 2003 16:02:49 -0000	1.2
--- idna.py	5 Aug 2003 06:20:23 -0000	1.2.12.1
***************
*** 151,158 ****
  
          result = []
!         for label in dots.split(input):
              result.append(ToASCII(label))
          # Join with U+002E
!         return ".".join(result), len(input)
  
      def decode(self,input,errors='strict'):
--- 151,164 ----
  
          result = []
!         labels = dots.split(input)
!         if labels and len(labels[-1])==0:
!             trailing_dot = '.'
!             del labels[-1]
!         else:
!             trailing_dot = ''
!         for label in labels:
              result.append(ToASCII(label))
          # Join with U+002E
!         return ".".join(result)+trailing_dot, len(input)
  
      def decode(self,input,errors='strict'):
***************
*** 169,177 ****
              labels = input.split(".")
  
          result = []
          for label in labels:
              result.append(ToUnicode(label))
  
!         return u".".join(result), len(input)
  
  class StreamWriter(Codec,codecs.StreamWriter):
--- 175,189 ----
              labels = input.split(".")
  
+         if labels and len(labels[-1]) == 0:
+             trailing_dot = u'.'
+             del labels[-1]
+         else:
+             trailing_dot = u''
+ 
          result = []
          for label in labels:
              result.append(ToUnicode(label))
  
!         return u".".join(result)+trailing_dot, len(input)
  
  class StreamWriter(Codec,codecs.StreamWriter):





More information about the Python-checkins mailing list