Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xform title regex can't deal with HTML #697

Open
jnm opened this issue Mar 29, 2021 · 1 comment
Open

xform title regex can't deal with HTML #697

jnm opened this issue Mar 29, 2021 · 1 comment
Labels

Comments

@jnm
Copy link
Member

jnm commented Mar 29, 2021

Traceback (most recent call last):
  File "<console>", line 8, in <module>
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 537, in delete
    collector.delete()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/deletion.py", line 314, in delete
    sender=model, instance=obj, using=self.using
  File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 189, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/srv/src/kobocat/onadata/apps/logger/models/instance.py", line 103, in update_xform_submission_count_delete
    xform.save(update_fields=['num_of_submissions'])
  File "/srv/src/kobocat/onadata/apps/logger/models/xform.py", line 191, in save
    self._set_title()
  File "/srv/src/kobocat/onadata/apps/logger/models/xform.py", line 162, in _set_title
    title_xml = matches[0][:XFORM_TITLE_LENGTH]
IndexError: list index out of range

OK, here's why this is broken. The form has:

<h:title><span style="color:red; font-family:gill sans">Weightlifting Wales #FindYourStrength</span></h:title>

but KoBoCAT assumes:

title_pattern = re.compile(r"<h:title>([^<]+)</h:title>")

Internal discussion: https://chat.kobotoolbox.org/#narrow/stream/4-KoBo-Dev/topic/Ending.20use.20of.20.60_deleted_at.60/near/23293

@jnm
Copy link
Member Author

jnm commented Mar 30, 2021

Only one affected XForm on HHI: the one with PK 64286.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant