rt 4.2.13 ticket#13852
[freeside.git] / rt / share / html / REST / 1.0 / dhandler
index a6fc897..4ff5ee9 100755 (executable)
@@ -2,7 +2,7 @@
 %#
 %# COPYRIGHT:
 %#
-%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
 %#                                          <sales@bestpractical.com>
 %#
 %# (Except where explicitly superseded by other copyright notices)
@@ -62,7 +62,7 @@ my $object = $m->dhandler_arg;
 
 my $name   = qr{[\w.-]+};
 my $list   = '(?:(?:\d+-)?\d+,)*(?:\d+-)?\d+';
-my $label  = '[a-zA-Z0-9@_.+-]+';
+my $label   = '[^,\\/]+';
 my $field  = RT::Interface::REST->field_spec;
 my $labels = "(?:$label,)*$label";
 
@@ -100,22 +100,22 @@ if ($object eq 'show' ||                                # $REST/show
         if (my ($type, $oids, $extra) =
             ($id =~ m#^($name)/($list|$labels)(?:(/.*))?$#o))
         {
-           $extra ||= '';
-           my ($attr, $args) = $extra =~ m{^(?:/($name)(?:/(.*))?)?$}o;
-           my $tids;
-           if ($attr and $attr eq 'history' and $args) {
-               ($tids) = $args =~ m#id/(\d.*)#o;
-           }
-           # expand transaction and attachment range specifications
-           # (if applicable)
-           foreach my $oid (expand_list($oids)) {
-               if ($tids) {
-                   push(@objects, "$type/$oid/$attr/id/$_") for expand_list($tids);
-               } else {
-                   push(@objects, "$type/$oid$extra");
-               }
-           }
-       }
+            $extra ||= '';
+            my ($attr, $args) = $extra =~ m{^(?:/($name)(?:/(.*))?)?$}o;
+            my $tids;
+            if ($attr and $attr eq 'history' and $args) {
+                ($tids) = $args =~ m#id/(\d.*)#o;
+            }
+            # expand transaction and attachment range specifications
+            # (if applicable)
+            foreach my $oid (expand_list($oids)) {
+                if ($tids) {
+                    push(@objects, "$type/$oid/$attr/id/$_") for expand_list($tids);
+                } else {
+                    push(@objects, "$type/$oid$extra");
+                }
+            }
+        }
         else {
             $status = "400 Bad Request";
             $output = "Invalid object ID specified: '$id'";
@@ -242,7 +242,7 @@ foreach $object (@objects) {
         $handler = "Forms/$type/$attr";
 
         unless ($m->comp_exists($handler)) {
-            $args = "$attr/$args";
+            $args = defined $args ? "$attr/$args" : $attr;
             $handler = "Forms/$type/default";
 
             unless ($m->comp_exists($handler)) {