You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement value sanitization for Time type input #19603
@KiChjang There's a dilemma. Currently is_valid_time_string is not suitable to transfer to parse a time string and parse a time component, because it deal with the string by chars. But parsing need to return (HH, MM, SS) = (u32, u32, u32).
I would use split(":") and change string to u32 in parsing functions.
However, Reinventing the wheel seems not a good idea.
I don't see much value in trying to reimplement is_valid_time_string solely in terms of parse_time_component and parse_time_string. That function today is well-optimized for its only use case, which is to validate whether the string itself is a valid time string. In fact, I think this implementation is much more spec-compliant since it iterates over the characters, instead of splitting them on the : codepoint.
Activity
tigercosmos commentedon Dec 19, 2017
@highfive: assign me
highfive commentedon Dec 19, 2017
Hey @tigercosmos! Thanks for your interest in working on this issue. It's now assigned to you!
tigercosmos commentedon Dec 19, 2017
@KiChjang There's a dilemma. Currently
is_valid_time_stringis not suitable to transfer toparse a time stringandparse a time component, because it deal with the string by chars. But parsing need to return(HH, MM, SS) = (u32, u32, u32).I would use
split(":")and change string to u32 in parsing functions.However, Reinventing the wheel seems not a good idea.
The best relationship might be:
parse_time_component->parse_time_string->is_valid_time_stringLogic should be reused.
cc. @SWW13
servo/components/script/dom/bindings/str.rs
Lines 214 to 283 in 54c6028
KiChjang commentedon Dec 19, 2017
I don't see much value in trying to reimplement
is_valid_time_stringsolely in terms ofparse_time_componentandparse_time_string. That function today is well-optimized for its only use case, which is to validate whether the string itself is a valid time string. In fact, I think this implementation is much more spec-compliant since it iterates over the characters, instead of splitting them on the:codepoint.tigercosmos commentedon Dec 19, 2017
@KiChjang I would implement parse function because date time input will use it. I cannot use valid function, because it is bind to Dom.
tigercosmos commentedon Dec 19, 2017
@KiChjang So do you think I just implement parse function aside with valid one is fine?
KiChjang commentedon Dec 19, 2017
Yes.
SWW13 commentedon Dec 19, 2017
@tigercosmos You could possibly reuse parts of the state machine and combine the Low, Middle and High states for parsing.
Auto merge of #19602 - tigercosmos:r1, r=KiChjang
Auto merge of #19602 - tigercosmos:r1, r=KiChjang
[-]implement Time type inputs[/-][+]Implement value sanitization for Time type input[/+]