From e216e5a6f2d62c068bc7d6eda70135cb9055482b Mon Sep 17 00:00:00 2001 From: winkidney Date: Mon, 15 Jul 2019 17:09:53 +0800 Subject: [PATCH] Feature: Use char-field instead of url-field to fit strange types of url Now Pinry will not care type of url, if it could be input, it could be saved. This may cause xss issue but Pinry is a private pin-board replacement, so be it. --- core/migrations/0004_auto_20190715_0912.py | 30 ++++++++++++++++++++++ core/models.py | 6 ++--- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 core/migrations/0004_auto_20190715_0912.py diff --git a/core/migrations/0004_auto_20190715_0912.py b/core/migrations/0004_auto_20190715_0912.py new file mode 100644 index 0000000..8b66138 --- /dev/null +++ b/core/migrations/0004_auto_20190715_0912.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-07-15 09:12 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0003_auto_20190222_1358'), + ] + + operations = [ + migrations.AlterField( + model_name='pin', + name='origin', + field=models.CharField(blank=True, max_length=256, null=True), + ), + migrations.AlterField( + model_name='pin', + name='referer', + field=models.CharField(blank=True, max_length=256, null=True), + ), + migrations.AlterField( + model_name='pin', + name='url', + field=models.CharField(blank=True, max_length=256, null=True), + ), + ] diff --git a/core/models.py b/core/models.py index 08a2543..0de747d 100644 --- a/core/models.py +++ b/core/models.py @@ -72,11 +72,11 @@ class Image(BaseImage): class Pin(models.Model): submitter = models.ForeignKey(User) - url = models.URLField(null=True, blank=True) + url = models.CharField(null=True, blank=True, max_length=256) # origin is tha same as referer but not work, # should be removed some day - origin = models.URLField(null=True, blank=True) - referer = models.URLField(null=True, blank=True) + origin = models.CharField(null=True, blank=True, max_length=256) + referer = models.CharField(null=True, blank=True, max_length=256) description = models.TextField(blank=True, null=True) image = models.ForeignKey(Image, related_name='pin') published = models.DateTimeField(auto_now_add=True)