mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 07:26:15 +01:00
gbase64: Fix documentation for line wrapping lengths
The implementation has always wrapped at 76 characters, rather than 72,
ever since it was introduced in commit 5cf8f1d4a8
in 2006. At this
stage, it’s probably best to fix the documentation rather than the
implementation.
The likely bug in the implementation is the comparison
```
(++already) >= 19
```
19 × 4 = 76, so it seems like an off-by-one error in the comparison.
What was actually wanted was 18 × 4 = 72.
Thanks to Simon McVittie for the investigation and diagnosis.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Fixes: #1997
This commit is contained in:
parent
9ed4b813e5
commit
8d3c502074
@ -76,10 +76,10 @@ static const char base64_alphabet[] =
|
||||
* be written to it. Due to the way base64 encodes you will need
|
||||
* at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
|
||||
* non-zero state). If you enable line-breaking you will need at least:
|
||||
* ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
|
||||
* ((@len / 3 + 1) * 4 + 4) / 76 + 1 bytes of extra space.
|
||||
*
|
||||
* @break_lines is typically used when putting base64-encoded data in emails.
|
||||
* It breaks the lines at 72 columns instead of putting all of the text on
|
||||
* It breaks the lines at 76 columns instead of putting all of the text on
|
||||
* the same line. This avoids problems with long lines in the email system.
|
||||
* Note however that it breaks the lines with `LF` characters, not
|
||||
* `CR LF` sequences, so the result cannot be passed directly to SMTP
|
||||
|
Loading…
Reference in New Issue
Block a user