Opened 14 years ago
Closed 8 years ago
Last modified 8 years ago
#8168 closed defect (fixed)
wiki [[Image(URL)]] breaks when the URL contains commas
|Reported by:||Owned by:||Dirk Stöcker|
Arguments to the Image macro can be wrapped in single or double quotes to avoid splitting at commas.
I'm trying to publish a wiki page in my trac using a the Image Macro.
When I post an image like this:
There is no problem and the image is displayed correctly in the browser and when I focus on the image the URL context information (left botton corner is shown correctly).
But when I use a longest URL address like this:
The image is not displayed and the context information in my browser (left botton corner) only shows a truncated URL when I am on the place where should be the image. The url displayed has a length 74 characters. like this:
I have test it using Firefox, Explorer and Opera and the same problem.
Change History (16)
comment:1 by , 14 years ago
follow-up: 4 comment:2 by , 14 years ago
The syntax of the image macro is
[[Image(path, [args,] arg)]. Take for instance for the url
http://www.google.com/?image=1,2,3,4,5 then it will be parsed as the following:
The path is then wrong and since the arguments do not match the predefined argument list, they will simply be ignored.
One solution would be to have the path be everything that is before the first recognized argument. It would fix the issue for this ticket but what if the URL contains a valid argument, eg. :
title=test will be considered as an argument although it is part of the URL.
Another solution would be to introduce an escape character for the commas. The macro to insert the URL above would the be
What do you think ?
comment:3 by , 13 years ago
I think quoting the URL should be the correct syntax, inline with ordinary links:
comment:4 by , 12 years ago
Replying to François Terrier <fterrier@…>:
What do you think ?
Sounds like the bigger problem here but hopefully this particular bug can be patched in the meantime?
comment:5 by , 12 years ago
|Summary:||wiki [[Image(URL)]], the URL address is truncated to its 74 first characters. → wiki [[Image(URL)]] breaks when the URL contains commas|
So yea, it's not related to 74 chars, it's the parsing of comma's like Francois describes in comment:2. Here's a 94 char url that works:
Renaming the ticket.
comment:6 by , 12 years ago
Alternatively a Quoting could be useful. Something like
This should be easy to implement and also would work for other macros which use same argument parsing.
comment:7 by , 12 years ago
comment:8 by , 12 years ago
I found a solution - URL-encode each comma as %2C, like this:
Took me too long to figure this out, so I hope it helps someone else.
comment:9 by , 12 years ago
comment:10 by , 8 years ago
comment:11 by , 8 years ago
|Milestone:||next-minor-0.12.x → 1.0.2|
|Version:||0.11.2.1 → 1.0.1|
comment:12 by , 8 years ago
|Milestone:||1.0.2 → next-stable-1.0.x|
comment:13 by , 8 years ago
|Milestone:||next-stable-1.0.x → 1.0.5|
|Status:||new → assigned|
As mentioned in comment:10, this will be resolved with #11773.
IMAGE_MACRO_TEST_CASES will be extended to cover the URLs containing commas: tags/trac-1.0.4/trac/wiki/tests/macros.py@:56#L52.
I'm considering a function for
trac.util.text that will split a string at the specified token(s) provided they aren't surrounded in quotes: SO:2787064/121694.
comment:14 by , 8 years ago
|Release Notes:||modified (diff)|
comment:15 by , 8 years ago
|Status:||assigned → closed|
comment:16 by , 8 years ago