Commit 2cc18228 authored by Liang Ding's avatar Liang Ding

🎨 Fix #12551

parent e1e2f7e7
......@@ -43,12 +43,13 @@ import org.json.JSONObject;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
/**
* Preference console request processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.13, Sep 25, 2018
* @version 1.2.0.14, Oct 17, 2018
* @since 0.4.0
*/
@RequestProcessor
......@@ -446,19 +447,20 @@ public class PreferenceConsole {
final HTTPRequestContext context, final JSONObject requestJSONObject) {
final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer);
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
try {
final String accessKey = requestJSONObject.optString(Option.ID_C_QINIU_ACCESS_KEY).trim();
final String secretKey = requestJSONObject.optString(Option.ID_C_QINIU_SECRET_KEY).trim();
String domain = requestJSONObject.optString(Option.ID_C_QINIU_DOMAIN).trim();
domain = StringUtils.lowerCase(domain);
final String bucket = requestJSONObject.optString(Option.ID_C_QINIU_BUCKET).trim();
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
if (StringUtils.isNotBlank(domain) && !StringUtils.endsWith(domain, "/")) {
domain += "/";
}
if (StringUtils.isNotBlank(domain) && !StringUtils.startsWithAny(domain, new String[]{"http", "https"})) {
domain = "http://" + domain;
}
final JSONObject accessKeyOpt = new JSONObject();
accessKeyOpt.put(Keys.OBJECT_ID, Option.ID_C_QINIU_ACCESS_KEY);
......@@ -484,6 +486,9 @@ public class PreferenceConsole {
ret.put(Keys.STATUS_CODE, true);
ret.put(Keys.MSG, langPropsService.get("updateSuccLabel"));
if (isQiniuTestDomain(domain)) {
ret.put(Keys.MSG, langPropsService.get("donotUseQiniuTestDoaminLabel"));
}
} catch (final ServiceException e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
......@@ -602,4 +607,15 @@ public class PreferenceConsole {
return false;
}
}
/**
* Checks whether the specified domain is a qiniu test domain.
*
* @param domain the specified domain
* @return {@code true} if it is, returns {@code false} otherwise
*/
private boolean isQiniuTestDomain(final String domain) {
return Arrays.asList("clouddn.com", "qiniucdn.com", "qiniudn.com", "qnssl.com", "qbox.me").stream().
anyMatch(testDomain -> StringUtils.containsIgnoreCase(domain, testDomain));
}
}
......@@ -18,12 +18,13 @@
#
# Description: Solo language configurations(en_US).
# Version: 2.23.0.0, Sep 21, 2018
# Version: 2.24.0.0, Oct 17, 2018
# Author: Liang Ding
# Author: Liyuan Li
# Author: Dongxu Wang
#
donotUseQiniuTestDoaminLabel=Do not use Qiniu test domain in production env, see <a href="https://developer.qiniu.com/fusion/kb/1319/test-domain-access-restriction-rules" target="_blank">\u4E03\u725B\u4E91\u6D4B\u8BD5\u57DF\u540D\u4F7F\u7528\u89C4\u8303</a> for more details.
cntLabel=
reply1Label=Reply
nextArticleLabel=Next Article
......
......@@ -18,12 +18,13 @@
#
# Description: Solo default language configurations(zh_CN).
# Version: 2.23.0.0, Sep 21, 2018
# Version: 2.24.0.0, Oct 17, 2018
# Author: Liang Ding
# Author: Liyuan Li
# Author: Dongxu Wang
#
donotUseQiniuTestDoaminLabel=\u751F\u4EA7\u73AF\u5883\u8BF7\u52FF\u4F7F\u7528\u4E03\u725B\u4E91\u6D4B\u8BD5\u57DF\u540D\uFF0C\u7EC6\u8282\u8BF7\u6D4F\u89C8<a href="https://developer.qiniu.com/fusion/kb/1319/test-domain-access-restriction-rules" target="_blank">\u4E03\u725B\u4E91\u6D4B\u8BD5\u57DF\u540D\u4F7F\u7528\u89C4\u8303</a>
cntLabel=\u4E2A
reply1Label=\u56DE\u590D
nextArticleLabel=\u4E0B\u4E00\u7BC7
......
......@@ -3124,7 +3124,7 @@ admin.register["link-list"] = {
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.1.10, Nov 15, 2016
* @version 1.2.1.11, Oct 17, 2018
*/
/* preference 相关操作 */
......@@ -3384,11 +3384,7 @@ admin.preference = {
cache: false,
data: JSON.stringify(requestJSONObject),
success: function (result, textStatus) {
if (result.sc) {
window.location.reload();
}
$("#tipMsg").text(result.msg);
$("#tipMsg").html(result.msg);
$("#loadMsg").text("");
}
});
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -20,7 +20,7 @@
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.1.10, Nov 15, 2016
* @version 1.2.1.11, Oct 17, 2018
*/
/* preference 相关操作 */
......@@ -280,11 +280,7 @@ admin.preference = {
cache: false,
data: JSON.stringify(requestJSONObject),
success: function (result, textStatus) {
if (result.sc) {
window.location.reload();
}
$("#tipMsg").text(result.msg);
$("#tipMsg").html(result.msg);
$("#loadMsg").text("");
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment