[Rt-commit] rt branch, 4.2/multi-value-cf-in-rest, created. rt-4.0.1-233-ga350811

Alex Vandiver alexmv at bestpractical.com
Wed Jul 6 16:03:56 EDT 2011


The branch, 4.2/multi-value-cf-in-rest has been created
        at  a35081196a922af379f37f8d1b99911f018f0e38 (commit)

- Log -----------------------------------------------------------------
commit a35081196a922af379f37f8d1b99911f018f0e38
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Jul 6 15:39:30 2011 -0400

    Add (failing) tests for escaping

diff --git a/t/web/command_line.t b/t/web/command_line.t
index 5a3548e..f2a7040 100644
--- a/t/web/command_line.t
+++ b/t/web/command_line.t
@@ -2,7 +2,7 @@
 use strict;
 use File::Spec ();
 use Test::Expect;
-use RT::Test tests => 303, actual_server => 1;
+use RT::Test tests => 333, actual_server => 1;
 my ($baseurl, $m) = RT::Test->started_ok;
 
 use RT::User;
@@ -254,6 +254,55 @@ expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf');
 expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value');
 expect_like(qr/CF\.{MultipleCF$$}: '1,2\\'s,3'/i, 'Verified change');
 
+# Test escaping of quotes - generate (foo)(bar') with no escapes
+my $ticket = RT::Ticket->new($RT::SystemUser);
+expect_send("edit ticket/$ticket_id set CF.{MultipleCF$$}=\"'foo',bar'\"", "Changing CF with no slashes: 'foo',bar'");
+expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf');
+$ticket->Load($ticket_id);
+is($ticket->CustomFieldValuesAsString("MultipleCF$$"), "foo"."\n"."bar'", "Direct value checks out");
+expect_send("edit ticket/$ticket_id del CF.{MultipleCF$$}=\"bar'\"", "Stripping off bar' (should be present)");
+expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf');
+expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value');
+expect_like(qr/CF\.{MultipleCF$$}: foo/i, 'Verified change');
+
+# With one \, generate (foo',bar)
+expect_send("edit ticket/$ticket_id set CF.{MultipleCF$$}=\"'foo\\',bar'\"", "Changing CF to one slash: 'foo\\',bar'");
+expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf');
+$ticket->Load($ticket_id);
+is($ticket->CustomFieldValuesAsString("MultipleCF$$"), "foo',bar", "Direct value checks out");
+expect_send("edit ticket/$ticket_id del CF.{MultipleCF$$}=\"bar'\"", "Stripping off bar' (should _not_ be present)");
+expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf');
+expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value');
+expect_like(qr/CF\.{MultipleCF$$}: 'foo\\',bar'/i, 'Verified change');
+
+# With two \, generate (foo\)(bar')
+expect_send("edit ticket/$ticket_id set CF.{MultipleCF$$}=\"'foo\\\\',bar'\"", "Changing CF to two slashes: 'foo\\\\',bar'");
+expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf');
+$ticket->Load($ticket_id);
+is($ticket->CustomFieldValuesAsString("MultipleCF$$"), "foo\\"."\n"."bar'", "Direct value checks out");
+expect_send("edit ticket/$ticket_id del CF.{MultipleCF$$}=\"bar'\"", "Stripping off bar' (should be present)");
+expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf');
+expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value');
+expect_like(qr/CF\.{MultipleCF$$}: 'foo\\\\'/i, 'Verified change');
+
+# With three \, generate (foo\',bar)
+expect_send("edit ticket/$ticket_id set CF.{MultipleCF$$}=\"'foo\\\\\\',bar'\"", "Changing CF to three slashes: 'foo\\\\\\',bar'");
+expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf');
+$ticket->Load($ticket_id);
+is($ticket->CustomFieldValuesAsString("MultipleCF$$"), "foo\\'bar", "Direct value checks out");
+expect_send("edit ticket/$ticket_id del CF.{MultipleCF$$}=\"bar'\"", "Stripping off bar' (should _not_ be present)");
+expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf');
+expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value');
+expect_like(qr/CF\.{MultipleCF$$}: 'foo\\\\\\',bar'/i, 'Verified change');
+
+# Check that we don't infinite-loop on 'foo'bar,baz
+TODO: {
+    todo_skip "Quotes not at comma boundries infinite-loop", 2;
+    expect_send("edit ticket/$ticket_id set CF.{MultipleCF$$}=\"'foo'bar,baz\"", 'Changing CF to have quotes not at commas');
+    expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf');
+}
+
+
 # ...
 # change a ticket's ...[other properties]...
 # ...

-----------------------------------------------------------------------


More information about the Rt-commit mailing list