On Jan 5, 2014, at 6:45 PM, z...@apache.org wrote:

> Updated Branches:
>  refs/heads/master daa10ebce -> 3b2b2afc7
> 
> 
> TS-2235: two functions should be changed too
> 
> to be changed functions:
>   url_length_get()
>   url_to_string()

It should be straight forward to write a regression test for this. Do you or Yu 
Quing want to take a crack at that?

> 
> Signed-off-by: Zhao Yongming <ming....@gmail.com>
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/3b2b2afc
> Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/3b2b2afc
> Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/3b2b2afc
> 
> Branch: refs/heads/master
> Commit: 3b2b2afc7680069edf0b122a5da7aaacb0235ecc
> Parents: daa10eb
> Author: Yu Qing <zhuangy...@taobao.com>
> Authored: Tue Nov 19 11:51:51 2013 +0800
> Committer: Zhao Yongming <ming....@gmail.com>
> Committed: Mon Jan 6 10:44:01 2014 +0800
> 
> ----------------------------------------------------------------------
> proxy/hdrs/URL.cc | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3b2b2afc/proxy/hdrs/URL.cc
> ----------------------------------------------------------------------
> diff --git a/proxy/hdrs/URL.cc b/proxy/hdrs/URL.cc
> index f88ae55..976a9c4 100644
> --- a/proxy/hdrs/URL.cc
> +++ b/proxy/hdrs/URL.cc
> @@ -776,19 +776,24 @@ url_length_get(URLImpl * url)
>       length += url->m_len_port + 1;    // +1 for ":"
>   }
> 
> -  if (url->m_ptr_path)
> +  if (url->m_ptr_path) {
>     length += url->m_len_path + 1;      // +1 for /
> -  else
> +  }
> +  else {
>     length += 1;                // +1 for /
> +  }
> 
> -  if (url->m_ptr_params)
> +  if (url->m_ptr_params && url->m_len_params > 0) {
>     length += url->m_len_params + 1;  // +1 for ";"
> +  }
> 
> -  if (url->m_ptr_query)
> +  if (url->m_ptr_query && url->m_len_query > 0) {
>     length += url->m_len_query + 1;   // +1 for "?"
> +  }
> 
> -  if (url->m_ptr_fragment)
> -    length += url->m_len_fragment + 1;        // +1 for "/"
> +  if (url->m_ptr_fragment && url->m_len_fragment > 0) {
> +    length += url->m_len_fragment + 1;        // +1 for "#"
> +  }
> 
>   return length;
> }
> @@ -851,19 +856,19 @@ url_to_string(URLImpl * url, Arena * arena, int *length)
>   memcpy(&str[idx], url->m_ptr_path, url->m_len_path);
>   idx += url->m_len_path;
> 
> -  if (url->m_ptr_params) {
> +  if (url->m_ptr_params && url->m_len_params > 0) {
>     str[idx++] = ';';
>     memcpy(&str[idx], url->m_ptr_params, url->m_len_params);
>     idx += url->m_len_params;
>   }
> 
> -  if (url->m_ptr_query) {
> +  if (url->m_ptr_query && url->m_len_query > 0) {
>     str[idx++] = '?';
>     memcpy(&str[idx], url->m_ptr_query, url->m_len_query);
>     idx += url->m_len_query;
>   }
> 
> -  if (url->m_ptr_fragment) {
> +  if (url->m_ptr_fragment && url->m_len_fragment > 0) {
>     str[idx++] = '#';
>     memcpy(&str[idx], url->m_ptr_fragment, url->m_len_fragment);
>     idx += url->m_len_fragment;
> 

Reply via email to