Edgewall Software
Modify

Opened 11 years ago

Closed 11 years ago

#11391 closed enhancement (fixed)

Image macro's width argument may not be respected

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.2
Component: wiki system Version: 1.0-stable
Severity: normal Keywords: image macro
Cc: Branch:
Release Notes:

ZWSPs are stripped from arguments to the Image macro.

API Changes:
Internal Changes:

Description

Demonstrated in comment:1:ticket:11384 (see edited markup), the width argument of the Image macro may be ignored.

The issue seems to be that the filename initially has a ZWSP at the end, and after I edited the comment the result was wider then yellow part pls.jpg, 100%\u200b (after splitting content to args in expand_marco we get [u'wider then yellow part pls.jpg', u'100%\u200b'].

I guess we can fix the immediate issue with:

  • trac/wiki/macros.py

    diff --git a/trac/wiki/macros.py b/trac/wiki/macros.py
    index c53fec5..3f8d649 100644
    a b class ImageMacro(WikiMacroBase):  
    537537        except Exception:
    538538            browser_links = []
    539539        while args:
    540             arg = args.pop(0).strip()
     540            arg = stripws(args.pop(0))
    541541            if size_re.match(arg):
    542542                # 'width' keyword
    543543                attr['width'] = arg
  • trac/wiki/tests/macros.py

    diff --git a/trac/wiki/tests/macros.py b/trac/wiki/tests/macros.py
    index 5141285..7c38574 100644
    a b IMAGE_MACRO_TEST_CASES = u"""  
    130130------------------------------
    131131<a style="padding:0; border:none" href="/wiki/WikiStart"><img src="/browser/%C2
    132132============================== Strip unicode white-spaces and ZWSPs (#10668)
    133 [[Image(  <U+200B>source:« test ».png  <U+200B>, nolink)]]
     133[[Image(  <U+200B>source:« test ».png  <U+200B>, nolink, 100%  <U+200B>)]]
    134134------------------------------
    135135<p>
    136 <img src="/browser/%C2%AB%20test%C2%A0%C2%BB.png?format=raw" alt="source:« test
     136<img width="100%" alt="source:« test ».png" title="source:« test ».png" src="/b
    137137</p>
    138138------------------------------
    139 <img src="/browser/%C2%AB%20test%C2%A0%C2%BB.png?format=raw" alt="source:« test
     139<img width="100%" alt="source:« test ».png" title="source:« test ».png" src="/b
    140140------------------------------
    141141============================== Attachments on page with ':' characters (#10562)
    142142[[Image("page:fr":img.png<U+200B>,nolink)]]

Perhaps this would all be more robust by utilizing a function such as parse_args. I previously made an attempt at refactoring Image macro to use parse_args in comment:6:ticket:10751. Maybe that should be revisted.

Attachments (0)

Change History (2)

comment:1 by Ryan J Ollos, 11 years ago

Status: newassigned

comment:2 by Ryan J Ollos, 11 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed to 1.0-stable in [12313] and merged to trunk in [12314].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos 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.