Bug 76893 - Implement value sanitization algorithm for type=datetime
Summary: Implement value sanitization algorithm for type=datetime
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: WebExposed
Depends on:
Blocks: 37024
  Show dependency treegraph
 
Reported: 2012-01-23 20:46 PST by Kent Tamura
Modified: 2024-11-05 01:14 PST (History)
8 users (show)

See Also:


Attachments
Patch (18.28 KB, patch)
2012-10-18 19:31 PDT, Kunihiko Sakamoto
no flags Details | Formatted Diff | Diff
Patch 2 (18.56 KB, patch)
2012-10-18 21:16 PDT, Kunihiko Sakamoto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Tamura 2012-01-23 20:46:02 PST
http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#date-and-time-state-(type=datetime)
> The value sanitization algorithm is as follows: If the value of the element is a valid global date and time string, then adjust the time so that the value represents the same point in time but expressed in the UTC time zone as a valid normalized forced-UTC global date and time string, otherwise, set it to the empty string instead.
Comment 1 Kunihiko Sakamoto 2012-10-18 19:31:53 PDT
Created attachment 169537 [details]
Patch
Comment 2 Kent Tamura 2012-10-18 20:28:48 PDT
Comment on attachment 169537 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=169537&action=review


> LayoutTests/fast/forms/datetime/datetime-value-sanitization-expected.txt:9
> +PASS input.value = "2009-09-07T16:49:00Z"; input.value is "2009-09-07T16:49Z"
> +PASS input.value = "2009-09-07T16:49:00.000Z"; input.value is "2009-09-07T16:49Z"

Can you preserve trailing zeros of the input datetime values?

If we do so, we should do:
 - Add "SecondFormat m_preferredSecondForamt;" and "SecondFormat preferredSecondFormat() const" to DateComponents
 - m_preferredSecondFormat is updated in DateComponents::parseTime
 - DateTimeInputType::sanitizeValue calls date.toString(date.preferredSecondFormat)

> LayoutTests/fast/forms/datetime/datetime-value-sanitization.html:1
> +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<!DOCTYPE html>

is enough.

> LayoutTests/fast/forms/datetime/datetime-value-sanitization.html:8
> +<p id="description"></p>
> +<div id="console"></div>

Please remove them.  They are unnecessary nowadays.

> LayoutTests/fast/forms/datetime/datetime-value-sanitization.html:15
> +// Valid values

Such labels are useful for test results too.
So please print it by debug('Valid values');

> LayoutTests/fast/forms/datetime/datetime-value-sanitization.html:16
> +shouldBe('input.value = "2009-09-07T16:49Z"; input.value', '"2009-09-07T16:49Z"');

should be:
  shouldBeEqualToString('input.value ...', '2009-09-07T16:49Z');
to avoid ugly nested quotes.
Comment 3 Kunihiko Sakamoto 2012-10-18 20:49:53 PDT
Comment on attachment 169537 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=169537&action=review

>> LayoutTests/fast/forms/datetime/datetime-value-sanitization-expected.txt:9
>> +PASS input.value = "2009-09-07T16:49:00.000Z"; input.value is "2009-09-07T16:49Z"
> 
> Can you preserve trailing zeros of the input datetime values?
> 
> If we do so, we should do:
>  - Add "SecondFormat m_preferredSecondForamt;" and "SecondFormat preferredSecondFormat() const" to DateComponents
>  - m_preferredSecondFormat is updated in DateComponents::parseTime
>  - DateTimeInputType::sanitizeValue calls date.toString(date.preferredSecondFormat)

The spec says that normalized value is the shortest possible representation of the given time.
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#valid-normalized-forced-utc-global-date-and-time-string
Is there a good reason for keeping the second format of the input?
Comment 4 Kent Tamura 2012-10-18 20:56:18 PDT
Comment on attachment 169537 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=169537&action=review

>>> LayoutTests/fast/forms/datetime/datetime-value-sanitization-expected.txt:9
>>> +PASS input.value = "2009-09-07T16:49:00.000Z"; input.value is "2009-09-07T16:49Z"
>> 
>> Can you preserve trailing zeros of the input datetime values?
>> 
>> If we do so, we should do:
>>  - Add "SecondFormat m_preferredSecondForamt;" and "SecondFormat preferredSecondFormat() const" to DateComponents
>>  - m_preferredSecondFormat is updated in DateComponents::parseTime
>>  - DateTimeInputType::sanitizeValue calls date.toString(date.preferredSecondFormat)
> 
> The spec says that normalized value is the shortest possible representation of the given time.
> http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#valid-normalized-forced-utc-global-date-and-time-string
> Is there a good reason for keeping the second format of the input?

Oh, I see.  It is a standard behavior.
So, the C++ part of your patch is ok.
Comment 5 Kunihiko Sakamoto 2012-10-18 21:16:23 PDT
Created attachment 169541 [details]
Patch 2
Comment 6 Kunihiko Sakamoto 2012-10-18 21:17:14 PDT
Updated the test. Please take another look.
Comment 7 Kent Tamura 2012-10-18 21:40:36 PDT
Comment on attachment 169541 [details]
Patch 2

ok
Comment 8 WebKit Review Bot 2012-10-18 21:45:53 PDT
Comment on attachment 169541 [details]
Patch 2

Clearing flags on attachment: 169541

Committed r131853: <http://trac.webkit.org/changeset/131853>
Comment 9 WebKit Review Bot 2012-10-18 21:45:57 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 MarleneCraig 2024-09-13 03:27:07 PDT
RocketPlay Casino is known for its generous bonuses and promotions catering to new and existing players. New players can take advantage of a lucrative welcome bonus, often including a match deposit bonus and free spins. This gives newcomers a great start and allows them to explore the games without risking too much of their money https://rocketplay.com.de/. Existing players are not left out, as RocketPlay offers regular promotions such as reload bonuses, cashback offers, and free spins on popular slots. The casino also has a loyalty program where players earn points for every wager. These points can be exchanged for rewards, adding extra value to your gameplay.
Comment 11 Sophia Carpenter 2024-09-27 00:32:54 PDT
Implementing a value sanitization algorithm for type=datetime is crucial for ensuring that data is properly validated and formatted, particularly when dealing with sensitive time-related inputs in web applications. This practice mitigates risks such as incorrect formatting and potential security vulnerabilities, enhancing the reliability of the system. Proper sanitization aligns with legal compliance efforts, much like the regulations discussed in the article https://northiowatoday.com/2024/08/27/understanding-the-legal-side-of-online-slots-in-australia/, where adherence to strict standards ensures a secure and fair online gaming environment.
Comment 12 Snowmanta 2024-09-30 01:15:26 PDT
RocketPlay provides frequent promotions, including reload bonuses, cashback incentives, and complimentary spins on popular slot games. The casino has a loyalty program that allows players to accumulate points for each bet placed. These points may be redeemed for gifts, enhancing the value of your gameplay. https://drifthunters2.io
Comment 13 JustinPlaying 2024-11-05 01:14:21 PST
RocketPlay Casino is known for its generous bonuses and promotions catering to new and existing players.as well as https://www.funnyshooter2.xyz. New players can take advantage of a lucrative welcome bonus, often including a match deposit bonus and free spins.