fix(inf-parser): tolerate bare-line sections in real vendor INFs

Real INFs (e.g. Ricoh oemsetup.inf) include [SourceDisksFiles] entries
with bare filename lines (no '='), which strict configparser rejects
with ParsingError, surfacing as a 500 on /drivers/upload.

Pre-process the INF text to rewrite bare lines into synthetic
__bare_N = <line> entries before parsing, and filter those synthetic
keys out of DriverDesc extraction so they cannot leak into driver_names.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-13 11:11:45 +02:00
co-authored by Claude Opus 4.6
parent 37a06dac89
commit 27ddc77ee1
2 changed files with 67 additions and 1 deletions
+37
View File
@@ -279,3 +279,40 @@ def test_empty_models_section():
"""INF with empty Models section returns empty driver_names list."""
result = parse_inf(EMPTY_MODELS_INF, "empty.inf", [])
assert result.driver_names == []
# ---------------------------------------------------------------------------
# parse_inf tolerates bare-line sections (real-world Ricoh oemsetup.inf)
# ---------------------------------------------------------------------------
BARE_LINE_INF = """\
[Version]
Signature="$Windows NT$"
[Manufacturer]
%MFG%=Models,NTamd64
[Models.NTamd64]
%RICOH_DRIVER%=Install,{CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC}
[SourceDisksFiles]
ricu18ui.dll,ricu18ui.dl_
ricu18ui.irj
ricu18ui.rdj
ricu18gl.dll,ricu18gl.dl_
RD01Kd64.dll,RD01Kd64.dl_,,0x00000020
[Strings]
MFG="Ricoh"
RICOH_DRIVER="Ricoh PCL6 Universal"
"""
def test_bare_line_sections_do_not_raise():
"""Real INFs (e.g. Ricoh oemsetup.inf) include [SourceDisksFiles] entries
with bare filename lines and no '=' — parse_inf must not raise and must
still extract DriverDesc from the Models section."""
result = parse_inf(BARE_LINE_INF, "oemsetup.inf", ["oemsetup.inf"])
assert "Ricoh PCL6 Universal" in result.driver_names
# Synthetic __bare_N keys must not leak into driver_names
assert not any(n.startswith("__bare_") for n in result.driver_names)