[system] / trunk / webwork-modperl / lib / WeBWorK / DB / Classlist.pm Repository:
ViewVC logotype

Diff of /trunk/webwork-modperl/lib/WeBWorK/DB/Classlist.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 425 Revision 426
135 135
136sub decode($) { 136sub decode($) {
137 my $string = shift; 137 my $string = shift;
138 return unless defined $string and $string; 138 return unless defined $string and $string;
139 my %hash = $string =~ /(.*?)(?<!\\)=(.*?)(?:(?<!\\)&|$)/g; 139 my %hash = $string =~ /(.*?)(?<!\\)=(.*?)(?:(?<!\\)&|$)/g;
140 $hash{$_} =~ s/\\(.)/$1/ foreach (keys %hash); # unescape anything 140 $hash{$_} =~ s/\\(.)/$1/g foreach (keys %hash); # unescape anything
141 return %hash; 141 return %hash;
142} 142}
143 143
144sub encode(@) { 144sub encode(@) {
145 my %hash = @_; 145 my %hash = @_;
146 my $string; 146 my $string;
147 foreach (keys %hash) { 147 foreach (keys %hash) {
148 $hash{$_} = "" unless defined $hash{$_}; # promote undef to "" 148 $hash{$_} = "" unless defined $hash{$_}; # promote undef to ""
149 $hash{$_} =~ s/(=|&)/\\$1/; # escape & and = 149 $hash{$_} =~ s/(=|&)/\\$1/g; # escape & and =
150 $string .= "$_=$hash{$_}&"; 150 $string .= "$_=$hash{$_}&";
151 } 151 }
152 chop $string; # remove final '&' from string for old code :p 152 chop $string; # remove final '&' from string for old code :p
153 return $string; 153 return $string;
154} 154}

Legend:
Removed from v.425  
changed lines
  Added in v.426

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9