Defect #27881

No validation errors when entering an invalid "Estimate hours" value

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

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Issues
Target version:3.3.6
Resolution:Fixed Affected version:

Description

This problem was reported as a part of #12955 by Daniel Felix five years ago. I confirmed that the latest versions of Redmine (3.4 and trunk) are still affected.

The helper for the estimated time doesn't check the correctness of the string. For example, you can define hours by 2h30m to get 2.5 or 3h5m to get 3.08 as timevalue. But if you enter abc or 3j (misstyped) the string isn't checked. The issue just returns "update successfully" and sets the estimated time to nil. The string should be checked and should raise some error, if the input isn't correct.

fix-27881.diff Magnifier (947 Bytes) Go MAEDA, 2018-01-03 09:25


Related issues

Related to Redmine - Defect #12955: Misbehaviour in estimated time validation Closed
Related to Redmine - Defect #2465: Spent time error Closed 2009-01-08

Associated revisions

Revision 17144
Added by Jean-Philippe Lang 6 months ago

No validation errors when entering an invalid "Estimate hours" value (#27881).

Patch by Go MAEDA.

Revision 17145
Added by Jean-Philippe Lang 6 months ago

Merged r17144 to 3.4-stable (#27881).

Revision 17146
Added by Jean-Philippe Lang 6 months ago

Merged r17144 to 3.3-stable (#27881).

History

#1 Updated by Go MAEDA 7 months ago

  • Related to Defect #12955: Misbehaviour in estimated time validation added

#2 Updated by Go MAEDA 7 months ago

I found a very similar fix r2251 (#2465). The following workaround should work.

Index: app/models/issue.rb
===================================================================
--- app/models/issue.rb    (revision 17140)
+++ app/models/issue.rb    (working copy)
@@ -440,7 +440,7 @@
   end

   def estimated_hours=(h)
-    write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
+    write_attribute :estimated_hours, (h.is_a?(String) ? (h.to_hours || h) : h)
   end

   safe_attributes 'project_id',

#3 Updated by Go MAEDA 7 months ago

#4 Updated by Go MAEDA 7 months ago

Attaching a patch file. Setting target version to 3.3.6.

#5 Updated by Jean-Philippe Lang 6 months ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Committed, thanks.

Also available in: Atom PDF