fix #811 encode redirected url
This commit is contained in:
parent
21997d8096
commit
a570239960
1 changed files with 22 additions and 2 deletions
|
@ -21,6 +21,7 @@ import java.net.URLEncoder;
|
|||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.net.URLUtil;
|
||||
|
@ -41,6 +42,7 @@ import org.lastaflute.web.Execute;
|
|||
import org.lastaflute.web.response.ActionResponse;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.StreamResponse;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -152,13 +154,31 @@ public class GoAction extends FessSearchAction {
|
|||
return redirect(ErrorAction.class);
|
||||
}
|
||||
} else {
|
||||
return HtmlResponse.fromRedirectPathAsIs(targetUrl + hash);
|
||||
return redirect(targetUrl + hash);
|
||||
}
|
||||
} else {
|
||||
return HtmlResponse.fromRedirectPathAsIs(targetUrl + hash);
|
||||
return redirect(targetUrl + hash);
|
||||
}
|
||||
}
|
||||
|
||||
protected ActionResponse redirect(final String url) {
|
||||
final HttpServletRequest request2 = LaRequestUtil.getRequest();
|
||||
final String enc = request2.getCharacterEncoding() == null ? Constants.UTF_8 : request2.getCharacterEncoding();
|
||||
final StringBuilder buf = new StringBuilder(url.length() + 100);
|
||||
for (final char c : url.toCharArray()) {
|
||||
if (CharUtil.isUrlChar(c)) {
|
||||
buf.append(c);
|
||||
} else {
|
||||
try {
|
||||
buf.append(URLEncoder.encode(String.valueOf(c), enc));
|
||||
} catch (final UnsupportedEncodingException e) {
|
||||
buf.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return HtmlResponse.fromRedirectPathAsIs(buf.toString());
|
||||
}
|
||||
|
||||
protected boolean isFileSystemPath(final String url) {
|
||||
return url.startsWith("file:") || url.startsWith("smb:") || url.startsWith("ftp:");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue