• <tfoot id='KXkix'></tfoot>

        <legend id='KXkix'><style id='KXkix'><dir id='KXkix'><q id='KXkix'></q></dir></style></legend>

          <bdo id='KXkix'></bdo><ul id='KXkix'></ul>

        <small id='KXkix'></small><noframes id='KXkix'>

        <i id='KXkix'><tr id='KXkix'><dt id='KXkix'><q id='KXkix'><span id='KXkix'><b id='KXkix'><form id='KXkix'><ins id='KXkix'></ins><ul id='KXkix'></ul><sub id='KXkix'></sub></form><legend id='KXkix'></legend><bdo id='KXkix'><pre id='KXkix'><center id='KXkix'></center></pre></bdo></b><th id='KXkix'></th></span></q></dt></tr></i><div id='KXkix'><tfoot id='KXkix'></tfoot><dl id='KXkix'><fieldset id='KXkix'></fieldset></dl></div>

        传递“("和“)"通过 URI 导致 403 错误,我该如何对其进行编码?

        Passing quot;(quot; and quot;)quot; through a URI causes a 403 error, how can I encode them?(传递“(和“)通过 URI 导致 403 错误,我该如何对其进行编码?)
      1. <tfoot id='NPoEA'></tfoot>
        <i id='NPoEA'><tr id='NPoEA'><dt id='NPoEA'><q id='NPoEA'><span id='NPoEA'><b id='NPoEA'><form id='NPoEA'><ins id='NPoEA'></ins><ul id='NPoEA'></ul><sub id='NPoEA'></sub></form><legend id='NPoEA'></legend><bdo id='NPoEA'><pre id='NPoEA'><center id='NPoEA'></center></pre></bdo></b><th id='NPoEA'></th></span></q></dt></tr></i><div id='NPoEA'><tfoot id='NPoEA'></tfoot><dl id='NPoEA'><fieldset id='NPoEA'></fieldset></dl></div>

            <tbody id='NPoEA'></tbody>

        • <small id='NPoEA'></small><noframes id='NPoEA'>

              <bdo id='NPoEA'></bdo><ul id='NPoEA'></ul>
                  <legend id='NPoEA'><style id='NPoEA'><dir id='NPoEA'><q id='NPoEA'></q></dir></style></legend>

                • 本文介绍了传递“("和“)"通过 URI 导致 403 错误,我该如何对其进行编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  (用于 XML HTTP 请求的 JavaScript 和用于执行 SQL 查询的 PHP.)

                  我正在构建一个执行查询的网络应用程序.它使用 XMLHTTP 请求 GET 方法并将查询传递给执行它的 PHP 脚本.在我在其中引入括号 ( ) 之前,它工作正常.

                  这是一个如何工作的例子:

                  函数执行Qry(){qry = document.getElementByID('textarea').value;qryHTTPRequest(encodeURI(qry));//我也试过 encodeURIComponent(qry);}函数 xmlHTTPRequest(qry){//获取urlFetch = "http://my.url.com/script.php?qry=" + qry;}

                  这是一个快速参考,我知道我的 xmlhttp 请求可以正常工作,因为它可以完成在传递其他查询时需要执行的操作,例如:

                  SELECT * FROM `tableName`

                  工作正常,但是当你尝试做类似的事情时

                  创建表`new_table`AS(选择 * FROM `old_table`)

                  然后这是它无法执行的时候,我收到 403 错误,所以我认为它与 () 相关,因为我什至在 PHP 本身上尝试了相同的代码,而不必通过它并且它起作用了,所以URL编码过程一定有问题吗?如果这是问题,是否有编码这些字符的方法?我假设还有其他字符没有使用 encodeURI() 方法以及 encodeURIComponent() 进行编码.提前致谢!

                  解决方案

                  下面应该这样做:

                  urlFetch = "http://my.url.com/script.php?qry=" + encodeURIComponent(qry).replace(/(/g, "%28").replace(/)/g, "%29");

                  括号在 URI 语法中很奇怪.许多编码器将它们视为特殊的,即使它们出现在过时标记"产生中.使用常见的 Web 协议(httphttpsmailto)可以安全地将它们编码为 %28%29 虽然允许 Web 服务器为它们分配特殊含义.您已经在使用 encodeURIencodeURIComponent 所以您已经假设 URL 转义序列是 UTF-8.

                  来自 RFC 3986:

                  <块引用>

                  子分隔符!"/$"/&"/'"/("/)"/*"/+"/,"/;"/="

                  ...

                  过时的规则翻译标记              "-"/"_"/"."/!"/~"/*"/'"/"("/")"

                  (JavaScript for the XML HTTP request and PHP for the execution SQL query.)

                  I'm building a web app that executes queries. It uses the XMLHTTP request GET method and passes a query to a PHP script that executes it. It works fine until I introduce parentheses ( ) in it.

                  Here is an example of how works:

                  function executeQry(){
                  qry = document.getElementByID('textarea').value;
                  qryHTTPRequest(encodeURI(qry));
                  //I've also tried encodeURIComponent(qry);
                  }
                  
                  
                  function xmlHTTPRequest(qry){
                  //fetches 
                  urlFetch = "http://my.url.com/script.php?qry=" + qry;
                   }
                  

                  this is a quick reference, I know that my xmlhttp request works fine because it does what it needs to do when other queries are passed through for example:

                  SELECT * FROM `tableName`
                  

                  works fine, but when you try to do something like

                  CREATE TABLE `new_table`
                  AS (SELECT * FROM `old_table`)
                  

                  Then this is when it won't execute, I get the 403 error so I figured that it's an with the () because I even tried this same code on the PHP itself, without having to pass it through and it worked, so there must be an issue with the URL encoding process right? If this is the issue, is there a method for encoding these characters? I assume there are other characters that don't get encoded with encodeURI() method as well as the encodeURIComponent(). Thanks in advance!

                  解决方案

                  The below should do it:

                  urlFetch = "http://my.url.com/script.php?qry=" + encodeURIComponent(qry)
                      .replace(/(/g, "%28").replace(/)/g, "%29");
                  

                  Parentheses are oddballs in the URI grammar. Many encoders treat them as special even though they only appear in the obsolete "mark" production. With common web protocols (http, https, mailto) it is safe to encode them to %28 and %29 though web servers are allowed to assign special meanings to them. You are already using encodeURI or encodeURIComponent so you are already assuming that URL escape sequences are UTF-8.

                  From RFC 3986:

                  sub-delims    "!" / "$" / "&" / "'" / "(" / ")"
                              / "*" / "+" / "," / ";" / "="
                  

                  ...

                  obsolete rule     translation
                  mark              "-" / "_" / "." / "!" / "~" / "*" / "'"
                                  / "(" / ")"
                  

                  这篇关于传递“("和“)"通过 URI 导致 403 错误,我该如何对其进行编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  SCRIPT5: Access is denied in IE9 on xmlhttprequest(SCRIPT5:在 IE9 中对 xmlhttprequest 的访问被拒绝)
                  XMLHttpRequest module not defined/found(XMLHttpRequest 模块未定义/未找到)
                  Show a progress bar for downloading files using XHR2/AJAX(显示使用 XHR2/AJAX 下载文件的进度条)
                  How can I open a JSON file in JavaScript without jQuery?(如何在没有 jQuery 的情况下在 JavaScript 中打开 JSON 文件?)
                  How do I get the HTTP status code with jQuery?(如何使用 jQuery 获取 HTTP 状态码?)
                  quot;Origin null is not allowed by Access-Control-Allow-Originquot; in Chrome. Why?(“Access-Control-Allow-Origin 不允许 Origin null在铬.为什么?)

                    • <bdo id='eC6PD'></bdo><ul id='eC6PD'></ul>

                      <small id='eC6PD'></small><noframes id='eC6PD'>

                          <i id='eC6PD'><tr id='eC6PD'><dt id='eC6PD'><q id='eC6PD'><span id='eC6PD'><b id='eC6PD'><form id='eC6PD'><ins id='eC6PD'></ins><ul id='eC6PD'></ul><sub id='eC6PD'></sub></form><legend id='eC6PD'></legend><bdo id='eC6PD'><pre id='eC6PD'><center id='eC6PD'></center></pre></bdo></b><th id='eC6PD'></th></span></q></dt></tr></i><div id='eC6PD'><tfoot id='eC6PD'></tfoot><dl id='eC6PD'><fieldset id='eC6PD'></fieldset></dl></div>
                          <tfoot id='eC6PD'></tfoot>
                        • <legend id='eC6PD'><style id='eC6PD'><dir id='eC6PD'><q id='eC6PD'></q></dir></style></legend>
                            <tbody id='eC6PD'></tbody>