Closed
Bug 371611
Opened 19 years ago
Closed 19 years ago
crash nsIScriptableDateFormat::FormatDate for undefined year, month, day
Categories
(Core :: Internationalization, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: surkov, Assigned: sciguyryan)
References
Details
Attachments
(2 files, 9 obsolete files)
|
679 bytes,
application/vnd.mozilla.xul+xml
|
Details | |
|
4.29 KB,
patch
|
Biesinger
:
superreview+
|
Details | Diff | Splinter Review |
crash nsIScriptableDateFormat::FormatDate for undefined year, month, day.
Example:
const nsIScriptableDateFormat =
Components.interfaces.nsIScriptableDateFormat
var dateConv = Components.classes["@mozilla.org/intl/scriptabledateformat;1"].
getService(nsIScriptableDateFormat);
dateConv.FormatDate("", nsIScriptableDateFormat.dateFormatLong,
undefined, undefined, undefined);
| Assignee | ||
Comment 1•19 years ago
|
||
Patch v1
Am I right in assuming the problem here is we're passing a 0 (undefined becomes 0 after conversion) for the year, month and day which is invalid. Wouldn't the fix therefore be something like this? In the case where either the year, month or day is 0 should we return |NS_ERROR_ILLEGAL_VALUE|?
Assignee: smontagu → sciguyryan
Status: NEW → ASSIGNED
Attachment #256365 -
Flags: superreview?(smontagu)
Attachment #256365 -
Flags: review?(smontagu)
Comment 2•19 years ago
|
||
+ return NS_ERROR_ILLEGAL_VALUE; // invalid arg value
fwiw we have NS_ERROR_INVALID_ARG which'd the comment redundant :) (and a unit test would be nice)
| Assignee | ||
Comment 3•19 years ago
|
||
(In reply to comment #2)
> + return NS_ERROR_ILLEGAL_VALUE; // invalid arg value
>
> fwiw we have NS_ERROR_INVALID_ARG which'd the comment redundant :) (and a unit
> test would be nice)
>
Fair enough - I was following the standard per line 148 so should that be changed also?
| Assignee | ||
Updated•19 years ago
|
OS: Windows XP → All
| Assignee | ||
Comment 4•19 years ago
|
||
Patch v1.1
* As suggested by Christian - use |NS_ERROR_INVALID_ARG| over |NS_ERROR_ILLEGAL_VALUE| as its self-explanatory (also changed the second instance of this to maintain a standard).
Attachment #256365 -
Attachment is obsolete: true
Attachment #256387 -
Flags: superreview?(smontagu)
Attachment #256387 -
Flags: review?(smontagu)
Attachment #256365 -
Flags: superreview?(smontagu)
Attachment #256365 -
Flags: review?(smontagu)
| Assignee | ||
Comment 6•19 years ago
|
||
(In reply to comment #5)
> add an xpcshell test for this, please.
>
Could we possibly add the xpcshell test to the pre-existing LocaleSelfTest.cpp file?
Comment 7•19 years ago
|
||
(In reply to comment #6)
> (In reply to comment #5)
> > add an xpcshell test for this, please.
> >
>
> Could we possibly add the xpcshell test to the pre-existing LocaleSelfTest.cpp
> file?
>
if you really wanted to. however, getting JS coverage would be better. you know where to find me on IRC if you need help
| Assignee | ||
Comment 8•19 years ago
|
||
(In reply to comment #7)
> if you really wanted to. however, getting JS coverage would be better. you know
> where to find me on IRC if you need help
>
Will do. I'll take a look at writing a test for this tomorrow when I get home from school in that case. Thanks!
Comment 10•19 years ago
|
||
Comment on attachment 256479 [details] [diff] [review]
Test v1
looks good to me. but have the module owners review your tests. Ideally, they should be in the patch with the code.
Attachment #256479 -
Flags: review?(smontagu)
Attachment #256479 -
Flags: review?(sayrer)
Attachment #256479 -
Flags: review+
| Assignee | ||
Comment 11•19 years ago
|
||
(In reply to comment #10)
> (From update of attachment 256479 [details] [diff] [review])
> looks good to me. but have the module owners review your tests. Ideally, they
> should be in the patch with the code.
>
Thanks for the comment. I'll remember to add them with the main patch from now on.
Comment 12•19 years ago
|
||
Comment on attachment 256387 [details] [diff] [review]
Patch v1.1
r=me, but I'm not a superreviewer
Attachment #256387 -
Flags: superreview?(smontagu)
Attachment #256387 -
Flags: superreview?(cbiesinger)
Attachment #256387 -
Flags: review?(smontagu)
Attachment #256387 -
Flags: review+
Comment 13•19 years ago
|
||
Comment on attachment 256479 [details] [diff] [review]
Test v1
While you're here, why not add tests for too-large values of month and day? r=me either way.
Attachment #256479 -
Flags: review?(smontagu) → review+
| Assignee | ||
Comment 14•19 years ago
|
||
Test v2
Attachment #256479 -
Attachment is obsolete: true
Attachment #256595 -
Flags: review?(smontagu)
Updated•19 years ago
|
Attachment #256595 -
Flags: review?(smontagu) → review+
Updated•19 years ago
|
Attachment #256387 -
Flags: superreview?(cbiesinger) → superreview+
Comment 15•19 years ago
|
||
Comment on attachment 256595 [details] [diff] [review]
Test v2
+ /* Testing if we throw instead of crashing when we are passed 0s. */
either change the comment to say "undefined" or the code to pass zero. I'd prefer the latter.
+ catch (ex if (ex.result == NS_ERROR_INVALID_ARG)) {
where is that constant defined?
Attachment #256595 -
Flags: superreview-
Comment 16•19 years ago
|
||
and you need to change the makefile too so that this unit test runs, don't you?
| Assignee | ||
Comment 17•19 years ago
|
||
Simon, do you have any idea why |make check| doesn't work in the mozilla/intl/tests/ folder?
I've got an updated patch and am unable to test it because I can't seem to get make check to run without error.
Comment 18•19 years ago
|
||
(In reply to comment #17)
> Simon, do you have any idea why |make check| doesn't work in the
> mozilla/intl/tests/ folder?
also, |make| doesn't work in there either
Comment 19•19 years ago
|
||
Grrr. It used to work, please file a bug against me. (You mean mozilla/intl/locale/tests, right?)
| Assignee | ||
Comment 20•19 years ago
|
||
(In reply to comment #19)
> Grrr. It used to work, please file a bug against me. (You mean
> mozilla/intl/locale/tests, right?)
>
Yes, that's it.
| Assignee | ||
Comment 21•19 years ago
|
||
Complete patch (v1)
* Includes the changes too the makefile, the test and the patch (as well as the makefile changes specified in bug 371990).
Attachment #256387 -
Attachment is obsolete: true
Attachment #256595 -
Attachment is obsolete: true
Comment 22•19 years ago
|
||
with this patch, the test runs as expected in |make check|.
However, the test fails:
*** CHECK FAILED: FormatDate didn't reject invalid month value.
Attachment #256727 -
Attachment is obsolete: true
Comment 23•19 years ago
|
||
Comment on attachment 256728 [details] [diff] [review]
Makefile tweaked
er, that patch skips the new unit/ directory in Ryan's patch but it's otherwise right.
| Assignee | ||
Comment 24•19 years ago
|
||
Complete patch (v2)
* With Robert's changes (thanks for all your help).
Attachment #256728 -
Attachment is obsolete: true
Attachment #256731 -
Flags: superreview?(cbiesinger)
Attachment #256731 -
Flags: review?(smontagu)
Comment 25•19 years ago
|
||
Comment on attachment 256731 [details] [diff] [review]
Complete patch (v2)
did you actually test this? the makefile still needs the includes.
Attachment #256731 -
Flags: superreview?(cbiesinger) → superreview-
Comment 26•19 years ago
|
||
Comment on attachment 256731 [details] [diff] [review]
Complete patch (v2)
My fault for ambiguous phrasing in bug 371990 comment 5: when I said "I think the lines between foo and bar can be removed" I should have added "not including the lines quoted"
| Assignee | ||
Comment 27•19 years ago
|
||
Complete patch (v2.2)
* Fixed the makefile error but the test still fails with |*** CHECK FAILED: FormatDate didn't reject invalid month value.|
I don't know why this occurs, Simon - any ideas and is it still OK to request review on this patch?
Attachment #256731 -
Attachment is obsolete: true
Attachment #256731 -
Flags: review?(smontagu)
Comment 28•19 years ago
|
||
(In reply to comment #27)
> * Fixed the makefile error but the test still fails with |*** CHECK FAILED:
> FormatDate didn't reject invalid month value.|
>
> I don't know why this occurs, Simon - any ideas
This turns out to be a feature of mktime:
"In addition to computing the calendar time, mktime normalizes the supplied tm structure. The original values of the tm_wday and tm_yday components of the structure are ignored, and the original values of the other components are not restricted to the ranges indicated in the definition of the structure."
So too-large values of month and day are not expected to fail and there's no point in testing for them. Sorry for the bad suggestion.
| Assignee | ||
Comment 29•19 years ago
|
||
(In reply to comment #28)
> So too-large values of month and day are not expected to fail and there's no
> point in testing for them. Sorry for the bad suggestion.
>
Ah OK, in that case I've removed the unneeded code from the test.
Attachment #256798 -
Attachment is obsolete: true
Attachment #256807 -
Flags: superreview?(cbiesinger)
Attachment #256807 -
Flags: review?(smontagu)
Updated•19 years ago
|
Attachment #256807 -
Flags: review?(smontagu) → review+
Comment 30•19 years ago
|
||
Comment on attachment 256807 [details] [diff] [review]
Complete patch (v2.3)
+ const nsIScriptableDateFormat = Ci.nsIScriptableDateFormat;
well ok, I wouldn't bother with this, it's not much shorter than Ci.nsIScriptableDateFormat
Attachment #256807 -
Flags: superreview?(cbiesinger) → superreview+
| Assignee | ||
Comment 31•19 years ago
|
||
patch v2.4
* Fixed the nits and hopefully ready for checkin.
Attachment #256807 -
Attachment is obsolete: true
Attachment #257052 -
Flags: superreview?(cbiesinger)
Updated•19 years ago
|
Attachment #257052 -
Flags: superreview?(cbiesinger) → superreview+
| Assignee | ||
Updated•19 years ago
|
Whiteboard: [checkin needed]
| Assignee | ||
Comment 32•19 years ago
|
||
This was checked in by Sayre so thanks!
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Flags: in-testsuite? → in-testsuite+
Resolution: --- → FIXED
Whiteboard: [checkin needed]
You need to log in
before you can comment on or make changes to this bug.
Description
•