Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#3108 closed defect (fixed)

Image Macro fails to render with certain parameters

Reported by: jeremy at slappy . org Owned by: Christian Boos
Priority: normal Milestone: 0.10
Component: wiki system Version: 0.9.5
Severity: normal Keywords: image macro
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Certain macro image formatting options seem to have broken with 0.9.5. To reproduce:

  1. Attach an image called picture.jpg to a Wiki page
  2. Edit the wiki page to include the following macro:
    • [[Image(picture.jpg, 30%)]]
  3. Preview the new wiki page
  4. An error message should appear as follows:
    • Error: Macro Image(picture.jpg, 30%) failed
    • Not enough arguments for format string

Attachments (1)

escape-percent-image-macro.diff (566 bytes ) - added by drodrigueztroitino@… 18 years ago.
Patch for ImageMacro with '%' symbol in the attributes.

Download all attachments as: .zip

Change History (7)

comment:1 by jeremy at slappy . org, 18 years ago

A couple more comments:

  • These parameters were based on the instructions as specified on WikiMacros
  • In the reproduction instructions above, if you change 30% to 120px the Macro works as expected.

comment:2 by anonymous, 18 years ago

Version: 0.9.5

by drodrigueztroitino@…, 18 years ago

Patch for ImageMacro with '%' symbol in the attributes.

comment:3 by drodrigueztroitino@…, 18 years ago

The patch above escape the '%' symbol in the img_attr string so the Markup class don't try to substitute it.

Works for me in a 0.9.5 (Debian version, I think) installation of Trac.

Don't know if the bug rises in other macros, but it should be as simple as this patch to fix them.

comment:4 by stephane, 18 years ago

Milestone: 0.10
Version: 0.9.5

I have this problem on Windows too since I installed 0.9.5. I just patched the file and now it works.

Note: I inserted the line

img_attr = img_attr.replace('%', '%%')    # line 355

at line 355 and not at line 346 as shown in the diff (don't know if it's important, only to be precise)

The code now looks like:

    img_attr += ' style="%s"' % img_style # line 354
img_attr = img_attr.replace('%', '%%')    # line 355
result = Markup('<img src="%%s" %s />' % img_attr, raw_url).sanitize()

Conclusion:

  • I confirm the existence of this bug
  • I would like to see this very small patch in the next version.

Excuse me if I set the version to 0.9.5, and the milestone to 0.10 but it's so a small patch :-)

comment:5 by Christian Boos, 18 years ago

Owner: changed from Jonas Borgström to Christian Boos
Status: newassigned

I'll take care of this one.

comment:6 by Christian Boos, 18 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r3286 and r3287 for 0.9-stable.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.