The attached patch fixes:

- the test failure caused by diff not exiting '2' on binary files
  anymore (the test was too eager, no other part of bzr relies on this
  behavior), 

- http basic auth was broken when the base64 encoding for the auth
  header become too long.

The former being encountered while fixing the later.

Tested locally with

autopkgtest .// -U -- lxd autopkgtest/debian/sid/amd64


Pushed to
https://anonscm.debian.org/bzr/pkg-bazaar/bzr/2.7/

Thanks in advance,

       Vincent

=== modified file 'debian/changelog'
--- debian/changelog	2016-07-02 16:18:18 +0000
+++ debian/changelog	2016-09-11 16:43:13 +0000
@@ -1,3 +1,14 @@
+bzr (2.7.0+bzr6619-2) unstable; urgency=medium
+
+  * Add 18_diff_binaries: With diffutils > 3.5, diff stop exiting with '2'
+    on binary files. LP: #1622039
+    Closes: #837268
+
+  * Add 19_fix_long_creds: Fix http Basic auth with credentials longer
+    than ~57 characters. LP: #1606203
+
+ -- Vincent Ladeuil <v.ladeuil...@free.fr>  Fri, 09 Sep 2016 16:00:49 +0200
+
 bzr (2.7.0+bzr6619-1) unstable; urgency=medium
 
   * Bump standards version to 3.9.8 (no changes).

=== added file 'debian/patches/18_diff_binaries'
--- debian/patches/18_diff_binaries	1970-01-01 00:00:00 +0000
+++ debian/patches/18_diff_binaries	2016-09-11 16:39:56 +0000
@@ -0,0 +1,17 @@
+Description: diff doesn't exit with 2 anymore on binary files.
+Author: Vincent Ladeuil <v.ladeuil...@free.fr>
+
+
+=== modified file 'bzrlib/tests/test_diff.py'
+--- unstable.orig/bzrlib/tests/test_diff.py	2016-02-01 18:06:32 +0000
++++ unstable/bzrlib/tests/test_diff.py	2016-09-11 16:32:54 +0000
+@@ -313,8 +313,6 @@
+         pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+                                      stdin=subprocess.PIPE)
+         out, err = pipe.communicate()
+-        # Diff returns '2' on Binary files.
+-        self.assertEqual(2, pipe.returncode)
+         # We should output whatever diff tells us, plus a trailing newline
+         self.assertEqual(out.splitlines(True) + ['\n'], lines)
+ 
+

=== added file 'debian/patches/19_fix_long_creds'
--- debian/patches/19_fix_long_creds	1970-01-01 00:00:00 +0000
+++ debian/patches/19_fix_long_creds	2016-09-09 14:03:49 +0000
@@ -0,0 +1,49 @@
+Description: http Basic auth was broken
+ When a long (>57) user/pass combination was used, a spurious '\n' ended up in the header value, crashing httplib.
+.
+Author: Vincent Ladeuil <v.ladeuil...@free.fr>
+
+
+
+=== modified file 'bzrlib/tests/test_http.py'
+--- unstable.orig/bzrlib/tests/test_http.py	2016-02-01 18:06:32 +0000
++++ unstable/bzrlib/tests/test_http.py	2016-09-09 12:57:44 +0000
+@@ -260,6 +260,16 @@
+         self.assertEqual('basic', scheme)
+         self.assertEqual('realm="Thou should not pass"', remainder)
+ 
++    def test_build_basic_header_with_long_creds(self):
++        handler = _urllib2_wrappers.BasicAuthHandler()
++        user = 'user' * 10  # length 40
++        password = 'password' * 5  # length 40
++        header = handler.build_auth_header(
++            dict(user=user, password=password), None)
++        # https://bugs.launchpad.net/bzr/+bug/1606203 was caused by incorrectly
++        # creating a header value with an embedded '\n'
++        self.assertFalse('\n' in header)
++
+     def test_basic_extract_realm(self):
+         scheme, remainder = self.parse_header(
+             'Basic realm="Thou should not pass"',
+
+=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
+--- unstable.orig/bzrlib/transport/http/_urllib2_wrappers.py	2016-01-31 12:55:31 +0000
++++ unstable/bzrlib/transport/http/_urllib2_wrappers.py	2016-09-09 12:58:12 +0000
+@@ -48,6 +48,7 @@
+ # actual code more or less do that, tests should be written to
+ # ensure that.
+ 
++import base64
+ import errno
+ import httplib
+ import os
+@@ -1491,7 +1492,7 @@
+ 
+     def build_auth_header(self, auth, request):
+         raw = '%s:%s' % (auth['user'], auth['password'])
+-        auth_header = 'Basic ' + raw.encode('base64').strip()
++        auth_header = 'Basic ' + base64.b64encode(raw)
+         return auth_header
+ 
+     def extract_realm(self, header_value):
+

=== modified file 'debian/patches/series'
--- debian/patches/series	2016-07-02 16:15:17 +0000
+++ debian/patches/series	2016-09-11 16:38:05 +0000
@@ -5,3 +5,5 @@
 15_autodoc_source_epoch
 16_paramiko_compat
 17_reproducible_makefile
+18_diff_binaries
+19_fix_long_creds

Reply via email to