From: Zooko O'Whielacronx Date: Thu, 3 Jan 2008 23:44:46 +0000 (-0700) Subject: add regexes to idlib to match certain kinds of base32-encoded values X-Git-Tag: allmydata-tahoe-0.7.0~45 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/file/URI:LIT:krugkidfnzsc4/(%5B%5E?a=commitdiff_plain;h=46db7cf1dc50f59a9ab01f87fa6530729370fd1f;p=tahoe-lafs%2Ftahoe-lafs.git add regexes to idlib to match certain kinds of base32-encoded values --- diff --git a/src/allmydata/util/idlib.py b/src/allmydata/util/idlib.py index 8432f580..202f1c27 100644 --- a/src/allmydata/util/idlib.py +++ b/src/allmydata/util/idlib.py @@ -34,6 +34,17 @@ def get_trailing_chars_without_lsbs(N): d = {} return ''.join(_get_trailing_chars_without_lsbs(N, d=d)) +ZBASE32CHAR = '['+get_trailing_chars_without_lsbs(0)+']' +ZBASE32CHAR_4bits = '['+get_trailing_chars_without_lsbs(1)+']' +ZBASE32CHAR_3bits = '['+get_trailing_chars_without_lsbs(2)+']' +ZBASE32CHAR_2bits = '['+get_trailing_chars_without_lsbs(3)+']' +ZBASE32CHAR_1bits = '['+get_trailing_chars_without_lsbs(4)+']' +ZBASE32STR_1byte = ZBASE32CHAR+ZBASE32CHAR_3bits +ZBASE32STR_2bytes = ZBASE32CHAR+'{3}'+ZBASE32CHAR_1bits +ZBASE32STR_3bytes = ZBASE32CHAR+'{4}'+ZBASE32CHAR_4bits +ZBASE32STR_4bytes = ZBASE32CHAR+'{6}'+ZBASE32CHAR_2bits +ZBASE32STR_anybytes = '((?:%s{8})*' % (ZBASE32CHAR,) + "(?:|%s|%s|%s|%s))" % (ZBASE32STR_1byte, ZBASE32STR_2bytes, ZBASE32STR_3bytes, ZBASE32STR_4bytes) + def b2a(os): """ @param os the data to be encoded (a string)