From 06d990510c9a478578b625fd43296ac35f9c07b7 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 7 Mar 2021 11:25:24 +0100 Subject: [PATCH] wpint: More input length validation of addresses --- inema/wpint.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/inema/wpint.py b/inema/wpint.py index 9e1dc5d..70d5040 100644 --- a/inema/wpint.py +++ b/inema/wpint.py @@ -114,10 +114,16 @@ class WarenpostInt(object): sender and recipient.""" def __init__(self, name, addr_lines, city, country_code, postal_code='', state=None, phone=None, fax=None, email=None): - if len(addr_lines) > 3: - raise ValueError('Maximum number of 3 Address Lines supported') if len(name) > 30: raise ValueError('Maximum length of name is 30 chars') + if len(addr_lines) > 3: + raise ValueError('Maximum number of 3 Address Lines supported') + if len(city) > 30: + raise ValueError('Maximum length of city is 30 chars') + if len(country_code) != 2: + raise ValueError('Country must be 2-digit ISO-3166-1 code') + if state and len(state) > 20: + raise ValueError('Maximum length of state is 20 chars') if phone and len(phone) > 15: raise ValueError('Maximum length of phone number is 15 chars') if fax and len(fax) > 15: