i2psnark: Prevent commenting without comment name (ticket #2138)

Trim name
This commit is contained in:
zzz
2018-01-24 15:35:30 +00:00
parent 2df32aa8e5
commit d364bba4c7
4 changed files with 42 additions and 35 deletions

View File

@@ -1264,13 +1264,13 @@ public class SnarkManager implements CompleteListener, ClientApp {
if (commentName == null) {
commentName = "";
} else {
commentName = commentName.replaceAll("[\n\r<>#;]", "");
commentName = commentName.trim().replaceAll("[\n\r<>#;]", "");
if (commentName.length() > Comment.MAX_NAME_LEN)
commentName = commentName.substring(0, Comment.MAX_NAME_LEN);
}
if (!_util.getCommentsName().equals(commentName)) {
_config.setProperty(PROP_COMMENTS_NAME, commentName);
addMessage(_t("Comments name set to {0}.", commentName));
addMessage(_t("Comments name set to {0}.", '"' + commentName + '"'));
_util.setCommentsName(commentName);
changed = true;
}