[Bug 300720] [NEW] $ in collected content causes "Invalid placeholder in string:"

10 views
Skip to first unread message

russf

unread,
Nov 21, 2008, 10:26:16 AM11/21/08
to singing...@googlegroups.com
Public bug reported:

collective.dancing-0.8.1-py2.4.egg

2008-11-21 14:45:25 ERROR Zope.SiteErrorLog http://.../preview-newsletter.html
Traceback (innermost last):
Module ZPublisher.Publish, line 119, in publish
Module ZPublisher.mapply, line 88, in mapply
Module Products.PDBDebugMode.pdbzope.runcall, line 60, in pdb_runcall
Module ZPublisher.Publish, line 42, in call_object
Module collective.dancing.browser.preview, line 62, in __call__
Module collective.singing.scheduler, line 99, in render_message
Module collective.dancing.composer, line 224, in render
Module string, line 172, in substitute
Module string, line 169, in convert
Module string, line 145, in _invalid

(Pdb) l
140 colno = 1
141 lineno = 1
142 else:
143 colno = i - len(''.join(lines[:-1]))
144 lineno = len(lines)
145 -> raise ValueError('Invalid placeholder in string: line %d, col %d' %
146 (lineno, colno))
147
148 def substitute(self, *args, **kws):
149 if len(args) > 1:
150 raise TypeError('Too many positional arguments')
(Pdb)
(Pdb) lines[-1:]
[u'<p>As its stock market dropped almost 80 percent, Iceland said it drew $']

Replacement stopped after the $ in "Iceland said it drew $273.2 million"

It's bad practise to do a string replace like this on 'open' text that
one has no control over. Especially in a $ dominated world. So I
suppose replaces could be done on header, footer and so on, separately,
and leave the body of the collected text out of this wholesale replace??

Gotta dump'n'run, but may be able to get back to this myself.

Best,
--r.

** Affects: singing-dancing
Importance: Undecided
Status: New

--
$ in collected content causes "Invalid placeholder in string:"
https://bugs.launchpad.net/bugs/300720
You received this bug notification because you are a member of Singing &
Dancing developers, which is the registrant for Singing & Dancing.

Status in Singing & Dancing: New

Bug description:
collective.dancing-0.8.1-py2.4.egg

2008-11-21 14:45:25 ERROR Zope.SiteErrorLog http://.../preview-newsletter.html
Traceback (innermost last):
Module ZPublisher.Publish, line 119, in publish
Module ZPublisher.mapply, line 88, in mapply
Module Products.PDBDebugMode.pdbzope.runcall, line 60, in pdb_runcall
Module ZPublisher.Publish, line 42, in call_object
Module collective.dancing.browser.preview, line 62, in __call__
Module collective.singing.scheduler, line 99, in render_message
Module collective.dancing.composer, line 224, in render
Module string, line 172, in substitute
Module string, line 169, in convert
Module string, line 145, in _invalid

(Pdb) l
140 colno = 1
141 lineno = 1
142 else:
143 colno = i - len(''.join(lines[:-1]))
144 lineno = len(lines)
145 -> raise ValueError('Invalid placeholder in string: line %d, col %d' %
146 (lineno, colno))
147
148 def substitute(self, *args, **kws):
149 if len(args) > 1:
150 raise TypeError('Too many positional arguments')
(Pdb)
(Pdb) lines[-1:]
[u'<p>As its stock market dropped almost 80 percent, Iceland said it drew $']

Replacement stopped after the $ in "Iceland said it drew $273.2 million"

It's bad practise to do a string replace like this on 'open' text that one has no control over. Especially in a $ dominated world. So I suppose replaces could be done on header, footer and so on, separately, and leave the body of the collected text out of this wholesale replace??

Gotta dump'n'run, but may be able to get back to this myself.

Best,
--r.

russf

unread,
Nov 22, 2008, 10:33:11 AM11/22/08
to singing...@googlegroups.com
Problem occurs in
html = string.Template(html).substitute(subscription_vars)
because $ occur in collected text, and they don't always conform to the placeholder syntax.

There were four uses of substitute in composer. Now replaced with
safe_substitute. There may be other instances of substitute in S&D that
need correction.

Committed revision 76316.

--r.

** Changed in: singing-dancing
Assignee: (unassigned) => russf (russf)
Status: New => Fix Committed

--
$ in collected content causes "Invalid placeholder in string:"
https://bugs.launchpad.net/bugs/300720
You received this bug notification because you are a member of Singing &
Dancing developers, which is the registrant for Singing & Dancing.

Status in Singing & Dancing: Fix Committed

Daniel Nouri

unread,
Nov 23, 2008, 7:44:46 AM11/23/08
to singing...@googlegroups.com
Thanks for the fix. It would be nice to have a regression test that
fails without the fix applied and works with it. Adding $ somewhere in
the text of some item in browser.txt should do.

--
$ in collected content causes "Invalid placeholder in string:"
https://bugs.launchpad.net/bugs/300720
You received this bug notification because you are a member of Singing &
Dancing developers, which is the registrant for Singing & Dancing.

Status in Singing & Dancing: Fix Committed

Russ Ferriday

unread,
Nov 23, 2008, 8:10:28 AM11/23/08
to singing...@googlegroups.com

On 23 Nov 2008, at 12:44, Daniel Nouri wrote:

> Thanks for the fix.
Needed to be done!

> It would be nice to have a regression test that
> fails without the fix applied and works with it. Adding $ somewhere
> in

> the text of some item in browser.txt should do.\

It's part of the commit.
Checkout "My Bonnie" ;)
--r.

>
>
> --
> $ in collected content causes "Invalid placeholder in string:"
> https://bugs.launchpad.net/bugs/300720

> You received this bug notification because you are a direct subscriber
> of the bug.

Russ Ferriday - Topia Systems - Open Source content management with
Plone and Zope
ru...@topia.com - office: +44 2076 1777588 - mobile: +44 7789 338868 -
skype: ferriday

tmog

unread,
Nov 24, 2008, 4:35:25 AM11/24/08
to singing...@googlegroups.com
Perfect Russ!
Thanks for correcting my brain fart. ;-)

--
$ in collected content causes "Invalid placeholder in string:"
https://bugs.launchpad.net/bugs/300720
You received this bug notification because you are a member of Singing &
Dancing developers, which is the registrant for Singing & Dancing.

Status in Singing & Dancing: Fix Committed

Daniel Widerin

unread,
Dec 3, 2008, 3:28:17 PM12/3/08
to singing...@googlegroups.com
This is part of collective.dancing 0.8.3 and collective.singing 0.6.7

** Changed in: singing-dancing
Status: Fix Committed => Fix Released

--
$ in collected content causes "Invalid placeholder in string:"
https://bugs.launchpad.net/bugs/300720
You received this bug notification because you are a member of Singing &
Dancing developers, which is the registrant for Singing & Dancing.

Status in Singing & Dancing: Fix Released

Reply all
Reply to author
Forward
0 new messages