summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarryl L. Pierce <mcpierce@apache.org>2012-12-03 21:06:46 +0000
committerDarryl L. Pierce <mcpierce@apache.org>2012-12-03 21:06:46 +0000
commit0f1e3b7bdae8794cee77065111456637b1e4019c (patch)
tree6c32bbcd46eea59c7a0f1f286b7c2eca7f46ddac
parent1f0faffd4ad0002a1a54ac18b36adbe0108b013e (diff)
downloadqpid-python-0f1e3b7bdae8794cee77065111456637b1e4019c.tar.gz
QPID-4480: Fix handling in Perl of strings with embedded nulls.
Contributed by Jimmy Jones <jimmyjones2@gmx.co.uk> git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.20@1416663 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/bindings/qpid/perl/test/test-null-inside-map.pl59
-rw-r--r--qpid/cpp/bindings/swig_perl_typemaps.i4
2 files changed, 62 insertions, 1 deletions
diff --git a/qpid/cpp/bindings/qpid/perl/test/test-null-inside-map.pl b/qpid/cpp/bindings/qpid/perl/test/test-null-inside-map.pl
new file mode 100644
index 0000000000..2c1e698abb
--- /dev/null
+++ b/qpid/cpp/bindings/qpid/perl/test/test-null-inside-map.pl
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+use strict;
+use warnings;
+use Data::Dumper;
+
+use cqpid_perl;
+
+my $broker = ( @ARGV > 0 ) ? $ARGV[0] : "localhost:5672";
+my $address = ( @ARGV > 1 ) ? $ARGV[0] : "amq.match";
+my $connectionOptions = ( @ARGV > 2 ) ? $ARGV[1] : "";
+
+my $in_address = "amq.match; {link:{x-bindings:[{exchange: 'amq.match', arguments:{'x-match': 'all', 'header2' : 'value2'}}]}}";
+
+my $connection = new cqpid_perl::Connection($broker, $connectionOptions);
+
+eval {
+ $connection->open();
+ my $session = $connection->createSession();
+
+ my $receiver = $session->createReceiver($in_address);
+ my $sender = $session->createSender($address);
+
+ my $hash = { id => 1234, name => "Blah\x00Blah" };
+ my $outmsg = new cqpid_perl::Message("Hello\x00World");
+ cqpid_perl::encode($hash, $outmsg);
+ $outmsg->setProperty("header2", "value2");
+ $sender->send($outmsg);
+
+ my $message = $receiver->fetch($cqpid_perl::Duration::SECOND);
+
+ print Dumper($message->getProperties());
+
+ print $message->getContent() . "\n";
+ my $outmap = cqpid_perl::decodeMap($message);
+ print Dumper($outmap);
+ $session->acknowledge();
+
+ $connection->close();
+};
+
+die $@ if ($@);
diff --git a/qpid/cpp/bindings/swig_perl_typemaps.i b/qpid/cpp/bindings/swig_perl_typemaps.i
index 831576a7d4..201e64bac6 100644
--- a/qpid/cpp/bindings/swig_perl_typemaps.i
+++ b/qpid/cpp/bindings/swig_perl_typemaps.i
@@ -47,7 +47,9 @@
return qpid::types::Variant((float)SvNV(value));
}
else if (SvPOK(value)) {
- return qpid::types::Variant(std::string(SvPV_nolen(value)));
+ STRLEN len;
+ char *ptr = SvPV(value, len);
+ return qpid::types::Variant(std::string(ptr, len));
}
}
return qpid::types::Variant();