Streams: Disallow certain markdown characters in stream names.

This commit is contained in:
Rhea Parekh
2017-11-25 14:24:31 +05:30
committed by showell
parent 8ed7f73199
commit dd1b14378b
5 changed files with 43 additions and 0 deletions

View File

@@ -33,6 +33,11 @@ var stream_name_error = (function () {
$("#stream_name_error").show();
};
self.report_invalid_chars = function () {
$("#stream_name_error").text(i18n.t("Stream names cannot contain #, *, `, or @."));
$("#stream_name_error").show();
};
self.select = function () {
$("#create_stream_name").focus().select();
};
@@ -66,6 +71,13 @@ var stream_name_error = (function () {
return false;
}
// Keep characters in sync with Stream.NAME_INVALID_CHARS
if (/[#*`@]/.test(stream_name)) {
self.report_invalid_chars();
self.select();
return false;
}
// If we got this far, then we think we have a new unique stream
// name, so we'll submit to the server. (It's still plausible,
// however, that there's some invite-only stream that we don't