Defect #12744
closedUnable to call a macro with a name that contains uppercase letters
Added by Ling Li almost 14 years ago. Updated almost 14 years ago.
Description
I recently upgraded from 2.0 to 2.2 and found that some macros stopped working. Those macros have upper-case letters in their name (e.g., EnableLaTeXMath), and it seems to me that Redmine 2.2 only triggers macro names in lower cases.
hypothesis: when looking up macros, Redmine 2.2 converts the macro name to lower case; but when registering the macro, Redmine 2.2 forgets to lower-case the names. So if a macro has upper case letters in the name during registration, it will never be found when it is called...
Files
| 0001-Preserve-case-of-macro-names-shown-by-macro_list.patch (2.34 KB) 0001-Preserve-case-of-macro-names-shown-by-macro_list.patch | Takeshi Yaegashi, 2013-01-06 19:22 |
Updated by Daniel Felix almost 14 years ago
Actions
#1
Hi there,
well on the first sight, this seems to be ok.
Save a new macro:
source:trunk/lib/redmine/wiki_formatting/macros.rb#L153
There is a downcase in line 153
Find the macro:
source:trunk/app/helpers/application_helper.rb#L864
There is a $4.downcase in line 864
Updated by Ling Li almost 14 years ago
Actions
#2
I don't know Ruby but this line seems suspicious where name is added to available_macros before downcase: source:trunk/lib/redmine/wiki_formatting/macros.rb#L151
(well, it's possible that available_macros is not used during macro look-up. I'll try to figure out why my plugin works only after I rename it to lower-case.)
Updated by Ling Li almost 14 years ago
Actions
#3
I think that was the culprit. An ugly line (before that L151) fixes the problem, and confirms that the problem was due to not lower-casing the names during macro registration:
Updated by Jean-Philippe Lang almost 14 years ago
Actions
#4
- Subject changed from Macro name has to be lower-cased? to Unable to call a macro with a name that contains uppercase letters
- Status changed from New to Closed
- Assignee set to Jean-Philippe Lang
- Target version set to 2.2.1
- Resolution set to Fixed
Fix committed with test in r11126, thanks for pointing this out.
Maybe we should even make macro name case-sensitive?
Updated by Jean-Philippe Lang almost 14 years ago
Actions
#5
- Status changed from Closed to Resolved
Updated by Ling Li almost 14 years ago
Actions
#6
I can confirm that r11126 fixes the problem. Thanks.
Updated by Takeshi Yaegashi almost 14 years ago
Actions
#7
- File 0001-Preserve-case-of-macro-names-shown-by-macro_list.patch 0001-Preserve-case-of-macro-names-shown-by-macro_list.patch added
Jean-Philippe Lang wrote:
Fix committed with test in r11126, thanks for pointing this out.
Maybe we should even make macro name case-sensitive?
I've just been stuck by this bug with my own macros too. There have already been many macro uses with case-confused names, so I hope they would remain case-insensitive.
Btw, I like {{macro_list}} to show macro names with case preserved. Please consider a fix like an attached patch.
Updated by Jean-Philippe Lang almost 14 years ago
Actions
#8
- Status changed from Resolved to Closed
Merged.
Btw, I like
to show macro names with case preserved. Please consider a fix like an attached patch.
hello_world Sample macro.macro_list Displays a list of all available macros, including description if available.child_pagesDisplays a list of child pages. With no argument, it displays the child pages of the current wiki page. Examples: {{child_pages}} -- can be used from a wiki page only {{child_pages(depth=2)}} -- display 2 levels nesting only {{child_pages(Foo)}} -- lists all children of page Foo {{child_pages(Foo, parent=1)}} -- same as above with a link to page Foorecent_pagesDisplays a list of recently updated wiki pages. With no argument, it displays pages that have been updated within the last 7 days. Examples: {{recent_pages}} -- displays pages updated within the last 7 days {{recent_pages(days=3)}} -- displays pages updated within the last 3 days {{recent_pages(limit=5)}} -- limits the maximum number of pages to display to 5 {{recent_pages(time=true)}} -- displays pages updated within the last 7 days with updated time {{recent_pages(project=identifier)}} -- displays pages updated within the last 7 days from a specific project {{recent_pages(include_subprojects=true)}} -- includes pages from subprojectsincludeIncludes a wiki page. Examples: {{include(Foo)}} {{include(projectname:Foo)}} -- to include a page of a specific project wikicollapseInserts of collapsed block of text. Examples: {{collapse This is a block of text that is collapsed by default. It can be expanded by clicking a link. }} {{collapse(View details...) With custom link text. }}thumbnailDisplays a clickable thumbnail of an attached image. Default size is 200 pixels. Examples: {{thumbnail(image.png)}} {{thumbnail(image.png, size=300, title=Thumbnail)}} -- with custom title and sizeissueDisplays an issue link including additional information. Examples: {{issue(123)}} -- Issue #123: Enhance macro capabilities {{issue(123, project=true)}} -- Andromeda - Issue #123: Enhance macro capabilities {{issue(123, tracker=false)}} -- #123: Enhance macro capabilities {{issue(123, subject=false, project=true)}} -- Andromeda - Issue #123sample_macro Sample macro
Will be fixed as a separate issue.