From f1bfb0a9a057aab754b93dab32e0f442e6c6d474 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 26 Feb 2020 16:46:41 +0200 Subject: [PATCH] Model uid validator: fix off-by-1 error with the uid. 256bit is actually 43 base64 chars, not 44. --- .../migrations/0016_auto_20200226_1446.py | 29 +++++++++++++++++++ django_etesync/models.py | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 django_etesync/migrations/0016_auto_20200226_1446.py diff --git a/django_etesync/migrations/0016_auto_20200226_1446.py b/django_etesync/migrations/0016_auto_20200226_1446.py new file mode 100644 index 0000000..2929cbf --- /dev/null +++ b/django_etesync/migrations/0016_auto_20200226_1446.py @@ -0,0 +1,29 @@ +# Generated by Django 3.0.3 on 2020-02-26 14:46 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('django_etesync', '0015_auto_20200226_1349'), + ] + + operations = [ + migrations.AlterField( + model_name='collection', + name='uid', + field=models.CharField(db_index=True, max_length=44, validators=[django.core.validators.RegexValidator(message='Not a valid UID. Expected a 256bit base64url.', regex='[a-zA-Z0-9\\-_=]{43}')]), + ), + migrations.AlterField( + model_name='collectionitem', + name='uid', + field=models.CharField(db_index=True, max_length=44, validators=[django.core.validators.RegexValidator(message='Not a valid UID. Expected a 256bit base64url.', regex='[a-zA-Z0-9\\-_=]{43}')]), + ), + migrations.AlterField( + model_name='collectionitemchunk', + name='uid', + field=models.CharField(db_index=True, max_length=44, validators=[django.core.validators.RegexValidator(message='Not a valid UID. Expected a 256bit base64url.', regex='[a-zA-Z0-9\\-_=]{43}')]), + ), + ] diff --git a/django_etesync/models.py b/django_etesync/models.py index dda081f..4577efb 100644 --- a/django_etesync/models.py +++ b/django_etesync/models.py @@ -20,7 +20,7 @@ from django.core.validators import RegexValidator from django.utils.functional import cached_property -UidValidator = RegexValidator(regex=r'[a-zA-Z0-9\-_=]{44}', message='Not a valid UID. Expected a 256bit base64url.') +UidValidator = RegexValidator(regex=r'[a-zA-Z0-9\-_=]{43}', message='Not a valid UID. Expected a 256bit base64url.') class Collection(models.Model):