qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcpie...@apache.org
Subject svn commit: r1416663 - in /qpid/branches/0.20/qpid/cpp/bindings: qpid/perl/test/ qpid/perl/test/test-null-inside-map.pl swig_perl_typemaps.i
Date Mon, 03 Dec 2012 21:06:47 GMT
Author: mcpierce
Date: Mon Dec  3 21:06:46 2012
New Revision: 1416663

URL: http://svn.apache.org/viewvc?rev=1416663&view=rev
Log:
QPID-4480: Fix handling in Perl of strings with embedded nulls.

Contributed by Jimmy Jones <jimmyjones2@gmx.co.uk>

Added:
    qpid/branches/0.20/qpid/cpp/bindings/qpid/perl/test/
    qpid/branches/0.20/qpid/cpp/bindings/qpid/perl/test/test-null-inside-map.pl
Modified:
    qpid/branches/0.20/qpid/cpp/bindings/swig_perl_typemaps.i

Added: qpid/branches/0.20/qpid/cpp/bindings/qpid/perl/test/test-null-inside-map.pl
URL: http://svn.apache.org/viewvc/qpid/branches/0.20/qpid/cpp/bindings/qpid/perl/test/test-null-inside-map.pl?rev=1416663&view=auto
==============================================================================
--- qpid/branches/0.20/qpid/cpp/bindings/qpid/perl/test/test-null-inside-map.pl (added)
+++ qpid/branches/0.20/qpid/cpp/bindings/qpid/perl/test/test-null-inside-map.pl Mon Dec  3
21:06:46 2012
@@ -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 ($@);

Modified: qpid/branches/0.20/qpid/cpp/bindings/swig_perl_typemaps.i
URL: http://svn.apache.org/viewvc/qpid/branches/0.20/qpid/cpp/bindings/swig_perl_typemaps.i?rev=1416663&r1=1416662&r2=1416663&view=diff
==============================================================================
--- qpid/branches/0.20/qpid/cpp/bindings/swig_perl_typemaps.i (original)
+++ qpid/branches/0.20/qpid/cpp/bindings/swig_perl_typemaps.i Mon Dec  3 21:06:46 2012
@@ -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();



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message