Re: url_for and ampersands encoding
On 3/27/07, Max Ischenko [EMAIL PROTECTED] wrote: Hi, I am trying to validate my XHTML page (generated with Pylons/Mako) and got an error: http://validator.w3.org/check?uri=http%3A%2F%2Ftesting.developers.org.ua%2F Warning Line 104 column 41: cannot generate system identifier for general entity norestart. | a href=/_pylons/selfupdate?svnup=yesnorestart=yesUpdate/a Obviously, w3c validators expects to be encoded as amp; while it isn't. The url in question is generated with | a href=${h.url_for(controller='selfupdate', svnup='yes', norestart='yes')}Update/a What should I do to automatically convert to amp;? Do I need to write a Mako filter? Does current behaviour correct/expected? Oh oh oh!!! I wrote all about this here: http://jjinux.blogspot.com/2006/03/html-escaping-s-in-urls-in-html.html Happy Hacking! -jj -- http://jjinux.blogspot.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: url_for and ampersands encoding
On 3/27/07, Ian Bicking [EMAIL PROTECTED] wrote: Max Ischenko wrote: Hi, I am trying to validate my XHTML page (generated with Pylons/Mako) and got an error: http://validator.w3.org/check?uri=http%3A%2F%2Ftesting.developers.org.ua%2F Warning /Line 104 column 41/: cannot generate system identifier for general entity norestart. || a href=/_pylons/selfupdate?svnup=yes*n*orestart=yesUpdate/a| Obviously, w3c validators expects to be encoded as amp; while it isn't. The url in question is generated with | a href=${h.url_for(controller='selfupdate', svnup='yes', norestart='yes')}Update/a What should I do to automatically convert to amp;? Do I need to write a Mako filter? Does current behaviour correct/expected? A filter is the right way to handle this. The URL shouldn't have amp; in it. That's just the way you encode in an HTML attribute. If you put it in a Javascript string literal it definitely shouldn't be encoded. Templating languages that auto-encode or know the structure of HTML will get this right (e.g., ZPT, Genshi, etc.). IMHO Mako should encode strings by default too. But either way, it's a template concern, not something url_for should handle. Absolutely. Per my blog, if you escape things automatically, it'll break url_for when url_for is used to generated URLs for redirects that contain more than a single parameter ;) This is one place where Genshi helps me do the right thing automatically. Happy Hacking! -jj -- http://jjinux.blogspot.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: url_for and ampersands encoding
Max Ischenko wrote: I am trying to validate my XHTML page (generated with Pylons/Mako) and got an error: http://validator.w3.org/check?uri=http%3A%2F%2Ftesting.developers.org.ua%2F Warning *Line 104 column 41*: cannot generate system identifier for general entity norestart. | a href=/_pylons/selfupdate?svnup=yes*n*orestart=yesUpdate/a Obviously, w3c validators expects to be encoded as amp; while it isn't. The url in question is generated with | a href=${h.url_for(controller='selfupdate', svnup='yes', norestart='yes')}Update/a What should I do to automatically convert to amp;? Do I need to write a Mako filter? Does current behaviour correct/expected? I went through the same issue last week and meant to write it up. I ended up adding a new helper in lib/helpers.py: import cgi def my_url_for(*args, **kargs): u = url_for(*args, **kargs) return cgi.escape(u, True) and call my_url_for wherever url_for was called. This correctly escapes the and passes the validator. This should probably be added to Routes - Ben? HTH Robert --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: url_for and ampersands encoding
Hello Robert, On Mar 27, 1:33 pm, Robert Leftwich [EMAIL PROTECTED] wrote: Obviously, w3c validators expects to be encoded as amp; while it isn't. The url in question is generated with | a href=${h.url_for(controller='selfupdate', svnup='yes', norestart='yes')}Update/a What should I do to automatically convert to amp;? This should probably be added to Routes - Ben? Thanks for quick reply. I added a mako filter to handle this but I agree, this should be part of Routes. Max. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: url_for and ampersands encoding
Max Ischenko wrote: Hi, I am trying to validate my XHTML page (generated with Pylons/Mako) and got an error: http://validator.w3.org/check?uri=http%3A%2F%2Ftesting.developers.org.ua%2F Warning /Line 104 column 41/: cannot generate system identifier for general entity norestart. || a href=/_pylons/selfupdate?svnup=yes*n*orestart=yesUpdate/a| Obviously, w3c validators expects to be encoded as amp; while it isn't. The url in question is generated with | a href=${h.url_for(controller='selfupdate', svnup='yes', norestart='yes')}Update/a What should I do to automatically convert to amp;? Do I need to write a Mako filter? Does current behaviour correct/expected? A filter is the right way to handle this. The URL shouldn't have amp; in it. That's just the way you encode in an HTML attribute. If you put it in a Javascript string literal it definitely shouldn't be encoded. Templating languages that auto-encode or know the structure of HTML will get this right (e.g., ZPT, Genshi, etc.). IMHO Mako should encode strings by default too. But either way, it's a template concern, not something url_for should handle. -- Ian Bicking | [EMAIL PROTECTED] | http://blog.ianbicking.org | Write code, do good | http://topp.openplans.org/careers --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---