Opened 11 years ago
Last modified 14 months ago
#11530 new enhancement
Ticket default_description cannot include new lines
Reported by: | Ryan J Ollos | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | next-stable-1.6.x |
Component: | ticket system | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
Two issues were discussed on the mailing list:
- It should be documented that lines 2:end need to be indented with whitespace to have a multi-line ticket description. For example,
This would be applicable to any
[ticket] default_description = line1 line2 line3 line4
textarea
. Description is currently the only one in[ticket]
section (TracIni#ticket-section), but we may also need to consider thevalue
parameter oftextarea
custom fields (TracTicketsCustomFields#AvailableFieldTypesandOptions).
- Empty lines can't be included in the
[ticket] default_description
becauseConfigParser
in Python 2.x does not appear to support empty lines. The empty lines are stripped out. We'll need a workaround such as specifying empty lines with a single\
character, and then stripping out the character before rendering an empty line in the ticket description.
Attachments (1)
Change History (9)
comment:1 by , 11 years ago
Description: | modified (diff) |
---|
by , 11 years ago
Attachment: | 20140312T032218.png added |
---|
comment:2 by , 11 years ago
comment:3 by , 10 years ago
Milestone: | next-stable-1.0.x → 1.0.3 |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:4 by , 10 years ago
The quality of the regexes could probably be improved, but here is what I came up with:
- Test for multi-line strings
- Wrap multi-line strings in double quotes.
There are probably corner cases that need to be dealt with (escape inline double-quotes?). I'm just posting this now in case someone has a better idea for approaching the problem.
-
trac/config.py
diff --git a/trac/config.py b/trac/config.py index 7b233d5..1bb1b96 100644
a b from __future__ import with_statement 17 17 from ConfigParser import ConfigParser 18 18 from copy import deepcopy 19 19 import os.path 20 import re 20 21 21 22 from genshi.builder import tag 22 23 from trac.admin import AdminCommandError, IAdminCommandProvider … … class Section(object): 398 399 value = u'' 399 400 elif isinstance(value, basestring): 400 401 value = to_unicode(value) 402 if re.search(r'[\r\n]+', value): 403 value = re.sub(r'^"|"$', '', value, flags=re.M) 401 404 self._cache[key] = value 402 405 return value 403 406 … … class Section(object): 507 510 value_str = '' 508 511 else: 509 512 value_str = _to_utf8(value) 513 # Escape whitespace on multi-line strings 514 if re.search(r'[\r\n]+', value_str): 515 value_str = re.sub(r'^([^\r\n]*)', r'"\1"', value_str, flags=re.M) 510 516 return self.config.parser.set(name_str, key_str, value_str) 511 517 512 518 def remove(self, key):
ConfigParser in Python 3.3 allows empty lines through the empty_lines_in_values
option, but there's no support for leading or trailing whitespace on the lines.
comment:5 by , 10 years ago
Milestone: | 1.0.3 → next-stable-1.0.x |
---|---|
Owner: | removed |
Status: | assigned → new |
comment:6 by , 8 years ago
Milestone: | next-stable-1.0.x → next-stable-1.2.x |
---|
Moved ticket assigned to next-stable-1.0.x since maintenance of 1.0.x is coming to a close. Please move the ticket back if it's critical to fix on 1.0.x.
comment:7 by , 4 years ago
Milestone: | next-stable-1.2.x → next-stable-1.4.x |
---|
[project] descr
option also can be saved multi-lines via admin view.Another thing is that leading spaces are stripped.