Edgewall Software
Modify

Opened 8 years ago

Last modified 19 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.4.x
Component: ticket system Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos)

Two issues were discussed on the mailing list:

  1. It should be documented that lines 2:end need to be indented with whitespace to have a multi-line ticket description. For example,
    [ticket]
    default_description = line1 
     line2
     line3
     line4
    
    This would be applicable to any textarea. Description is currently the only one in [ticket] section (TracIni#ticket-section), but we may also need to consider the value parameter of textarea custom fields (TracTicketsCustomFields#AvailableFieldTypesandOptions).
  1. Empty lines can't be included in the [ticket] default_description because ConfigParser 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)

20140312T032218.png (5.4 KB ) - added by Jun Omae 8 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by Ryan J Ollos, 8 years ago

Description: modified (diff)

by Jun Omae, 8 years ago

Attachment: 20140312T032218.png added

comment:2 by Jun Omae, 8 years ago

[project] descr option also can be saved multi-lines via admin view.

Another thing is that leading spaces are stripped.

[project]
admin =
admin_trac_url = .
descr = My example project
  2nd line
   3rd line
 
 5th line

comment:3 by Ryan J Ollos, 7 years ago

Milestone: next-stable-1.0.x1.0.3
Owner: set to Ryan J Ollos
Status: newassigned

comment:4 by Ryan J Ollos, 7 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  
    1717from ConfigParser import ConfigParser
    1818from copy import deepcopy
    1919import os.path
     20import re
    2021
    2122from genshi.builder import tag
    2223from trac.admin import AdminCommandError, IAdminCommandProvider
    class Section(object):  
    398399            value = u''
    399400        elif isinstance(value, basestring):
    400401            value = to_unicode(value)
     402            if re.search(r'[\r\n]+', value):
     403                value = re.sub(r'^"|"$', '', value, flags=re.M)
    401404        self._cache[key] = value
    402405        return value
    403406
    class Section(object):  
    507510            value_str = ''
    508511        else:
    509512            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)
    510516        return self.config.parser.set(name_str, key_str, value_str)
    511517
    512518    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 Ryan J Ollos, 7 years ago

Milestone: 1.0.3next-stable-1.0.x
Owner: Ryan J Ollos removed
Status: assignednew

comment:6 by Ryan J Ollos, 5 years ago

Milestone: next-stable-1.0.xnext-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 Ryan J Ollos, 19 months ago

Milestone: next-stable-1.2.xnext-stable-1.4.x

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.