Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Issues with escaping of strings
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Aaron  
View profile  
 More options Oct 18, 11:37 am
From: Aaron <aaron...@gmail.com>
Date: Sun, 18 Oct 2009 08:37:28 -0700 (PDT)
Local: Sun, Oct 18 2009 11:37 am
Subject: Issues with escaping of strings
I just found out the hard way that a "\" character is not escaped when
passed to a client. Injecting some message ending with a \ can cause a
javascript syntax error on the client.

If meteor is deployed on a site where a user can inject traffic into
it, a user might be able to crash all connected meteor clients
connected streams.

Can someone with access to the official code please change it to
replace all "\" with "\\" before serving to connected clients?

Thanks,

Aaron


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin Peno  
View profile  
 More options Oct 18, 1:10 pm
From: Kevin Peno <kevinp...@gmail.com>
Date: Sun, 18 Oct 2009 10:10:45 -0700
Local: Sun, Oct 18 2009 1:10 pm
Subject: Re: Issues with escaping of strings

This has been brought up before. The reasoning behind the lack of escaping
is that meteor is designed to be client agnostic (which most people seem to
agree on). So, because of this, you will need to escapse said strings
yourself.

For more on the debate and the ultimate decision, please see this thread:

http://groups.google.com/group/meteorserver/browse_thread/thread/d984...

I had made a suggestion there to allow for "plugins" that determined the
output (thus handling odd cases like string escaping), but no response was
given.

Kevin Peno


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron  
View profile  
 More options Oct 19, 12:16 pm
From: Aaron <aaron...@gmail.com>
Date: Mon, 19 Oct 2009 09:16:47 -0700 (PDT)
Local: Mon, Oct 19 2009 12:16 pm
Subject: Re: Issues with escaping of strings
Ah, I should have searched but I just assumed it was a bug. I had no
idea meteor aimed to be client agnostic. I assumed JS + Flash would be
about it.
I don't know if I like the idea of plugin's though, they introduce
overhead in the form of plugin management and the only one I can think
of is escaping.

The server documentation states this:

Message template, content to send for each event: ~text~, ~id~,
~channel~ and ~timestamp~ will be replaced by the appropriate values.
Format: String, Default: <script>p(~id~,"~channel~","~text~");</script>
\r\n

What about just adding an ~escapedtext~ as a possible argument? All
format agnostic behaviour will continue to function as is and the only
thing that needs to change is the MessageTemplate for the javascript
case.

Patch below if someone likes this idea enough to push it into the main
repo.

Aaron

-----------------

diff --git a/meteor_daemon/Meteor/Config.pm b/meteor_daemon/Meteor/
Config.pm
index 6309b1d..3f2849e 100644
--- a/meteor_daemon/Meteor/Config.pm
+++ b/meteor_daemon/Meteor/Config.pm
@@ -85,7 +85,7 @@ package Meteor::Config;
        MaxTime                                 => 0,

 'Message template, ~text~, ~id~, ~channel~ and ~timestamp~ will be
replaced by the appropriate values',
-       MessageTemplate                 => '<script>p
(~id~,"~channel~","~text~");</script>\r\n',
+       MessageTemplate                 => '<script>p
(~id~,"~channel~","~escapedtext~");</script>\r\n',

 'Interval at which PingMessage is sent to all persistent subscriber
connections. Must be at least 3 if set higher than zero. Set to zero
to disable.',
        PingInterval                    => 5,
@@ -395,4 +395,4 @@ EOT
 }

diff --git a/meteor_daemon/Meteor/Message.pm b/meteor_daemon/Meteor/
Message.pm
index eb9ac03..dee2c81 100644
--- a/meteor_daemon/Meteor/Message.pm
+++ b/meteor_daemon/Meteor/Message.pm
@@ -61,6 +61,8 @@ sub newWithID {
        $self->{'timestamp'}=time;
        $self->{'id'}=$id;
        $self->{'text'}=$text;
+       $self->{'escapedtext'} = $text;
+       $self->{'escapedtext'} =~ s/\\/\\\\/g;

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

@@ -75,6 +77,8 @@ sub setText {
        my $text=shift || '';

        $self->{'text'}=$text;
+       $self->{'escapedtext'} = $text;
+       $self->{'escapedtext'} =~ s/\\/\\\\/g;
 }

 sub channelName {
@@ -128,4 +132,4 @@ sub messageWithTemplate {
 }

On Oct 19, 2:10 am, Kevin Peno <kevinp...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Betts  
View profile  
 More options Oct 26, 7:15 am
From: Andrew Betts <andrew.be...@gmail.com>
Date: Mon, 26 Oct 2009 04:15:16 -0700 (PDT)
Local: Mon, Oct 26 2009 7:15 am
Subject: Re: Issues with escaping of strings
Kevin - sorry I didn't pick up on your plugin request in the earlier
thread.  I think implementing plugins could be interesting, and could
be done in a number of ways - it could be argued that right now the
ability to define differently named transports with different headers,
footers and message templates amounts to a plugin system, and in order
to achieve what is being discussed here, you only really need an
extension to this templating principle to allow for string
manipulation in the templates, rather than a more comprehensive plugin-
hook system.

So rather than simply dropping the data directly into template strings
defined in the config file, we could have Meteor check for the
existence of a filter class for that transport, and if one exists,
pass the output through the filter before it is inserted into the
template.

Such a solution would have a separation of the template content for a
transport from the string processing code that manipulates the data,
so for better encapsulation if may be better to simply have each
transport defined by a class that offers an interface for rendering
the necessary messages, for example (for a Meteor::Subscriber)

my $transport = Meteor::Transports->getTransport($self->{'mode'});
my $outputstring = $transport->renderMessage(id, channel, text);

And the template text for the message would be within the transport
class.

I don't really have the time to give to this right now, but if someone
wants to have a crack at it, feel free.

Aaron - Thanks for the suggestion but I disagree with ~escapedText~
because you're assuming that the escaping method that will be required
would be to simply prefix all \ characters with an extra \.  Escaping
for some situations might require this, but it's not a generic
solution so it would simply lead to a requirement for ~escapedText2~
when we come across someone that wants a different set of characters
to be escaped in a different way.

Andrew

On Oct 19, 4:16 pm, Aaron <aaron...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin Peno  
View profile  
 More options Oct 26, 12:51 pm
From: Kevin Peno <kevinp...@gmail.com>
Date: Mon, 26 Oct 2009 09:51:48 -0700
Local: Mon, Oct 26 2009 12:51 pm
Subject: Re: Issues with escaping of strings

Hey Andrew,

That's basically all I was speaking about. Just some sort of
filter/serializer check for the data itself based on an "Accept" header sent
in through the request headers. So that meteor could remain neutral and
serve multiple clients. The only thing I was suggetsing is that it was made
in a plugable fashion so that people could drop in custom filters at any
time.

-- Kevin

On Mon, Oct 26, 2009 at 4:15 AM, Andrew Betts <andrew.be...@gmail.com>wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron  
View profile  
 More options Oct 27, 5:23 am
From: Aaron <aaron...@gmail.com>
Date: Tue, 27 Oct 2009 02:23:00 -0700 (PDT)
Subject: Re: Issues with escaping of strings
Thanks for the reply Andrew,

Glad the project is still alive!

I figured my patch might be too much of a single-use-case to warrant
inclusion. :)

Second idea that is not-quite a plugin: Why not just support the
evaluation of a perl string specified in the config file?

- Aaron

On Oct 27, 1:51 am, Kevin Peno <kevinp...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google