The delimiter problem in the map route in Yaf, yafdelimiter

Source: Internet
Author: User

The delimiter problem in the map route in Yaf, yafdelimiter

Because the url requested by the user under the map route will correspond to the Controller under the controllers directory according to the "/" classification, the default action is indexAction, therefore, to implement parameter passing in the form of/key1/param1/key2/param2, we need to use delimiter to split the url into two parts: req_uri and query_str.

In practice, delimiter is defined (although it does not use its functions). In this case, if a user's request (more crawler or scan site) inadvertently contains the following forms: /aaa/bbb [delimiter] (xxx )? /Key1/param1/key2/param2. .., causing program crash.

After I raised this question to laruence, laruence quickly provided a solution (18 ~ 19 rows ):

 

 1 if (Z_TYPE_P(delimer) == IS_STRING 2             && Z_STRLEN_P(delimer)) { 3         if ((query_str = strstr(req_uri, Z_STRVAL_P(delimer))) != NULL 4             && *(query_str - 1) == '/') { 5             tmp  = req_uri; 6             rest = query_str + Z_STRLEN_P(delimer); 7             if (*rest == '\0') { 8                 req_uri     = estrndup(req_uri, query_str - req_uri); 9                 query_str     = NULL;10                 efree(tmp);11             } else if (*rest == '/') {12                 req_uri     = estrndup(req_uri, query_str - req_uri);13                 query_str   = estrdup(rest);14                 efree(tmp);15             } else {16                 query_str = NULL;17             }18         } else {19             query_str = NULL;20         }

After query_str is obtained through delimiters, the system determines whether the first character of delimiters is "/", but does not judge whether it is not, cause/aaa/bbb/[deletable]/key1/param1 /... the format of urk is truncated into req_uri and query_str for parsing, so the program has a problem.

Thank you for your quick response!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.