Просмотр исходного кода

support \n and \r\n line endings in ReadMessages

David Kalnischkies лет назад: 13
Родитель
Сommit
7090386528
2 измененных файлов с 4 добавлено и 2 удалено
  1. 3 2
      apt-pkg/contrib/strutl.cc
  2. 1 0
      debian/changelog

+ 3 - 2
apt-pkg/contrib/strutl.cc

@@ -758,7 +758,8 @@ bool ReadMessages(int Fd, vector<string> &List)
       // Look for the end of the message
       // Look for the end of the message
       for (char *I = Buffer; I + 1 < End; I++)
       for (char *I = Buffer; I + 1 < End; I++)
       {
       {
-	 if (I[0] != '\n' || I[1] != '\n')
+	 if (I[1] != '\n' ||
+	       (I[0] != '\n' && strncmp(I, "\r\n\r\n", 4) != 0))
 	    continue;
 	    continue;
 	 
 	 
 	 // Pull the message out
 	 // Pull the message out
@@ -766,7 +767,7 @@ bool ReadMessages(int Fd, vector<string> &List)
 	 PartialMessage += Message;
 	 PartialMessage += Message;
 
 
 	 // Fix up the buffer
 	 // Fix up the buffer
-	 for (; I < End && *I == '\n'; I++);
+	 for (; I < End && (*I == '\n' || *I == '\r'); ++I);
 	 End -= I-Buffer;	 
 	 End -= I-Buffer;	 
 	 memmove(Buffer,I,End-Buffer);
 	 memmove(Buffer,I,End-Buffer);
 	 I = Buffer;
 	 I = Buffer;

+ 1 - 0
debian/changelog

@@ -18,6 +18,7 @@ apt (0.9.8.3) UNRELEASED; urgency=low
   * fix file location for configure-index.gz in apt.conf(5) (Closes: #711921)
   * fix file location for configure-index.gz in apt.conf(5) (Closes: #711921)
   * handle missing "Description" in apt-cache show (Closes: #712435)
   * handle missing "Description" in apt-cache show (Closes: #712435)
   * try defaults if auto-detection failed in apt-cdrom (Closes: #712433)
   * try defaults if auto-detection failed in apt-cdrom (Closes: #712433)
+  * support \n and \r\n line endings in ReadMessages
 
 
  -- David Kalnischkies <kalnischkies@gmail.com>  Sun, 09 Jun 2013 15:06:24 +0200
  -- David Kalnischkies <kalnischkies@gmail.com>  Sun, 09 Jun 2013 15:06:24 +0200