Skip to content

Commit b181d78

Browse files
committed
fix(param): split params only on \n
str.lines() splits on both \n and \r\n We use \n as a field separator, so \r\n should not separate the fields.
1 parent b9ff40c commit b181d78

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/param.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl str::FromStr for Params {
265265
/// or from an upgrade (when a key is dropped but was used in the past)
266266
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
267267
let mut inner = BTreeMap::new();
268-
let mut lines = s.lines().peekable();
268+
let mut lines = s.split('\n').peekable();
269269

270270
while let Some(line) = lines.next() {
271271
if let [key, value] = line.splitn(2, '=').collect::<Vec<_>>()[..] {
@@ -457,6 +457,7 @@ mod tests {
457457
let mut params = Params::new();
458458
params.set(Param::Height, "foo\nbar=baz\nquux");
459459
params.set(Param::Width, "\n\n\na=\n=");
460+
params.set(Param::WebrtcRoom, "foo\r\nbar\r\n\r\nbaz\r\n");
460461
assert_eq!(params.to_string().parse::<Params>().unwrap(), params);
461462
}
462463

0 commit comments

Comments
 (0)