Subject: | Possible problem with greedy regexp |
The regexps in the parse_message method are possibly problematic,
because the .* is greedy and might "eat" too much of the strings,
leading to wrong matches. I think this should be fixed, see the patch in
the attachment.
Regards,
Slaven
Subject: | 0001-made-the-regexp-in-parse_message-non-greedy.patch |
From d84e95d3bd82613e3adaf4063edb31132b64936b Mon Sep 17 00:00:00 2001
From: Slaven Rezic <slaven@rezic.de>
Date: Fri, 29 May 2009 14:39:52 +0200
Subject: [PATCH 1/2] made the regexp in parse_message non-greedy
---
lib/Net/UCP.pm | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/Net/UCP.pm b/lib/Net/UCP.pm
index 2f5bd46..3a4f913 100644
--- a/lib/Net/UCP.pm
+++ b/lib/Net/UCP.pm
@@ -515,7 +515,7 @@ sub parse_message {
my $ref_mess = undef;
- if ($resp =~ m/^\d{2}\/\d{5}\/.*\/01\/.*/) { $ref_mess = $self->parse_01($resp) }
+ if ($resp =~ m/^\d{2}\/\d{5}\/.*?\/01\/.*/) { $ref_mess = $self->parse_01($resp) }
elsif ($resp =~ m/^\d{2}\/\d{5}\/.*\/02\/.*/) { $ref_mess = $self->parse_02($resp) }
elsif ($resp =~ m/^\d{2}\/\d{5}\/.*\/03\/.*/) { $ref_mess = $self->parse_03($resp) }
elsif ($resp =~ m/^\d{2}\/\d{5}\/.*\/30\/.*/) { $ref_mess = $self->parse_30($resp) }
--
1.6.3.1