Commit Graph
3 Commits
Author SHA1 Message Date
dualfroz fd69f1aadd fix(strutil): clamp Substr stop index to avoid out-of-range panic
Substr panicked with a slice-bounds error when a negative length trimmed
more runes than remained after pos, because stopIdx (strLn + length) could
fall before pos. Clamp stopIdx to pos so an over-long negative trim returns
an empty string, matching the existing pos >= strLn guard.
2026-09-06 00:44:31 +02:00
dualfroz e2e5b5495f fix(strutil): keep center-aligned Resize within the requested length
The center branch of resize() added the odd-padding space whenever the
input was non-empty, because the parity check omitted the source length
(wantLen - padLn*2 instead of wantLen - sLen - padLn*2). This made Resize,
Align and their utf8 variants overflow wantLen by one for every non-empty
string with an even amount of padding. Subtract sLen so the extra space is
only added when the total padding is actually odd.
2026-09-04 09:07:10 +02:00
dualfroz d6c91f3cdd fix(strutil): return zero digit instead of empty string in base conversion
BaseConvIntByTpl returned an empty string for the value zero because its
loop condition (dec > 0) was never entered. This affected BaseConv,
Base10Conv and BaseConvInt for bases above 62, and was inconsistent with
BaseConvInt for smaller bases which correctly returned "0" via strconv.

Emit the zero digit of the target base for a zero input and guard against
an empty template.
2026-09-04 09:00:39 +02:00