Defect #30256

Cannot make cross-project wiki link if the project name includes square brackets

Added by Go MAEDA 6 months ago. Updated 4 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Text formatting
Target version:4.0.3
Resolution:Fixed Affected version:

Description

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.

screenshot@2x.png (11.6 KB) Go MAEDA, 2018-12-20 12:39

30256-make-wiki-link-includes-brackets.patch Magnifier (3.06 KB) Yuichi HARADA, 2019-01-11 06:46


Related issues

Related to Redmine - Defect #20397: project:someproject wiki syntax should link to project wi... New

Associated revisions

Revision 17906
Added by Go MAEDA 4 months ago

Cannot make cross-project wiki link if the project name includes square brackets (#30256).

Patch by Yuichi HARADA.

Revision 17912
Added by Go MAEDA 4 months ago

Merged r17906 from trunk to 4.0-stable (#30256).

History

#1 Updated by Go MAEDA 6 months ago

  • Related to Defect #20397: project:someproject wiki syntax should link to project with identifier "someproject', not name. added

#2 Updated by Yuichi HARADA 6 months ago

I reviewed the regular expression as follows.(Change from "greedy quantifier" to "lazy quantifier")
https://ruby-doc.org/core-2.6/doc/regexp_rdoc.html#label-Repetition
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?

#3 Updated by Go MAEDA 5 months ago

  • Target version set to Candidate for next minor release

#4 Updated by Go MAEDA 4 months ago

  • Target version changed from Candidate for next minor release to 4.0.3

LGTM. Setting the target version to 4.0.3.

#5 Updated by Go MAEDA 4 months 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.

#6 Updated by Go MAEDA 4 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF