comparison sat/plugins/plugin_xep_0059.py @ 2763:c4190d5340ab

XEP-0059: max value check: check that max is not negative, this is to spot the accidental use of C.NO_LIMIT for max
author Goffi <goffi@goffi.org>
date Fri, 11 Jan 2019 09:48:19 +0100
parents e3f6de6ce320
children 003b8b4b56a7
comparison
equal deleted inserted replaced
2762:5a51c7fc74a5 2763:c4190d5340ab
59 59
60 @param extra(dict): data for parse 60 @param extra(dict): data for parse
61 @return (rsm.RSMRequest, None): request with parsed arguments 61 @return (rsm.RSMRequest, None): request with parsed arguments
62 or None if no RSM arguments have been found 62 or None if no RSM arguments have been found
63 """ 63 """
64 if int(extra.get(RSM_PREFIX + u'max', 0)) < 0:
65 raise ValueError(_(u"rsm_max can't be negative"))
66
64 rsm_args = {} 67 rsm_args = {}
65 for arg in (u"max", u"after", u"before", u"index"): 68 for arg in (u"max", u"after", u"before", u"index"):
66 try: 69 try:
67 argname = "max_" if arg == u"max" else arg 70 argname = "max_" if arg == u"max" else arg
68 rsm_args[argname] = extra.pop(RSM_PREFIX + arg) 71 rsm_args[argname] = extra.pop(RSM_PREFIX + arg)