Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
kid's XML() and not well-formed issues.
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
  8 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
 
Olli  
View profile  
 More options Sep 11 2006, 6:11 am
From: "Olli" <olliw...@gmail.com>
Date: Mon, 11 Sep 2006 10:11:18 -0000
Local: Mon, Sep 11 2006 6:11 am
Subject: kid's XML() and not well-formed issues.
hi, I'm interesting to Markup. But I got some question about it. Think
about I have a guestbook form which let people to fill but it may
contain HTML tags, and even badly they are invalid XHTML. I originally
use kid but now looking for a replacement because kid can't handle not
well-formed XHTML. Cheetah and Django is on my list, but I like the kid
style more than others. I found this

"""It is possible to include markup that is not well-formed in the
output (which you may need to do in some cases). And if you need to
include bad HTML markup but would like to still produce valid output,
Markup provides a HTML-sanitizing stream filter."""

on markup's website, but I still totally have no idea how to use it, is
it possible to be use in .html file simply and directly? and another
questioin, is there a XML()-like function with Markup? thanks.


 
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.
Christopher Lenz  
View profile  
 More options Sep 11 2006, 6:52 am
From: Christopher Lenz <cml...@gmx.de>
Date: Mon, 11 Sep 2006 12:52:34 +0200
Local: Mon, Sep 11 2006 6:52 am
Subject: Re: kid's XML() and not well-formed issues.
Hi Olli,

Am 11.09.2006 um 12:11 schrieb Olli:

See:

   <http://markup.edgewall.org/wiki/
MarkupFaq#HowcanIincludeliteralXMLintemplateoutput>

For something like a guestbook or forum, I'd propose you parse the  
HTML and sanitize it. In your controller code, you'd do something  
like this:

   from markup.input import HTML
   from markup.filters import HTMLSanitizer

   content = # fetch submission string from database
   template.generate(content=HTML(content).filter(HTMLSanitizer()))

The other option is using the Markup class, but I wouldn't recommend  
that here, because you easily open your site to XSS attacks:

   from markup.core import Markup

   content = # fetch submission string from database
   template.generate(content=Markup(content))

In both cases, you can simply substitute ${content} in the template,  
and it will not be escaped.

Hope this helps,
Chris
--
Christopher Lenz
   cmlenz at gmx.de
   http://www.cmlenz.net/


 
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.
Olli  
View profile  
 More options Sep 11 2006, 6:57 am
From: "Olli" <olliw...@gmail.com>
Date: Mon, 11 Sep 2006 10:57:23 -0000
Local: Mon, Sep 11 2006 6:57 am
Subject: Re: kid's XML() and not well-formed issues.
thank you very much. That's what I need.

BTW, is it possible to enhance the performance in future?


 
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.
Christopher Lenz  
View profile  
 More options Sep 11 2006, 7:55 am
From: Christopher Lenz <cml...@gmx.de>
Date: Mon, 11 Sep 2006 13:55:39 +0200
Local: Mon, Sep 11 2006 7:55 am
Subject: Re: kid's XML() and not well-formed issues.
Am 11.09.2006 um 12:57 schrieb Olli:

> thank you very much. That's what I need.

> BTW, is it possible to enhance the performance in future?

I'm constantly looking into ways to improve the performance. I'm not  
sure at this point whether it'll be possible to achieve a drastic  
improvement... if I had found a way, I would've done it already ;-)

Markup should already be faster than Kid in most (all?) cases, but I  
do think there's still room in a couple of places where performance  
could be improved.

Are you asking because templating performance has been an actual  
issue for you?

Cheers,
Chris
--
Christopher Lenz
   cmlenz at gmx.de
   http://www.cmlenz.net/


 
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.
Olli  
View profile  
 More options Sep 11 2006, 8:30 am
From: "Olli" <olliw...@gmail.com>
Date: Mon, 11 Sep 2006 12:30:45 -0000
Local: Mon, Sep 11 2006 8:30 am
Subject: Re: kid's XML() and not well-formed issues.
yes. because I need to develop a long-term and large-scale web-app.
however, you did a good job, thanks, Chris. :)

 
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.
Olli  
View profile  
 More options Sep 11 2006, 2:46 pm
From: "Olli" <olliw...@gmail.com>
Date: Mon, 11 Sep 2006 18:46:24 -0000
Local: Mon, Sep 11 2006 2:46 pm
Subject: Re: kid's XML() and not well-formed issues.
Hi, Chris. I got another problem with HTMLSanitizer, that is, the
variable after filtering by HTMLSanitizer will can be use only once in
.html file. for example:

# in the .py file
content = 'This is a test.'
content = HTML(content).filter(HTMLSanitizer())
greeting = "Hello World!"

# And in the .html file
${greeting}
<span py:content="content">Content goes here</span>
${greeting}
<span py:content="content">Content goes here</span>

# The actually output
Hello World! This is a test.  Hello World!

# However, it should be..
Hello World! This is a test.  Hello World! This is a test.

I tested this with TurboGears. so is it normal?


 
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.
Oliver Cope  
View profile  
 More options Sep 11 2006, 4:07 pm
From: "Oliver Cope" <oliver.c...@gmail.com>
Date: Mon, 11 Sep 2006 21:07:35 +0100
Local: Mon, Sep 11 2006 4:07 pm
Subject: Re: kid's XML() and not well-formed issues.
On 9/11/06, Olli <olliw...@gmail.com> wrote:

I think this is because of the concept of event streams.
'HTML(content)' converts whatever is in 'content' into a stream of
events which may then be rendered. But once rendered the stream is
exhausted, and I don't think there is a way to reset it back to the
beginning. This is why it is empty the second time around.

Moving the stream generation/filtering into the template should work,
because then you can generate two independent streams:

  .py:
    content = 'This is a test.'
    greeting = "Hello World!"

  .html:
    ${greeting}
    <span py:content="HTML(content).filter(HTMLSanitizer())">Content
goes here</span>
    ${greeting}
    <span py:content="HTML(content).filter(HTMLSanitizer())">Content
goes here</span>

You'll need to put HTML and HTMLSanitizer into the template's
namespace to do this. I don't know turbogears so can't advise on how
to do this.

Olly.


 
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.
Matt Good  
View profile  
 More options Sep 11 2006, 7:45 pm
From: "Matt Good" <m...@matt-good.net>
Date: Mon, 11 Sep 2006 16:45:14 -0700
Local: Mon, Sep 11 2006 7:45 pm
Subject: Re: kid's XML() and not well-formed issues.

Parsing and filtering the content twice is redundant.  If you really
need to reuse the stream you should expand it into a list so it can be
reused:

content = list(HTML(content).filter(HTMLSanitizer()))

-- Matt Good


 
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 »