@@ -2704,14 +2704,17 @@ deliver_redirect_map(CliSock, Req, Arg,
27042704 % % Here Code is 1xx, 2xx, 4xx or 5xx
27052705 ? Debug (" in redir ~p " , [Code ]),
27062706 deliver_xxx (CliSock , Req , Arg , Code );
2707- deliver_redirect_map (_CliSock , _Req , Arg ,
2708- {_Prefix , Code , Path , Mode }, N ) when is_list (Path ) ->
2707+ deliver_redirect_map (_CliSock , _Req , # arg {server_path = ServerPath } = Arg ,
2708+ {_Prefix , Code , Path , Mode }, N )
2709+ when is_list (Path ) andalso
2710+ % % Stop redirect loops
2711+ ServerPath /= Path ->
27092712 % % Here Code is 1xx, 2xx, 4xx or 5xx
27102713 ? Debug (" in redir ~p " , [Code ]),
27112714 Path1 = if
27122715 Mode == append ->
2713- filename :join ([Path ++ Arg # arg . server_path ]) ++
2714- preserve_trailing_slash (Arg # arg . server_path );
2716+ filename :join ([Path ++ ServerPath ]) ++
2717+ preserve_trailing_slash (ServerPath );
27152718 true -> % % noappend
27162719 Path
27172720 end ,
@@ -2725,8 +2728,10 @@ deliver_redirect_map(_CliSock, _Req, Arg,
27252728 put (yaws_arg , Arg ),
27262729 put (client_data_pos , N ),
27272730 {page , {[{status , Code }], Page }};
2728- deliver_redirect_map (CliSock , Req , Arg ,
2729- {_Prefix , Code , URL , Mode }, N ) when is_record (URL , url ) ->
2731+ deliver_redirect_map (CliSock , Req , # arg {server_path = ServerPath } = Arg ,
2732+ {_Prefix , Code , # url {path = Path } = URL , Mode }, N )
2733+ when % % Stop redirect loops
2734+ ServerPath /= Path ->
27302735 % % Here Code is 3xx
27312736 ? Debug (" in redir ~p " , [Code ]),
27322737 H = get (outh ),
@@ -2736,8 +2741,8 @@ deliver_redirect_map(CliSock, Req, Arg,
27362741 end ,
27372742 LocPath = if
27382743 Mode == append ->
2739- Path1 = filename :join ([URL # url . path ++ Arg # arg . server_path ]) ++
2740- preserve_trailing_slash (Arg # arg . server_path ),
2744+ Path1 = filename :join ([Path ++ ServerPath ]) ++
2745+ preserve_trailing_slash (ServerPath ),
27412746 yaws_api :format_partial_url (
27422747 URL # url {path = Path1 ,querypart = QueryData }, get (sc )
27432748 );
0 commit comments