Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1425

url data without encodeURIComponent occurred messy code

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.0.33.Final
    • 2.0.13.Final
    • Core
    • None

      I create a servlet just like:
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

      { // TODO Auto-generated method stub name =new String(request.getParameter("name").getBytes("utf-8")); System.out.println(name); System.out.println(request.getParameter("name")); response.getWriter().append("Served at: ").append(request.getContextPath()); }

      then use curl --header "Content-Type:application/x-www-form-urlencoded;charset=utf-8" -d "name=中文" http://1et/Test1:8080/sync-servle

      then getParameter messy code

      I find someone like me :https://stackoverflow.com/questions/43085811/ajax-post-to-jboss-eap-7-without-encodeuricomponent-occurred-messy-code

      io.undertow.server.handlers.form.FormEncodedDataDefinition.FormEncodedDataParser.doParse(final StreamSourceChannel channel),it handled like this:

      buffer.clear();
      int c = channel.read(buffer);
      if (c > 0) {
      buffer.flip();
      while (buffer.hasRemaining()) {
      byte n = buffer.get();
      builder.append((char) n);//the problem occurred here,[a][b][c] would be changed to [0][a][0][b][0][c]

            rhn-cservice-bbaranow Bartosz Baranowski
            gaoyonglu 永露 高 (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: