Model uid validator: fix off-by-1 error with the uid.

256bit is actually 43 base64 chars, not 44.
This commit is contained in:
Tom Hacohen 2020-02-26 16:46:41 +02:00
parent f4cb7cb74f
commit f1bfb0a9a0
2 changed files with 30 additions and 1 deletions

View File

@ -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}')]),
),
]

View File

@ -20,7 +20,7 @@ from django.core.validators import RegexValidator
from django.utils.functional import cached_property 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): class Collection(models.Model):