File 1095-stdlib-fix-normalize-missing-path-crash.patch of Package erlang

From 20029175e9ce6ce49748e146d54c9bb02fe9fb1d Mon Sep 17 00:00:00 2001
From: Jakub Witczak <kuba@erlang.org>
Date: Wed, 2 Oct 2024 18:17:25 +0200
Subject: [PATCH] stdlib: fix normalize missing path crash

---
 lib/stdlib/src/uri_string.erl        | 2 +-
 lib/stdlib/test/uri_string_SUITE.erl | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/stdlib/src/uri_string.erl b/lib/stdlib/src/uri_string.erl
index dbbb835036..6ab5c58cff 100644
--- a/lib/stdlib/src/uri_string.erl
+++ b/lib/stdlib/src/uri_string.erl
@@ -2288,7 +2288,7 @@ to_lower(<<>>, Acc) ->
 %% 6.2.2.3. Path Segment Normalization
 %% 5.2.4.   Remove Dot Segments
 normalize_path_segment(Map) ->
-    Path = maps:get(path, Map, undefined),
+    Path = maps:get(path, Map, <<>>),
     Map#{path => remove_dot_segments(Path)}.
 
 
diff --git a/lib/stdlib/test/uri_string_SUITE.erl b/lib/stdlib/test/uri_string_SUITE.erl
index 6a6bff2688..b1fbb48e57 100644
--- a/lib/stdlib/test/uri_string_SUITE.erl
+++ b/lib/stdlib/test/uri_string_SUITE.erl
@@ -1073,7 +1073,13 @@ normalize_map(_Config) ->
                                host => <<"localhost">>}),
     <<"yeti://localhost">> =
         uri_string:normalize(#{scheme => <<"yeti">>,port => undefined,path => <<>>,
-                               host => <<"localhost">>}).
+                               host => <<"localhost">>}),
+    <<"yeti://localhost">> =
+        uri_string:normalize(#{scheme => <<"yeti">>,port => undefined,
+                               host => <<"localhost">>}),
+    "yeti://localhost" =
+        uri_string:normalize(#{scheme => "yeti",port => undefined,
+                               host => "localhost"}).
 
 normalize_return_map(_Config) ->
     #{scheme := "http",path := "/a/g",host := "localhost-örebro"} =
-- 
2.43.0

openSUSE Build Service is sponsored by