Put in check for maximum character size in input strings that can be set with settings.MAX_CHAR_LIMIT.
This commit is contained in:
parent
619a9cee57
commit
760c5b41fc
2 changed files with 18 additions and 1 deletions
|
|
@ -18,9 +18,11 @@ _MOD_IMPORT = None
|
||||||
# throttles
|
# throttles
|
||||||
_MAX_CONNECTION_RATE = float(settings.MAX_CONNECTION_RATE)
|
_MAX_CONNECTION_RATE = float(settings.MAX_CONNECTION_RATE)
|
||||||
_MAX_COMMAND_RATE = float(settings.MAX_COMMAND_RATE)
|
_MAX_COMMAND_RATE = float(settings.MAX_COMMAND_RATE)
|
||||||
|
_MAX_CHAR_LIMIT = settings.MAX_CHAR_LIMIT
|
||||||
|
|
||||||
_MIN_TIME_BETWEEN_CONNECTS = 1.0 / float(settings.MAX_CONNECTION_RATE)
|
_MIN_TIME_BETWEEN_CONNECTS = 1.0 / float(settings.MAX_CONNECTION_RATE)
|
||||||
_ERROR_COMMAND_OVERFLOW = settings.COMMAND_RATE_WARNING
|
_ERROR_COMMAND_OVERFLOW = settings.COMMAND_RATE_WARNING
|
||||||
|
_ERROR_MAX_CHAR = settings.MAX_CHAR_LIMIT_WARNING
|
||||||
|
|
||||||
_CONNECTION_QUEUE = deque()
|
_CONNECTION_QUEUE = deque()
|
||||||
|
|
||||||
|
|
@ -354,7 +356,14 @@ class PortalSessionHandler(SessionHandler):
|
||||||
"""
|
"""
|
||||||
#from evennia.server.profiling.timetrace import timetrace
|
#from evennia.server.profiling.timetrace import timetrace
|
||||||
#text = timetrace(text, "portalsessionhandler.data_in")
|
#text = timetrace(text, "portalsessionhandler.data_in")
|
||||||
|
try:
|
||||||
|
text = kwargs['text']
|
||||||
|
if _MAX_CHAR_LIMIT and len(text) > _MAX_CHAR_LIMIT:
|
||||||
|
if session:
|
||||||
|
self.data_out(session, text=[[_ERROR_MAX_CHAR], {}])
|
||||||
|
return
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
if session:
|
if session:
|
||||||
now = time()
|
now = time()
|
||||||
if self.command_counter > _MAX_COMMAND_RATE:
|
if self.command_counter > _MAX_COMMAND_RATE:
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,14 @@ MAX_CONNECTION_RATE = 2
|
||||||
MAX_COMMAND_RATE = 80
|
MAX_COMMAND_RATE = 80
|
||||||
# The warning to echo back to users if they send commands too fast
|
# The warning to echo back to users if they send commands too fast
|
||||||
COMMAND_RATE_WARNING ="You entered commands too fast. Wait a moment and try again."
|
COMMAND_RATE_WARNING ="You entered commands too fast. Wait a moment and try again."
|
||||||
|
# Determine how large of a string can be sent to the server in number
|
||||||
|
# of characters. If they attempt to enter a string over this character
|
||||||
|
# limit, we stop them and send a message. Set to None by default. To
|
||||||
|
# change it, just set it to a number of characters - ie, 6000 to be
|
||||||
|
# roughly two pages of text.
|
||||||
|
MAX_CHAR_LIMIT = None
|
||||||
|
# The warning to echo back to users if they enter a very large string
|
||||||
|
MAX_CHAR_LIMIT_WARNING="You entered a string that was too large. Please break it up into separate commands."
|
||||||
# If this is true, errors and tracebacks from the engine will be
|
# If this is true, errors and tracebacks from the engine will be
|
||||||
# echoed as text in-game as well as to the log. This can speed up
|
# echoed as text in-game as well as to the log. This can speed up
|
||||||
# debugging. Showing full tracebacks to regular users could be a
|
# debugging. Showing full tracebacks to regular users could be a
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue