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

Check for null and newline bytes in check_user_identity.

This is called in Repo.do_commit and Repo._write_reflog.
Christian Sattler 2 лет назад
Родитель
Сommit
6a8d8b04f6
2 измененных файлов с 8 добавлено и 0 удалено
  1. 2 0
      dulwich/repo.py
  2. 6 0
      dulwich/tests/test_repository.py

+ 2 - 0
dulwich/repo.py

@@ -235,6 +235,8 @@ def check_user_identity(identity):
         raise InvalidUserIdentity(identity) from exc
     if b">" not in snd:
         raise InvalidUserIdentity(identity)
+    if b'\0' in identity or b'\n' in identity:
+        raise InvalidUserIdentity(identity)
 
 
 def parse_graftpoints(

+ 6 - 0
dulwich/tests/test_repository.py

@@ -1487,3 +1487,9 @@ class CheckUserIdentityTests(TestCase):
         self.assertRaises(
             InvalidUserIdentity, check_user_identity, b"Fullname >order<>"
         )
+        self.assertRaises(
+            InvalidUserIdentity, check_user_identity, b'Contains\0null byte <>'
+        )
+        self.assertRaises(
+            InvalidUserIdentity, check_user_identity, b'Contains\nnewline byte <>'
+        )