Skip to content

Commit

Permalink
Don't crash kvs that can't be parsed.
Browse files Browse the repository at this point in the history
This only prevents crashing. It doesn't actually
properly parse the message causing the crash in #15
  • Loading branch information
ConnorRigby committed Oct 31, 2018
1 parent 140e944 commit 9cf1b1d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/nerves_wpa_supplicant/messages.ex
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,14 @@ defmodule Nerves.WpaSupplicant.Messages do
resp
|> String.split("\n", trim: true)
|> List.foldl(%{}, fn pair, acc ->
[key, value] = String.split(pair, "=")
Map.put(acc, String.to_atom(key), kv_value(String.trim_trailing(value)))
case String.split(pair, "=") do
[key, value] ->
acc
|> Map.put(String.to_atom(key), kv_value(String.trim_trailing(value)))

_ ->
acc
end
end)
end

Expand Down

0 comments on commit 9cf1b1d

Please sign in to comment.