Skip to content

Commit a0660fe

Browse files
committed
Allow empty-valued commit headers in more places
I just fixed a problem where a `gpgsig ` header line in a historical commit in the git.git repository itself was mistakenly causing a parse error. The culprit was, of course, that the header value is empty, and the existing code expected the value _not_ to be empty. Handle similar issues in other locations, too. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent a86f67b commit a0660fe

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

gix-object/src/commit/decode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn commit<'a, E: ParserError<&'a [u8]> + AddContext<&'a [u8], StrContext>>(
4444
.context(StrContext::Expected("author <signature>".into())),
4545
(|i: &mut _| parse::header_field(i, b"committer", parse::signature))
4646
.context(StrContext::Expected("committer <signature>".into())),
47-
opt(|i: &mut _| parse::header_field(i, b"encoding", take_till(1.., NL)))
47+
opt(|i: &mut _| parse::header_field(i, b"encoding", take_till(0.., NL)))
4848
.context(StrContext::Expected("encoding <encoding>".into())),
4949
repeat(
5050
0..,

gix-object/src/commit/ref_iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl<'a> CommitRefIter<'a> {
214214
}
215215
}
216216
Encoding => {
217-
let encoding = opt(|i: &mut _| parse::header_field(i, b"encoding", take_till(1.., NL)))
217+
let encoding = opt(|i: &mut _| parse::header_field(i, b"encoding", take_till(0.., NL)))
218218
.context(StrContext::Expected("encoding <encoding>".into()))
219219
.parse_next(input)?;
220220
*state = State::ExtraHeaders;
@@ -227,7 +227,7 @@ impl<'a> CommitRefIter<'a> {
227227
let extra_header = opt(alt((
228228
|i: &mut _| parse::any_header_field_multi_line(i).map(|(k, o)| (k.as_bstr(), Cow::Owned(o))),
229229
|i: &mut _| {
230-
parse::any_header_field(i, take_till(1.., NL))
230+
parse::any_header_field(i, take_till(0.., NL))
231231
.map(|(k, o)| (k.as_bstr(), Cow::Borrowed(o.as_bstr())))
232232
},
233233
)))

gix-object/src/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(crate) fn any_header_field_multi_line<'a, E: ParserError<&'a [u8]> + AddCont
1818
(
1919
terminated(take_till(1.., SPACE_OR_NL), SPACE),
2020
(
21-
take_till(1.., NL),
21+
take_till(0.., NL),
2222
NL,
2323
repeat(1.., terminated((SPACE, take_until(0.., NL)), NL)).map(|()| ()),
2424
)

0 commit comments

Comments
 (0)