From e070530907b29e917d319c51c20df57674495fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Menou?= Date: Tue, 14 Jan 2025 18:30:48 +0100 Subject: [PATCH] Resist to unescaped characters in gtfs --- apps/transport/lib/registry/gtfs.ex | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/transport/lib/registry/gtfs.ex b/apps/transport/lib/registry/gtfs.ex index 7f558651ff..b3f16f0859 100644 --- a/apps/transport/lib/registry/gtfs.ex +++ b/apps/transport/lib/registry/gtfs.ex @@ -24,11 +24,18 @@ defmodule Transport.Registry.GTFS do {:ok, content} -> Logger.debug("Valid Zip archive") - content - |> Utils.to_stream_of_maps() - |> Stream.flat_map(&handle_stop(data_source_id, &1)) - |> Enum.to_list() - |> Result.ok() + try do + content + |> Utils.to_stream_of_maps() + |> Stream.flat_map(&handle_stop(data_source_id, &1)) + |> Enum.to_list() + |> Result.ok() + rescue + e in NimbleCSV.ParseError -> + e + |> Exception.message() + |> Result.error() + end end end