|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -107,18 +107,29 @@ protected String determineTargetUrl(HttpServletRequest request, HttpServletRespo
|
107 | 107 | if (isAlwaysUseDefaultTargetUrl()) {
|
108 | 108 | return this.defaultTargetUrl;
|
109 | 109 | }
|
110 |
| - // with or without value the targetUrlParameter take precedence |
111 |
| - if (StringUtils.hasText(this.targetUrlParameter) |
112 |
| - && StringUtils.hasText(request.getParameter(this.targetUrlParameter))) { |
113 |
| - trace("Using url %s from request parameter %s", request.getParameter(this.targetUrlParameter), |
114 |
| - this.targetUrlParameter); |
115 |
| - return request.getParameter(this.targetUrlParameter); |
| 110 | + String targetUrlParameterValue = getTargetUrlParameterValue(request); |
| 111 | + if (StringUtils.hasText(targetUrlParameterValue)) { |
| 112 | + trace("Using url %s from request parameter %s", targetUrlParameterValue, this.targetUrlParameter); |
| 113 | + return targetUrlParameterValue; |
116 | 114 | }
|
117 |
| - if (this.targetUrlParameter == null && this.useReferer) { |
| 115 | + if (this.useReferer) { |
118 | 116 | trace("Using url %s from Referer header", request.getHeader("Referer"));
|
119 | 117 | return request.getHeader("Referer");
|
120 | 118 | }
|
121 |
| - trace("Using default url %s", this.defaultTargetUrl); |
| 119 | + return this.defaultTargetUrl; |
| 120 | + } |
| 121 | + |
| 122 | + private String getTargetUrlParameterValue(HttpServletRequest request) { |
| 123 | + if (this.targetUrlParameter == null) { |
| 124 | + return null; |
| 125 | + } |
| 126 | + String value = request.getParameter(this.targetUrlParameter); |
| 127 | + if (value == null) { |
| 128 | + return null; |
| 129 | + } |
| 130 | + if (StringUtils.hasText(value)) { |
| 131 | + return value; |
| 132 | + } |
122 | 133 | return this.defaultTargetUrl;
|
123 | 134 | }
|
124 | 135 |
|
|
0 commit comments