X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/0f7ebe49c20394d80afb129b29e4afa411347441..d1276c781518fc7b90c4b6bd3bd6364252ab3174:/apps/catalogue/management/commands/fixdc.py diff --git a/apps/catalogue/management/commands/fixdc.py b/apps/catalogue/management/commands/fixdc.py index 80b341c7..3f997d0c 100644 --- a/apps/catalogue/management/commands/fixdc.py +++ b/apps/catalogue/management/commands/fixdc.py @@ -18,7 +18,13 @@ class FixDC(XmlUpdater): try: WLURI.strict(elem.text) except ValidationError: - correct_field = unicode(WLURI.from_slug(WLURI(elem.text).slug)) + correct_field = unicode(WLURI.from_slug( + WLURI(elem.text.strip()).slug)) + try: + WLURI.strict(correct_field) + except ValidationError: + # Can't make a valid WLURI out of it, leave as is. + return False if verbose: print "Changing %s from %s to %s" % ( elem.tag, elem.text, correct_field