[Catalyst] Extra characters inserted into PDF output

Dr. Jennifer Nussbaum bg271828 at yahoo.com
Wed Dec 3 11:59:54 GMT 2008


--- On Tue, 12/2/08, Steve Sabljak <steve at sabljak.org> wrote:

> From: Steve Sabljak <steve at sabljak.org>
> Subject: Re: [Catalyst] Extra characters inserted into PDF output
> To: bg271828 at yahoo.com, "The elegant MVC web framework" <catalyst at lists.scsys.co.uk>
> Date: Tuesday, December 2, 2008, 10:55 PM
> On Wed, Dec 3, 2008 at 2:41 PM, Dr. Jennifer Nussbaum
> <bg271828 at yahoo.com> wrote:
> >
> > --- On Tue, 12/2/08, Steve Sabljak
> <steve at sabljak.org> wrote:
> >
> >> From: Steve Sabljak <steve at sabljak.org>
> >> Subject: Re: [Catalyst] Extra characters inserted
> into PDF output
> >> To: "The elegant MVC web framework"
> <catalyst at lists.scsys.co.uk>
> >> Date: Tuesday, December 2, 2008, 6:30 PM
> >> On Wed, Dec 3, 2008 at 5:25 AM, Dr. Jennifer
> Nussbaum
> >> <bg271828 at yahoo.com> wrote:
> >> > --- On Tue, 12/2/08, Robin Berjon
> >> <robin at berjon.com> wrote:
> >> >
> >> >> From: Robin Berjon
> <robin at berjon.com>
> >> >> Subject: Re: [Catalyst] Extra characters
> inserted
> >> into PDF output
> >> >> To: bg271828 at yahoo.com, "The elegant
> MVC web
> >> framework" <catalyst at lists.scsys.co.uk>
> >> >> Date: Tuesday, December 2, 2008, 8:57 AM
> >> >> On Dec 2, 2008, at 17:02 , Dr. Jennifer
> Nussbaum
> >> wrote:
> >> >> > My PDF files are being uploaded and
> saved in
> >> the
> >> >> database apparently correctly. Then what
> seems to
> >> be
> >> >> happening is that somewhere in the binary
> stream
> >> of PDF,
> >> >> there is a (random) sequence of
> "<!",
> >> and
> >> >> somewhere later there is a
> ">". And
> >> something
> >> >> is inserting a "--" before the
> >> ">".
> >> >> >
> >> >> > My debugging statements show that
> Catalyst is
> >> >> outputting the correct size of the file,
> which
> >> suggests that
> >> >> the insertion is happening elsewhere.
> >> >>
> >> >> The one thing you're not saying is
> under what
> >> Catalyst
> >> >> is running when it's producing that.
> Are you
> >> running
> >> >> FastCGI? Mod_perl? Stand-alone
> development server?
> >> >
> >> > This happens both under the standalone server
> and
> >> under Apache/mod_perl.
> >> >
> >> >> If it happens in all of those then the
> bug is
> >> probably in
> >> >> your code (though after your debugging
> >> statements).
> >> >
> >> > Ive shown all the code for the view, so you
> can see
> >> anything that happens after the debugging....
> >> >
> >> >> If the
> >> >> insertion is indeed happening outside
> that pretty
> >> much just
> >> >> leaves the Web server, or perhaps a
> proxy. Wild
> >> stab in the
> >> >> dark: do you happen to have SSI turned
> on?
> >> >
> >> > Yes, but only on the actual server. My dev
> box running
> >> the standalone server isnt doing any SSI's.
> >> >
> >> > This is baffling.
> >> >
> >> > Jen
> >> >
> >>
> >> So, if you use (literally)
> >>
> >>
> $c->res->output('XXXXX<!XXXXXX>XXXXX');
> >>
> >> does it output
> 'XXXXX<!XXXXX-->XXXXX'?
> >> (you might want to change the content-type to
> text/plain
> >> for this test
> >> if testing with a browser)
> >
> > I dont know if this was a rhetorical question designed
> to show how stupid i am, or a real question, but the answer
> is "yes". Or, rather, if I change my output
> routine to
> >
> >
> $c->res->output('XXXXX<!XXXXXX>XXXXX');
> $c->res->content_type('text/plain');
> >
> > Then what i get in my browser is:
> >
> > XXXXX<!--XXXXXX-->XXXXX
> >
> > Where does this leave me? WHY is this happening?
> >
> > Jen
> >
> 
> No, not rhetorical or designed to do anything, just trying
> to narrow
> down where it's happening. Do the extra characters get
> inserted when
> you do this?
> 
> require bytes;
> 
> my $content = 'XXXXX<!XXXXXX>XXXXX';
> $c->res->content_type('text/plain');
> $c->res->content_length(bytes::length($content));
> $c->finalize_headers
> $c->write($content);
> 
> Does that still insert the unwanted chars?

Two interesting things. First, *NO*, that does *NOT* display the unwanted characters. Wow.

Second, in response to an off-list suggestion from Tom Doran, i created a test app in which the only thing i did was change the index method in Controller/Root from the "hellow orld " welcome message to

 $c->res->output('XXXXX<!XXXXXX>XXXXX'); 
 $c->res->content_type('text/plain');

And that also does *NOT* display the unwanted characters.

This suggetsts that its something in my plugins or app that is doing this. But i still cant see where. My plugin line is:

use Catalyst qw/ConfigLoader Authentication Authorization::Roles Session Session::Store::DBIC Session::State::Cookie Static::Simple RequireSSL FormValidator FillInForm/;

and my only end processing (someone else asked about this) is:

sub render : ActionClass('RenderView') { }

sub end : Private { 
  my ( $self, $c ) = @_;
  $c->forward('render');
  if (defined $c->stash->{edit_data} ) {
    $c->fillform( $c->stash->{edit_data} );
  } else {
    $c->fillform;
  }
}

If there is a response body RenderView is supposed to do nothing; and...
hmm...

This looks like it's going to call fillform() even if theres a response set... <Jen codes>

THATS IT!

I just added "return if $c->response->body;" after the forward and it works! Nothing inserted! The problem was with fillform all the time.

Thank you, thank you all for helping me in such detail! I never would have gotten there on my own.

Should the docs be clarified? In the firs tpart of the FillInForm docs there *IS* something about skipping the view if output is set, but at the bottom where it talks about RenderView (which must be where i got this) it DOESNT say this.

Thank you all again!

Jen



      



More information about the Catalyst mailing list