使用非UTF-8编码的get方法提交表单 [英] Submit form with get method in non UTF-8 encoding

查看:96
本文介绍了使用非UTF-8编码的get方法提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我有一个页面使用非UTF-8编码.
  2. 存在一个带有method="get"的表格.如果我提交这些非UTF-8字符,它们将进入URI.
  3. 当我尝试在URI上运行decodeURIComponent()时,出现臭名昭著的错误:URIError: malformed URI sequence./li>
  1. I have a page in non UTF-8 encoding.
  2. There is a form with method="get". If I submit these non UTF-8 characters, they get to the URI.
  3. When I try to run decodeURIComponent() on the URI, I get the infamous error: URIError: malformed URI sequence.

请遵循 测试用例 .

Please follow the testcase.

问题:

  1. 问题在上面的哪个步骤(1、2、3)中? 1应该可以. 2是提交<form>的标准方法.而3是标准功能.所有这些都是标准的!但是某个地方肯定有错误.

  1. In which of the above steps (1, 2, 3) is the problem? 1 should be OK. 2 is the standard way to submit <form>. And 3 is the standard function. All these things are standard! Yet there must be an error somewhere.

URI中是否允许使用非UTF-8编码的字符? (否则,问题显然出在步骤2中.)

Are characters of encodings other than UTF-8 allowed in URIs? (If not, the problem apparently is in step 2).

正确诊断问题后,问题是-什么是干净的解决方案?该页面必须保持非UTF-8编码.

After the problem is correctly diagnosed, the question is - what would be a clean solution to it? The page must stay in the non UTF-8 encoding.

推荐答案

Firefox说:

[11:38:39.275]表单以ISO-8859-2编码提交,无法对所有Unicode字符进行编码,因此用户输入可能会损坏.为避免此问题,应更改页面,以便通过将页面本身的编码更改为UTF-8 或通过在页面上指定accept-charset = utf-8来以UTF-8编码形式提交表单.表单元素. @ http://artax.karlin.mff.cuni.cz/~ttel5535/pub/bugs/form_get_submit_non_utf-8/non_utf8_uri_test.html?input=%B9

这篇关于使用非UTF-8编码的get方法提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆