Actions
Defect #38464
closedRendering a custom field with a URL pattern set and containing " :" in the value raises Addressable::URI::InvalidURIError
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
Affected version:
Description
An Addressable::URI::InvalidURIError
occurs in Issues#show
for certain values used to format a URL.
Steps to reproduce:
- Create an issue custom field:
- Field format: Text
- Link values to URL: https://example.com/%value%
- Inside an issue:
- Set the custom field value to:
Test :Test
, i.e.Test
, blank, colon,Test
- Save the issue
- Set the custom field value to:
- When the issue is about to be shown, an
Addressable::URI::InvalidURIError
occurs.
The error is caused by the url_from_pattern
method in lib/redmine/field_format.rb
. The issue can be solved by replacing the 5 occurrances of Addressable::URI.encode
with URI.encode_www_form_component
.
>> Addressable::URI.encode "Test :Test" Traceback (most recent call last): Addressable::URI::InvalidURIError (Invalid scheme format: 'Test ') >> URI.encode_www_form_component "Test :Test" => "Test+%3ATest"
Best regards,
Thomas
Files
Related issues
Updated by Go MAEDA 11 months ago
- Related to Defect #32752: Ruby 2.7: Remove deprecated URI.escape/unescape added
Updated by Go MAEDA 11 months ago
Thank you for suggesting the fix but some tests fail if you simply replace Addressable::URI.encode
with URI.encode_www_form_component
because it encodes space characters as "+". My understanding is that space characters have to be encoded as "%20" in the path part.
Maybe we have to find another approach.
Failure: Redmine::FieldFormatTest#test_text_field_with_url_pattern_and_value_containing_a_space_should_format_as_link [/path/to/redmine/test/unit/lib/redmine/field_format/field_format_test.rb:90]: --- expected +++ actual @@ -1 +1 @@ -"<a href=\"http://foo/foo%20bar\" class=\"external\">foo bar</a>" +"<a href=\"http://foo/foo+bar\" class=\"external\">foo bar</a>" rails test test/unit/lib/redmine/field_format/field_format_test.rb:85 .F Failure: Redmine::FieldFormatTest#test_text_field_with_url_pattern_should_encode_values [/path/to/redmine/test/unit/lib/redmine/field_format/field_format_test.rb:106]: --- expected +++ actual @@ -1 +1 @@ -"<a href=\"http://foo/foo%20bar#anchor\" class=\"external\">foo bar</a>" +"<a href=\"http://foo/foo+bar#anchor\" class=\"external\">foo bar</a>" rails test test/unit/lib/redmine/field_format/field_format_test.rb:101
Updated by Go MAEDA 11 months ago
- File 38464.patch 38464.patch added
- Subject changed from Addressable::URI::InvalidURIError in Issues#show to Rendering a custom field with a URL pattern set and containing " :" in the value raises Addressable::URI::InvalidURIError
- Target version set to Candidate for next minor release
Here is a patch to fix the issue.
Updated by Go MAEDA 11 months ago
- Has duplicate Defect #38491: Invalid scheme format: ' VP1' added
Actions