Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-21081

Improper encoding of request when using standard html form and resource handler

    XMLWordPrintable

Details

    • Unknown
    • N/A
    • N/A

    Description

      Apparently processing a request coming from a form in a resource handler, without using any piece of javascript to submit the form, doesn't allow to properly process the encoding of the request.
      In Change Request I had a standard html form such as:

      <form id="titleForm" action="/my/resource/handler/url" method="post">
      <input type="hidden" name="change" value="settitle"/>
      <input type="text" id="newTitle" name="newTitle" value="中文"/>
      <input type="submit" value="Click me"/>
      </form>
      

      When submitted to the resource handler the value of the newTitle parameter was badly encoded when using tomcat. However, when transforming my code to rely on a piece of jQuery with a script as dumb as:

      event.preventDefault();
            var actionUrl = $('#titleForm').attr('action');
            $.post(actionUrl, {
              'changeType': 'settitle',
              'new-title': $('input#newTitle').val()
            }).done(function (data) {
              console.log(data);
            });
      

      Then the parameter was properly encoded. Analysis of the request shown that in first case (standard html form) the Content-Type header was application/x-www-form-urlencoded while in second case it was application/x-www-form-urlencoded; charset=UTF-8

      Attachments

        Issue Links

          Activity

            People

              MichaelHamann Michael Hamann
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: