]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
parser: Don't pass a message-id longer than 255 chars to the db
authorStephen Finucane <stephen@that.guru>
Wed, 28 Jun 2017 20:33:20 +0000 (21:33 +0100)
committerStephen Finucane <stephen@that.guru>
Wed, 28 Jun 2017 20:41:28 +0000 (21:41 +0100)
The db limit is 255: we need to make sure we don't pass anything
longer in or it will throw an exception.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
patchwork/parser.py

index 8a07a69822f02d8988005c5dc14bef142c5f6e37..37603f9441502864877e197d51932ef6ba52fcf7 100644 (file)
@@ -225,7 +225,7 @@ def _find_series_by_references(project, mail):
     for ref in refs:
         try:
             return SeriesReference.objects.get(
-                msgid=ref, series__project=project).series
+                msgid=ref[:255], series__project=project).series
         except SeriesReference.DoesNotExist:
             continue
 
@@ -548,6 +548,7 @@ def find_comment_content(mail):
 
 def find_submission_for_comment(project, refs):
     for ref in refs:
+        ref = ref[:255]
         # first, check for a direct reply
         try:
             submission = Submission.objects.get(project=project, msgid=ref)
@@ -924,6 +925,7 @@ def parse_mail(mail, list_id=None):
     msgid = clean_header(mail.get('Message-Id'))
     if not msgid:
         raise ValueError("Broken 'Message-Id' header")
+    msgid = msgid[:255]
 
     author = find_author(mail)
     subject = mail.get('Subject')
@@ -985,6 +987,7 @@ def parse_mail(mail, list_id=None):
             # be possible to identify the relationship between patches
             # as the earlier patch does not reference the later one.
             for ref in refs + [msgid]:
+                ref = ref[:255]
                 # we don't want duplicates
                 try:
                     # we could have a ref to a previous series. (For