Yaf中地图路由下delimiter的有关问题
Yaf中map路由下delimiter的问题
由于map路由下用户请求的url会按照"/"分级对应到controllers下的目录下的Controller上,action则默认为indexAction,所以想要实现/key1/param1/key2/param2这种形式进行传参,就要通过delimiter来讲url分割成req_uri和query_str两个部分。
在实践中,定义了delimiter(尽管并没有用到它的功能),这时,如果用户的请求(更多的是爬虫或扫站)无意中包含以下形式:/aaa/bbb[delimiter](xxx)?/key1/param1/key2/param2...,会造成程序崩溃。
将这个问题提给鸟哥后,鸟哥迅速给出了修复(18~19行):
<span style="color: #008080;"> 1</span> <span style="color: #0000ff;">if</span> (Z_TYPE_P(delimer) == <span style="color: #008080;">IS_STRING</span><span style="color: #008080;"> 2</span> &&<span style="color: #000000;"> Z_STRLEN_P(delimer)) {</span><span style="color: #008080;"> 3</span> <span style="color: #0000ff;">if</span> ((query_str = <span style="color: #008080;">strstr</span>(req_uri, Z_STRVAL_P(delimer))) != <span style="color: #0000ff;">NULL</span><span style="color: #008080;"> 4</span> && *(query_str - 1) == '/'<span style="color: #000000;">) {</span><span style="color: #008080;"> 5</span> tmp =<span style="color: #000000;"> req_uri;</span><span style="color: #008080;"> 6</span> rest = query_str +<span style="color: #000000;"> Z_STRLEN_P(delimer);</span><span style="color: #008080;"> 7</span> <span style="color: #0000ff;">if</span> (*rest == '\0'<span style="color: #000000;">) {</span><span style="color: #008080;"> 8</span> req_uri = estrndup(req_uri, query_str -<span style="color: #000000;"> req_uri);</span><span style="color: #008080;"> 9</span> query_str = <span style="color: #0000ff;">NULL</span><span style="color: #000000;">;</span><span style="color: #008080;">10</span> <span style="color: #000000;"> efree(tmp);</span><span style="color: #008080;">11</span> } <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (*rest == '/'<span style="color: #000000;">) {</span><span style="color: #008080;">12</span> req_uri = estrndup(req_uri, query_str -<span style="color: #000000;"> req_uri);</span><span style="color: #008080;">13</span> query_str =<span style="color: #000000;"> estrdup(rest);</span><span style="color: #008080;">14</span> <span style="color: #000000;"> efree(tmp);</span><span style="color: #008080;">15</span> } <span style="color: #0000ff;">else</span><span style="color: #000000;"> {</span><span style="color: #008080;">16</span> query_str = <span style="color: #0000ff;">NULL</span><span style="color: #000000;">;</span><span style="color: #008080;">17</span> <span style="color: #000000;"> }</span><span style="color: #008080;">18</span> } <span style="color: #0000ff;">else</span><span style="color: #000000;"> {</span><span style="color: #008080;">19</span> query_str = <span style="color: #0000ff;">NULL</span><span style="color: #000000;">;</span><span style="color: #008080;">20</span> }
通过delimer获取了query_str后,判断delimer的前一个字符是"/"的情况,却没有判断不是的情况,导致不符合/aaa/bbb/[delimer]/key1/param1/...形式的urk被截断成req_uri和query_str去解析,所以程序出现了问题。
感谢鸟哥快速的答复!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this article, we will show you how to reorder multiple columns in PowerQuery by dragging and dropping. Often, when importing data from various sources, columns may not be in the desired order. Reordering columns not only allows you to arrange them in a logical order that suits your analysis or reporting needs, it also improves the readability of your data and speeds up tasks such as filtering, sorting, and performing calculations. How to rearrange multiple columns in Excel? There are many ways to rearrange columns in Excel. You can simply select the column header and drag it to the desired location. However, this approach can become cumbersome when dealing with large tables with many columns. To rearrange columns more efficiently, you can use the enhanced query editor. Enhancing the query

Note: The root and aliasroot instructions in location only set the search root to the directory set by root, that is, the uri will not be truncated. Instead, the original uri will be used to jump to the directory to find the file. The aias instruction will truncate the matching uri, and then Use the path set by alias plus the remaining uri as a sub-path to find the uri of proxy_pass in location. If the url of proxy_pass does not have uri, if the tail is "/", the matching uri will be truncated. If the tail is not "/", then Will not truncate the matching uri if the proxy_pass url contains uri

ReactQuery database plug-in: Methods to implement data import and export, specific code examples are required. With the widespread application of ReactQuery in front-end development, more and more developers are beginning to use it to manage data. In actual development, we often need to export data to local files or import data from local files into the database. In order to implement these functions more conveniently, you can use the ReactQuery database plug-in. The ReactQuery database plugin provides a series of methods

This article will introduce how to use PowerQuery to split data into rows. When exporting data from other systems or sources, it is common to encounter situations where the data is stored in cells combining multiple values. With PowerQuery, we can easily split such data into rows, making the data easier to process and analyze. This can happen if the user doesn't understand Excel's rules and accidentally enters multiple data into a cell, or if the data is not formatted correctly when copying/pasting it from other sources. Processing this data requires additional steps to extract and organize the information for analysis or reporting. How to split data in PowerQuery? PowerQuery transformations can be based on a variety of different factors such as word

1The basic unit of Unicode computer storage is the byte, which is composed of 8 bits. Since English only consists of 26 letters plus a number of symbols, English characters can be stored directly in bytes. But other languages (such as Chinese, Japanese, Korean, etc.) have to use multiple bytes for encoding due to the large number of characters. With the spread of computer technology, non-Latin character encoding technology continues to develop, but there are still two major limitations: no multi-language support: the encoding scheme of one language cannot be used in another language and there is no unified standard: for example There are many encoding standards in Chinese such as GBK, GB2312, GB18030, etc. Since the encoding methods are not unified, developers need to convert back and forth between different encodings, and many errors will inevitably occur.

1. Background Introduction Enterprise digitalization is a hot topic in recent years. It refers to the use of new generation digital technologies such as artificial intelligence, big data, and cloud computing to change the business model of enterprises, thereby promoting new growth in enterprise business. Enterprise digitalization generally includes the digitalization of business operations and the digitalization of enterprise management. This sharing mainly introduces the digitalization of enterprise management level. Information digitization, simply put, means reading, writing, storing and transmitting information in a digital way. From the previous paper documents to the current electronic documents and online collaborative documents, information digitization has become the new normal in today's office. Currently, Alibaba uses DingTalk Documents and Yuque Documents for business collaboration, and the number of online documents has reached more than 20 million. In addition, many companies will internally

What are the similarities and differences between __str__ and __repr__? We all know the representation of strings. Python's built-in function repr() can express objects in the form of strings to facilitate our identification. This is the "string representation". repr() obtains the string representation of an object through the special method __repr__. If __repr__ is not implemented, when we print an instance of a vector to the console, the resulting string may be. >>>classExample:pass>>>print(str(Example()))>>>

1. Introduction The location directive is the core configuration of the http module. It receives requests sent by users based on predefined URL matching rules. Based on the matching results, the request is forwarded to the backend server. Illegal requests are directly rejected and return 403. 404, 500 error handling, etc. 2. Location instruction syntax location[=|~|~*|^~|@]/uri/{…} or location@name{…} 3. URI matching mode The location instruction is divided into two matching modes: 1> Ordinary characters String matching: rules starting with = or without leading characters (~) 2> Regular matching: starting with ~ or ~* indicates regular matching, ~*
