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 |
||
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): 537 537 except Exception: 538 538 browser_links = [] 539 539 while args: 540 arg = args.pop(0).strip()540 arg = stripws(args.pop(0)) 541 541 if size_re.match(arg): 542 542 # 'width' keyword 543 543 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""" 130 130 ------------------------------ 131 131 <a style="padding:0; border:none" href="/wiki/WikiStart"><img src="/browser/%C2 132 132 ============================== 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>)]] 134 134 ------------------------------ 135 135 <p> 136 <img src="/browser/%C2%AB%20test%C2%A0%C2%BB.png?format=raw" alt="source:« test136 <img width="100%" alt="source:« test ».png" title="source:« test ».png" src="/b 137 137 </p> 138 138 ------------------------------ 139 <img src="/browser/%C2%AB%20test%C2%A0%C2%BB.png?format=raw" alt="source:« test139 <img width="100%" alt="source:« test ».png" title="source:« test ».png" src="/b 140 140 ------------------------------ 141 141 ============================== Attachments on page with ':' characters (#10562) 142 142 [[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 , 11 years ago
Status: | new → assigned |
---|
comment:2 by , 11 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Committed to 1.0-stable in [12313] and merged to trunk in [12314].