Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put in check for maximum character size in input strings #1137

Merged
merged 2 commits into from
Dec 13, 2016

Conversation

TehomCD
Copy link
Contributor

@TehomCD TehomCD commented Dec 13, 2016

Brief overview of PR changes/additions

Just an optional setting, MAX_CHAR_LIMIT, that lets you specify the maximum length of any string passed on from the portalsessionhandler to the server, to prevent people from obnoxiously spamming and the like.

Motivation for adding to Evennia

Just a little optional anti-troll protection.

Other info (issues closed, discussion etc)

I made the default None, which leaves it uncapped, so current behavior is unaffected.

# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be a reasonable thing to actually set a sane default max here - it's good for people that don't bother with the settings. People can always up the limit manually later if they think it's limiting. I don't know what the max would be though - it would need to be a value you rarely hit yet not so large you run into slowdowns. 6000 sounds like a lot to me, but maybe it's not ...?

@@ -18,9 +18,11 @@
# throttles
_MAX_CONNECTION_RATE = float(settings.MAX_CONNECTION_RATE)
_MAX_COMMAND_RATE = float(settings.MAX_COMMAND_RATE)
_MAX_CHAR_LIMIT = settings.MAX_CHAR_LIMIT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better convert this to an int() here, so eventual unit errors in the settings file get caught early (doing > operations can have some unexpected results when mixing types).

@TehomCD
Copy link
Contributor Author

TehomCD commented Dec 13, 2016

6000 is just around the edge of the largest things I've seen people write that aren't just trying to mess with people - ascii art for item descriptions, generally speaking. When I start to see clients die is when it's probably like an order of magnitude larger than that, though that's just a ballpark estimate. If you think a smaller value would be more sane as a default, by all means! It's just what I would land on myself.

@Griatch Griatch merged commit b41053d into evennia:master Dec 13, 2016
@TehomCD TehomCD deleted the portal_max_char_limit branch December 13, 2016 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants