@@ -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 == Prefix ->
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,12 @@ 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 , Mode }, N )
2733+ when is_record (url , URL )
2734+ andalso
2735+ % % Stop redirect loops
2736+ ServerPath == Prefix ->
27302737 % % Here Code is 3xx
27312738 ? Debug (" in redir ~p " , [Code ]),
27322739 H = get (outh ),
@@ -2736,8 +2743,8 @@ deliver_redirect_map(CliSock, Req, Arg,
27362743 end ,
27372744 LocPath = if
27382745 Mode == append ->
2739- Path1 = filename :join ([URL # url .path ++ Arg # arg . server_path ]) ++
2740- preserve_trailing_slash (Arg # arg . server_path ),
2746+ Path1 = filename :join ([URL # url .path ++ ServerPath ]) ++
2747+ preserve_trailing_slash (ServerPath ),
27412748 yaws_api :format_partial_url (
27422749 URL # url {path = Path1 ,querypart = QueryData }, get (sc )
27432750 );
0 commit comments