Skip to content

Commit c131701

Browse files
committed
Don't crash on flakerefs containing newlines
Fixes NixOS#14311.
1 parent 3f18cad commit c131701

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libflake/flakeref.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
109109

110110
std::smatch match;
111111
auto succeeds = std::regex_match(url, match, pathFlakeRegex);
112-
assert(succeeds);
112+
if (!succeeds)
113+
throw Error("invalid flakeref '%s'", url);
113114
auto path = match[1].str();
114115
auto query = decodeQuery(match[3].str(), /*lenient=*/true);
115116
auto fragment = percentDecode(match[5].str());

0 commit comments

Comments
 (0)