Skip to contentSkip to conversation

Allow whitespace before a trailer

PATCH In review Rob Herring 3 participants 4 messages Dec 14, 2021 – Feb 1, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow whitespace before a trailer

Currently, b4 fails to find and add trailers with leading whitespace. Let's be a bit more forgiving and allow for that case.

Cc Greg Kroah-Hartman <[email protected]>

---
This thread exhibits the problem:
https://lore.kernel.org/r/20211206174113.2295616-1-robh%40kernel.org

Note that patchwork also fails on this. Between fixing b4 or Greg, I went with b4. :)

---
 b4/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
b4/__init__.py +1 -1
index 11c287eb3433..a4add56c5f80 100644
@@ -1397,7 +1397,7 @@ class LoreMessage:
         was_trailer = False
         for line in body.split('\n'):
             line = line.strip('\r')
-            matches = re.search(r'^(\w\S+):\s+(\S.*)', line, flags=re.I)
+            matches = re.search(r'^\s?(\w\S+):\s+(\S.*)', line, flags=re.I)
             if matches:
                 groups = list(matches.groups())
                 # We only accept headers if we haven't seen any non-trailer lines
Signature · 1 line
2.32.0
Acked-by on v1 1/1
#1 lore raw
Quoted 31 lines · Rob Herring

Currently, b4 fails to find and add trailers with leading whitespace. Let's be a bit more forgiving and allow for that case.

Cc Greg Kroah-Hartman <[email protected]>

---
This thread exhibits the problem:
https://lore.kernel.org/r/20211206174113.2295616-1-robh%40kernel.org

Note that patchwork also fails on this. Between fixing b4 or Greg, I went with b4. :)

---
 b4/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
b4/__init__.py +1 -1
index 11c287eb3433..a4add56c5f80 100644
@@ -1397,7 +1397,7 @@ class LoreMessage:
         was_trailer = False
         for line in body.split('\n'):
             line = line.strip('\r')
-            matches = re.search(r'^(\w\S+):\s+(\S.*)', line, flags=re.I)
+            matches = re.search(r'^\s?(\w\S+):\s+(\S.*)', line, flags=re.I)
             if matches:
                 groups = list(matches.groups())
                 # We only accept headers if we haven't seen any non-trailer lines
Signature · 1 line
2.32.0

Hah, sorry about that, I assumed that b4 was picking these up properly, my fault.

#2 lore raw
In reply to Rob Herring
Quoted 4 lines · Rob Herring

Currently, b4 fails to find and add trailers with leading whitespace. Let's be a bit more forgiving and allow for that case.

Quoted 8 lines
Cc Greg Kroah-Hartman <[email protected]>

---
This thread exhibits the problem:
https://lore.kernel.org/r/20211206174113.2295616-1-robh%40kernel.org

Note that patchwork also fails on this. Between fixing b4 or Greg, I went with b4. :)

ping!

Quoted 21 lines
---
 b4/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
b4/__init__.py +1 -2
index 11c287eb3433..a4add56c5f80 100644
@@ -1397,7 +1397,7 @@ class LoreMessage:
         was_trailer = False
         for line in body.split('\n'):
             line = line.strip('\r')
-            matches = re.search(r'^(\w\S+):\s+(\S.*)', line, flags=re.I)
+            matches = re.search(r'^\s?(\w\S+):\s+(\S.*)', line, flags=re.I)
             if matches:
                 groups = list(matches.groups())
                 # We only accept headers if we haven't seen any non-trailer lines
--

2.32.0

#3 lore raw
In reply to Rob Herring
Quoted 2 lines · Rob Herring

Currently, b4 fails to find and add trailers with leading whitespace. Let's be a bit more forgiving and allow for that case.

Okay, I think this is fairly safe and hopefully won't result in more false-positives.

Quoted 18 lines
Cc Greg Kroah-Hartman <[email protected]>

---
This thread exhibits the problem:
https://lore.kernel.org/r/20211206174113.2295616-1-robh%40kernel.org

Note that patchwork also fails on this. Between fixing b4 or Greg, I went with b4. :)

---
 b4/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
b4/__init__.py +0 -0
index 11c287eb3433..a4add56c5f80 100644

b4/__init__.py class LoreMessage: · line 1400

Quoted 5 lines
b4/__init__.py +1 -1
@@ -1397,7 +1397,7 @@ class LoreMessage:
         was_trailer = False
         for line in body.split('\n'):
             line = line.strip('\r')
-            matches = re.search(r'^(\w\S+):\s+(\S.*)', line, flags=re.I)
+            matches = re.search(r'^\s?(\w\S+):\s+(\S.*)', line, flags=re.I)

I used a \s* instead, since there may be more than a single whitespace character. It's in master and stable-0.8.y.

b4/__init__.py class LoreMessage: · line 1403

Quoted 3 lines
b4/__init__.py +0 -0
             if matches:
                 groups = list(matches.groups())
                 # We only accept headers if we haven't seen any non-trailer lines

Thanks,
-K