Yaf中map路由下delimiter的问题,yafdelimiter
Yaf中map路由下delimiter的问题,yafdelimiter
由于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> 1</span> <span>if</span> (Z_TYPE_P(delimer) == <span>IS_STRING</span> <span> 2</span> &&<span> Z_STRLEN_P(delimer)) { </span><span> 3</span> <span>if</span> ((query_str = <span>strstr</span>(req_uri, Z_STRVAL_P(delimer))) != <span>NULL</span> <span> 4</span> && *(query_str - 1) == '/'<span>) { </span><span> 5</span> tmp =<span> req_uri; </span><span> 6</span> rest = query_str +<span> Z_STRLEN_P(delimer); </span><span> 7</span> <span>if</span> (*rest == '\0'<span>) { </span><span> 8</span> req_uri = estrndup(req_uri, query_str -<span> req_uri); </span><span> 9</span> query_str = <span>NULL</span><span>; </span><span>10</span> <span> efree(tmp); </span><span>11</span> } <span>else</span> <span>if</span> (*rest == '/'<span>) { </span><span>12</span> req_uri = estrndup(req_uri, query_str -<span> req_uri); </span><span>13</span> query_str =<span> estrdup(rest); </span><span>14</span> <span> efree(tmp); </span><span>15</span> } <span>else</span><span> { </span><span>16</span> query_str = <span>NULL</span><span>; </span><span>17</span> <span> } </span><span>18</span> } <span>else</span><span> { </span><span>19</span> query_str = <span>NULL</span><span>; </span><span>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

AI Hentai Generator
Generate AI Hentai for free.

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

How to set up keyboard startup on Gigabyte's motherboard. First, if it needs to support keyboard startup, it must be a PS2 keyboard! ! The setting steps are as follows: Step 1: Press Del or F2 to enter the BIOS after booting, and go to the Advanced (Advanced) mode of the BIOS. Ordinary motherboards enter the EZ (Easy) mode of the motherboard by default. You need to press F7 to switch to the Advanced mode. ROG series motherboards enter the BIOS by default. Advanced mode (we use Simplified Chinese to demonstrate) Step 2: Select to - [Advanced] - [Advanced Power Management (APM)] Step 3: Find the option [Wake up by PS2 keyboard] Step 4: This option The default is Disabled. After pulling down, you can see three different setting options, namely press [space bar] to turn on the computer, press group

1. Processor When choosing a computer configuration, the processor is one of the most important components. For playing games like CS, the performance of the processor directly affects the smoothness and response speed of the game. It is recommended to choose Intel Core i5 or i7 series processors because they have powerful multi-core processing capabilities and high frequencies, and can easily cope with the high requirements of CS. 2. Graphics card Graphics card is one of the important factors in game performance. For shooting games such as CS, the performance of the graphics card directly affects the clarity and smoothness of the game screen. It is recommended to choose NVIDIA GeForce GTX series or AMD Radeon RX series graphics cards. They have excellent graphics processing capabilities and high frame rate output, and can provide a better gaming experience. 3. Memory power

System76 has made waves recently with its Cosmic desktop environment, which is slated to launch with the next major alpha build of Pop!_OS on August 8. However, a recent post on X by System76 CEO, Carl Richell, has tipped that the Cosmic DE developer

Glodon Software is a software company focusing on the field of building informatization. Its products are widely used in all aspects of architectural design, construction, and operation. Due to the complex functions and large data volume of Glodon software, it requires high computer configuration. This article will elaborate on the computer configuration recommendations of Glodon Software from many aspects to help readers choose a suitable computer configuration processor. Glodon Software requires a large amount of data calculation and processing when performing architectural design, simulation and other operations. Therefore, the requirements for the processor are higher. It is recommended to choose a multi-core, high-frequency processor, such as Intel i7 series or AMD Ryzen series. These processors have strong computing power and multi-thread processing capabilities, and can better meet the needs of Glodon software. Memory Memory is affecting computing

SPDIFOUT connection line sequence on the motherboard. Recently, I encountered a problem regarding the wiring sequence of the wires. I checked online. Some information says that 1, 2, and 4 correspond to out, +5V, and ground; while other information says that 1, 2, and 4 correspond to out, ground, and +5V. The best way is to check your motherboard manual. If you can't find the manual, you can use a multimeter to measure it. Find the ground first, then you can determine the order of the rest of the wiring. How to connect motherboard VDG wiring When connecting the VDG wiring of the motherboard, you need to plug one end of the VGA cable into the VGA interface of the monitor and the other end into the VGA interface of the computer's graphics card. Please be careful not to plug it into the motherboard's VGA port. Once connected, you can

Apache Camel is an Enterprise Service Bus (ESB)-based integration framework that can easily integrate disparate applications, services, and data sources to automate complex business processes. ApacheCamel uses route-based configuration to easily define and manage integration processes. Key features of ApacheCamel include: Flexibility: ApacheCamel can be easily integrated with a variety of applications, services, and data sources. It supports multiple protocols, including HTTP, JMS, SOAP, FTP, etc. Efficiency: ApacheCamel is very efficient, it can handle a large number of messages. It uses an asynchronous messaging mechanism, which improves performance. Expandable

To solve the problem that jQuery.val() cannot be used, specific code examples are required. For front-end developers, using jQuery is one of the common operations. Among them, using the .val() method to get or set the value of a form element is a very common operation. However, in some specific cases, the problem of not being able to use the .val() method may arise. This article will introduce some common situations and solutions, and provide specific code examples. Problem Description When using jQuery to develop front-end pages, sometimes you will encounter

Optimizing the performance of Go language map In Go language, map is a very commonly used data structure, used to store a collection of key-value pairs. However, map performance may suffer when processing large amounts of data. In order to improve the performance of map, we can take some optimization measures to reduce the time complexity of map operations, thereby improving the execution efficiency of the program. 1. Pre-allocate map capacity. When creating a map, we can reduce the number of map expansions and improve program performance by pre-allocating capacity. Generally, we
