Opened 4 years ago

Closed 4 years ago

#18740 closed Uncategorized (needsinfo)

request.REQUEST truncates POST data

Reported by: colleen@… Owned by: nobody
Component: HTTP handling Version: 1.4
Severity: Normal Keywords: request, POST, getlist
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by ramiro)

So I have this form (some elements removed for clarity)

    <form id="{{ section }}-submission-form{{ cell_id }}">

        <input type=hidden name="section" value="{{ section }}" />
        <input type="hidden" name="school" id="{{ section }}-submit-school{{ cell_id }}" />

        {% if section == "posts" %}
            <input type=hidden name="url" />
            <textarea class="{{ section }}txtinput{{ cell_id }}" name="text-submission"
                      default="{% if is_advice %}What's your question?{% else %}What's on your mind?{% endif %}"
                      id="{{ section }}-suggestion-box{{ cell_id }}"
                      style="margin: 0 0 .5em 0;font-family: Arial, sans-serif;font-size: 14px; width: 410px;"
            <br />
        {% endif %}
        {% if section == "photos" %}
            <span style='line-height: 40px;'>
            <label class="photouploadlabel">URL</label><input type="text" name="image-url" style="width: 335px" /><br>
            <label class="photouploadlabel">File</label><input type="file" name="image-file" style="width: 335px"/><br>
            <label class="photouploadlabel">Caption</label><input type="text" id="image-caption{{ cell_id }}"
                                                                  name="image-caption" style="width: 335px" default="optional"/>
        {% endif %}

        <div id="{{ section }}-bottomdiv{{ cell_id }}" style="height: 45px; margin-top: .5em; width: 413px;">
            <div style="height: 45px">
            <label id="{{ section }}-tagsbutton{{ cell_id }}"
                   style="margin-right: .5em; cursor: pointer; vertical-align: bottom; float:left; line-height: 1.8em;">Tags</label>

            <input id="{{ section }}-tagsinput{{ cell_id }}" type="text" name="tags-list" style="position: relative"/>
                        <button id="send-{{ section }}-suggestion{{ cell_id }}" disabled="disabled"
                    style="float:right; position: relative; bottom: 7px; right: -4px;">Post</button>

The tags-list input is turned into an autocomplete and users select tags, which are then added to a global js variable "selected tags". When the user presses "Post", I have this code:

               url: '/save-suggestion/',
               type: 'post',
               data: {'tags': selectedtags },
               dataType: 'json',
               success: function(response){
                   clear_text(section, cellid);

printing out request.POST gets me:

<QueryDict: {u'text-submission': [u'your mom is on my mind.'], u'school': [u'1997'], u'tags-list': [u''], u'url': [u''], u'section': [u'posts'], u'tags[]': [u'tigers', u'lions'], u'anonymity-level': [u'schoolandmajor']}>

(i.e. what I expect)

but printing request.REQUEST gets me:

{u'text-submission': u'your mom is on my mind.', u'school': u'1997', u'tags-list': u'', u'url': u'', u'section': u'posts', u'tags[]': u'lions', u'anonymity-level': u'schoolandmajor'}

(i.e. tags[] is truncated, as if using get instead of getlist)

Change History (1)

comment:1 Changed 4 years ago by ramiro

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

Are you getting any real behavior that shows request.REQUEST isn't having the value you expect or it's only the representation shown with print?

Also, I'd beg you to take a few more minutes and re-post a test case:

  • With a simple HTML form that is actually a minimal expression needed to get the issue to show.
  • Not using any AJAX, but using a form widget that has the same representation and use POST.

Otherwise, trying to create a setup reproducing all the same bells and whistles is nearly impossible for others.

Note: See TracTickets for help on using tickets.
Back to Top