Bug found in Enketo forms when handling prefilled field containing a percent character

I’m posting here as I’m not sure which of the various KBT component projects an issue about this would belong in…

I’ve noticed there seems to be a bug in the prefilled form fields function: it hangs if any fields have a percent character in them. To replicate:

  • take any deployed form, with an unvalidated text field, which for the purposes of this example I’ll assume has an ID called name
  • Create an URL which prefills this form in Enketo, for instance: https://ee.kobotoolbox.org/x/BWPeKC3E?d[name]=10%25%20tony (URL-encoded percents are %25)
  • Open this URL in a browser

The browser will show the pulsing progress circle indefinitely - the form is never rendered.

Remove the %25, and it will then work normally.

As a work-around, I’ve found that if you double-encode the percent character (i.e. %2525), it seems to work and you get a percent in the pre-filled field. In this case, the URL would be:

https://ee.kobotoolbox.org/x/BWPeKC3E?d[name]=10%2525%20tony

@wu-lee, maybe you could take a reference of how to prefill a response in Enketo through this post discussed previously:

Thanks. That post seems to be about how to use the prefilled field parameters. Just to be clear, I don’t have a problem getting prefilled fields to work in general - just I’ve discovered that some of my prefilled content seemed to break it, even though I was url-encoding it. A process of trial and error narrowed it down to the percent character.

The first example URL above seems to be correct, to prefill a field called “name” with a value of “10% tony”, don’t you agree? (It references a real form, you can click it to see.) And yet it doesn’t work… or at least not in any of my forms. Whereas if you click the second link - it should work.

Hi @wu-lee, thank you for looking deeper into it and finding a workaround. I’ll do some testing and get back to you :+1: in the meantime, please keep using the workaround.

1 Like

Hi @wu-lee, please follow the issue here:

2 Likes