Cannot make cross-project wiki link if the project name includes square brackets
|Assignee:||Go MAEDA||% Done:|
According to the Wiki formatting help, You can link to wiki pages of another project using the following syntax.
[[sandbox:some page]] [[sandbox:]]
However, it does not work if the name of the destination project includes "[" or "]" character.
For example, suppose that there is a project named "[Foo]Bar". If you want to link to wiki pages in the project, the syntax is "[[[Foo]Bar:PageName]]". However, it does not generate any link.
Cannot make cross-project wiki link if the project name includes square brackets (#30256).
Patch by Yuichi HARADA.
#2 Updated by Yuichi HARADA over 2 years ago
- File 30256-make-wiki-link-includes-brackets.patch added
I reviewed the regular expression as follows.(Change from "greedy quantifier" to "lazy quantifier")
I attached a patch.
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e250c20ee..8fa56ac55 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -787,7 +787,7 @@ module ApplicationHelper # [[project:mypage]] # [[project:mypage|mytext]] def parse_wiki_links(text, project, obj, attr, only_path, options) - text.gsub!(/(!)?(\[\[([^\]\n\|]+)(\|([^\]\n\|]+))?\]\])/) do |m| + text.gsub!(/(!)?(\[\[([^\n\|]+?)(\|([^\n\|]+?))?\]\])/) do |m| link_project = project esc, all, page, title = $1, $2, $3, $5 if esc.nil?
#5 Updated by Go MAEDA about 2 years ago
- Subject changed from Cannot make cross-project wiki link if the project name includes "[" or "]" to Cannot make cross-project wiki link if the project name includes square brackets
- Status changed from New to Resolved
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the patch. Thank you for your contribution.