BUG: newlines within attributes?

Bruno Postle <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
It seems that Petal processes these two differently:

  <div petal:content="string:
    plum">xxx</div>

  <div petal:content="string: pear">xxx</div>

The first one gets 'half processed'.  I was under the impression 
that Petal should be whitespace insensitive here.

Attached a test case, Could somebody else confirm that I'm really 
looking at such an obvious bug?

The following one-liner fixes it for me.  Are there any valid 
reasons for preserving newlines within attributes?

Index: lib/Petal/Parser.pm
===================================================================
RCS file: /var/spool/cvs/Petal/lib/Petal/Parser.pm,v
retrieving revision 1.5
diff -u -r1.5 Parser.pm
--- lib/Petal/Parser.pm 9 Jul 2004 11:09:34 -0000       1.5
+++ lib/Petal/Parser.pm 9 Sep 2005 16:07:22 -0000
@@ -114,6 +114,8 @@
     local %_ = %{shift()};
     delete $_{'/'};

+    foreach my $key (keys %_) { $_{$key} =~ s/\n/ /g }
+
     # process the Petal namespace
     my $ns = (scalar @NameSpaces) ? $NameSpaces[$#NameSpaces] : $Petal::NS;
     foreach my $key (keys %_)

-- 
Bruno
091_attribute-newline.t (text/plain, 407 B)
#!/usr/bin/perl
use warnings;
use strict;
use lib ('lib');
use Test::More 'no_plan';
use Petal;

$Petal::BASE_DIR     = './t/data/';
$Petal::DISK_CACHE   = 0;
$Petal::MEMORY_CACHE = 0;
$Petal::TAINT        = 1;

my $string = Petal->new ('attribute-newline.xml')->process ();
like ($string, '/>apple</', '');
like ($string, '/>orange</', '');
like ($string, '/>plum</', '');
like ($string, '/>pear</', '');
attribute-newline.xml (text/plain, 248 B)
<stuff xmlns:petal="http://purl.org/petal/1.0/">

<div petal:define="foo
string: apple">$foo</div>
<div petal:define="bar string: orange">$bar</div>

<div petal:content="string:
plum">xxx</div>
<div petal:content="string: pear">xxx</div>

</stuff>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.