--- loncom/LONCAPA.pm 2008/11/20 15:19:33 1.27 +++ loncom/LONCAPA.pm 2010/06/15 05:31:43 1.30 @@ -1,7 +1,7 @@ # The LearningOnline Network # Base routines # -# $Id: LONCAPA.pm,v 1.27 2008/11/20 15:19:33 jms Exp $ +# $Id: LONCAPA.pm,v 1.30 2010/06/15 05:31:43 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -44,6 +44,7 @@ my $loncapa_max_wait_time = 13; use vars qw($match_domain $match_not_domain $match_username $match_not_username $match_courseid $match_not_courseid + $match_community $match_name $match_lonid $match_handle $match_not_handle); @@ -56,32 +57,20 @@ our @EXPORT = qw(&add_get_param &esca our @EXPORT_OK = qw($match_domain $match_not_domain $match_username $match_not_username $match_courseid $match_not_courseid + $match_community $match_name $match_lonid $match_handle $match_not_handle); our %EXPORT_TAGS = ( 'match' =>[qw($match_domain $match_not_domain $match_username $match_not_username $match_courseid $match_not_courseid + $match_community $match_name $match_lonid $match_handle $match_not_handle)],); my %perlvar; -=pod - -=head2 NOTE: - -add_get_param() - -Inputs are a url, and a hash ref of -form name => value pairs -takes care of properly adding the form name elements and values to the -the url doing proper escaping of the values and joining with ? or & as -needed - -=cut - sub add_get_param { my ($url,$form_data) = @_; my $needs_question_mark = ($url !~ /\?/); @@ -114,8 +103,8 @@ sub unescape { return $str; } -$match_domain = $LONCAPA::domain_re = qr{[\w\-.]+}; -$match_not_domain = $LONCAPA::not_domain_re = qr{[^\w\-.]+}; +$match_domain = $LONCAPA::domain_re = qr{[[:alnum:]\-.]+}; +$match_not_domain = $LONCAPA::not_domain_re = qr{[^[:alnum:]\-.]+}; sub clean_domain { my ($domain) = @_; $domain =~ s/$match_not_domain//g; @@ -133,6 +122,7 @@ sub clean_username { $match_courseid = $LONCAPA::courseid_re = qr{\d[\w\-.]+}; +$match_community =$LONCAPA::community_re = qr{0[\w\-.]+}; $match_not_courseid = $LONCAPA::not_courseid_re = qr{[^\w\-.]+}; sub clean_courseid { my ($courseid) = @_; @@ -175,8 +165,7 @@ sub propath { $subdir =~ s/(.)(.)(.).*/$1\/$2\/$3/; my $proname="$perlvar{'lonUsersDir'}/$udom/$subdir/$uname"; return $proname; -} - +} sub tie_domain_hash { my ($domain,$namespace,$how,$loghead,$logtail) = @_; @@ -385,6 +374,7 @@ BEGIN { __END__ +=pod =head1 NAME @@ -409,12 +399,14 @@ unpack non-word characters into CGI-comp pack CGI-compatible hex codes into actual non-word ASCII character =item add_get_param() + +Append escaped form elements (name=value etc.) to a url. Inputs: url (with or without exit GET from parameters), hash ref of form name => value pairs - Return: url with properly added the form name elements and values to the - the url doing proper escaping of the values and joining with ? or & + Return: url with form name elements and values appended to the + the url, doing proper escaping of the values and joining with ? or & as needed =item clean_handle()