Invalid characters check
This commit is contained in:
parent
1d081ba572
commit
916b170e41
@ -116,15 +116,18 @@ module RedmineDmsf
|
||||
self.project.id if self.project
|
||||
end
|
||||
|
||||
# Characters that MATCH this regex will be replaced with dots, no more than one dot in a row.
|
||||
INVALID_CHARACTERS = /[\/\\\?":<>#%\*\[\]]/.freeze # = / \ ? " : < > # % * [ ]
|
||||
|
||||
def self.create_project_name(p)
|
||||
use_project_names = Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names']
|
||||
if use_project_names
|
||||
# 1. Invalid characters are replaced with a dot.
|
||||
# 2. Two or more dots in a row are replaced with a single dot.
|
||||
# (3. Windows WebClient does not like a dot at the end, but since the project id tag is appended this is not a problem.)
|
||||
"#{p.name.gsub(DmsfFolder::INVALID_CHARACTERS, ".").gsub(/\.{2,}/, '.')} #{p.id}" unless p.nil?
|
||||
"#{p.name.gsub(INVALID_CHARACTERS, '.').gsub(/\.{2,}/, '.')} #{p.id}" if p
|
||||
else
|
||||
p.identifier unless p.nil?
|
||||
p.identifier if p
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user