Escaping quotes in arguments to p(...)

2 views
Skip to first unread message

James A. Bowery

unread,
Dec 5, 2009, 8:22:40 AM12/5/09
to meteorserver
I'm trying to send a message like this:

ADDMESSAGE 3794334353 <a href="javascript:document.getElementById
('message').value='886-381-9569 20091205130006'">886-381-9569
20091205130006</a>

The problem is, it gets written out as this:

Sat Dec 5 13:00:33 2009 debug Contents <script>p
(4,"3794334353","<a href="javascript:document.getElementById
('message').value='886-381-9569 20091205130006'">886-381-9569
20091205130006</a></script>

This, of course, fails due to the lack of appropriate escapes for
embedded double quotes.

The proper place to escape the double quotes would seem to be in the
template processing since that's where the knowledge that the entire
string is being quoted as an argument to the p(...) function, but
there doesn't appear to be any mechanism in the template processor to
impose appropriate escaping within templates that enclose arguments in
quotes.

James Bowery

unread,
Dec 5, 2009, 9:15:20 AM12/5/09
to meteorserver
This is what I ended up doing:

sub newWithID {
        #
        # new instance from new server connection
        #
        my $self=shift->new();
        my $id=shift;
        my $text=shift || '';

        $self->{'timestamp'}=time;
        $self->{'id'}=$id;
        $text=~s/"/\\"/g;
        $self->{'text'}=$text;

        $::Statistics->{'unique_messages'}++;

        $self;
}

###############################################################################
# Instance methods
###############################################################################
sub setText {
        my $self=shift;
        my $text=shift || '';
        $text=~s/"/\\"/g;
        $self->{'text'}=$text;
}

sub channelName {
        shift->{'channel'};
}

sub setChannelName {
        my $self=shift;
        my $channelName=shift || '';

        $self->{'channel'}=$channelName;
}

sub text {
        my $tmp=shift->{'text'};
        $tmp=~s/\\"/"/g;
        return $tmp;
}



--

You received this message because you are subscribed to the Google Groups "meteorserver" group.
To post to this group, send email to meteor...@googlegroups.com.
To unsubscribe from this group, send email to meteorserver...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/meteorserver?hl=en.



Andrew Betts

unread,
Jan 12, 2010, 6:03:13 AM1/12/10
to meteorserver
James,

This has been discussed fairly extensively before, with the conclusion
that if this is to be supported in Meteor, Meteor's templates need to
change to be perl classes that can do their own string processing. We
don't wishto include string escaping in the core codebase because each
application may need to escape its message text differently.

I don't have any plans to implement this right now, but very happy to
support someone else doing so.

Andrew

> > meteorserver...@googlegroups.com<meteorserver%2Bunsu...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages