Data gets corrupted on form send, =\r\n introduced in the data every 75 characters?

扶醉桌前 提交于 2019-12-23 23:01:17

问题


I'm working on a project in Django nonrel, on Google App Engine, though I have a feeling my problem has nothing to do with either of these directly .

I have a hidden field in one of the models that is defined like so:

models.CharField(max_length=400, null=True, blank=True,default="{}")

The field is meant to receive JSON data from a widget in my admin, and in the client its value changes properly.

(Which data is being sent is irrelevant to my problem - whatever string is in the field value is being corrupted)

The problem is - when I look at the data as passed to the django save function , I see that every 75 characters I get =\r\n inside the data string. This effectively breaks the string, rendering my data useless. I have no idea where this is coming from, or what causes this.

More interesting points:

  • The admin form has enctype='multipart/form-data', since I use GAE blobstore to upload a file in that form
  • I'm using django-filetransfers to facilitate working with the blobstore
  • I've checked the request going out of the browser, the data going out is clean
  • Django saves the data in the model as UTF8

I haven't found anything remotely close to my problem on google...

Does anyone have a solution? Or maybe a direction on where to start looking?


回答1:


So it turns out the problem is a result of this bug in Google App Engine

I found my solution here: Encoding problem in app engine when submitting multipart/form-data forms

The problem was solved using Andres Bossard middleware fix in that thread



来源:https://stackoverflow.com/questions/11950220/data-gets-corrupted-on-form-send-r-n-introduced-in-the-data-every-75-characte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!