Re: [PATCHv4] gitweb: refactor input parameters parse/validation

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jakub Narebski
Date: Friday, October 3, 2008 - 4:20 am

On Fri, 3 Oct 2008, Giuseppe Bilotta wrote:


I now think that %input_params is a better solution, even if we won't
be implementing -true_replay / -faithful_replay option, where options
gotten in path_info would be passed in path_info, and options passed
in query string would be passed as CGI params (even if those params
could be encoded in path_info).
 
One of the advantages is that having @cgi_param_mapping near the top
provides opportunity to describe short CGI query options.

Another advantage is that with %input_params it is easy to find if
parameter is multivalued, or is meant to be multivalued: just check
ref($input_params{long_name}); well, perhaps not _that_ easy, but...


Avoiding repetition can be done in different ways, for example we can
have gitweb assume that if value is already in params variable
($project, $action, $hash,...) it is already validated, and if it is
only in %input_params it is not.  Add to that for example putting
common part of project path checks into validate_project and you have
all the advantages (no code repetition, spared validation) without
drawback of harder to maintain spaghetti-like code.


Hmmmm...
 

[cut]

For project from query string we now have:

  !validate_pathname($project) ||
  !(-d "$projectroot/$project") ||
  !check_head_link("$projectroot/$project") ||
  ($export_ok && !(-e "$projectroot/$project/$export_ok")) ||
  ($strict_export && !project_in_list($project))

For project from path_info we now have:

  while ($project && !check_head_link("$projectroot/$project")) {
	$project =~ s,/*[^/]*$,,;
  }
  ...
  !validate_pathname($project) ||
  ($export_ok && !-e "$projectroot/$project/$export_ok") ||
  ($strict_export && !project_in_list($project))
  
It is almost the same; I have thought that they differ more. Perhaps
some of above code could be refactored into validate_project(), or
project_ok() subroutine.


Perhaps also put query string handling into evaluate_CGI_query(), or
evaluate_query_string(), similar to evaluate_path_info()?

-- 
Jakub Narebski
Poland
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCHv4] gitweb: PATH_INFO support improvements, Giuseppe Bilotta, (Wed Oct 1, 5:10 pm)
[PATCHv4] gitweb: refactor input parameters parse/validation, Giuseppe Bilotta, (Wed Oct 1, 5:10 pm)
[PATCHv4] gitweb: generate project/action/hash URLs, Giuseppe Bilotta, (Wed Oct 1, 5:10 pm)
[PATCHv4] gitweb: use_pathinfo filenames start with /, Giuseppe Bilotta, (Wed Oct 1, 5:10 pm)
[PATCHv4] gitweb: parse parent..current syntax from pathinfo, Giuseppe Bilotta, (Wed Oct 1, 5:10 pm)
[PATCHv4] gitweb: generate parent..current URLs, Giuseppe Bilotta, (Wed Oct 1, 5:10 pm)
Re: [PATCHv4] gitweb: PATH_INFO support improvements, Jakub Narebski, (Thu Oct 2, 1:19 am)
Re: [PATCHv4] gitweb: PATH_INFO support improvements, Giuseppe Bilotta, (Thu Oct 2, 1:49 am)
Re: [PATCHv4] gitweb: PATH_INFO support improvements, Jakub Narebski, (Thu Oct 2, 3:16 am)
Re: [PATCHv4] gitweb: generate project/action/hash URLs, Jakub Narebski, (Thu Oct 2, 6:48 pm)
Re: [PATCHv4] gitweb: refactor input parameters parse/vali ..., Jakub Narebski, (Fri Oct 3, 4:20 am)
Re: [PATCHv4] gitweb: use_pathinfo filenames start with /, Jakub Narebski, (Fri Oct 3, 4:28 am)
Re: [PATCHv4] gitweb: generate project/action/hash URLs, Jakub Narebski, (Fri Oct 3, 6:15 pm)
Re: [PATCHv4] gitweb: generate parent..current URLs, Jakub Narebski, (Sun Oct 5, 5:17 pm)