ColdFusion 9: int and type=“numeric” nasty bug?

前端 未结 2 1136
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-07 11:30

I\'ve just experienced a behaviour that defies any logic and could potentially lead to serious issues and was wondering if it was a bug or if the behaviour was itend

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-07 11:51

    This is a variation on that theme from the other question. See this code (or run it on cflive.net):

    
    s = "1 2";
    i = int(s);
    v = isValid("numeric", s);
    d = createOdbcDate(s);
    writeDump([s,i,v,d]);
    
    

    s converts to 41276 when calling int(), and when using it as an input for createOdbcDate(), we get:

    January, 02 2013 00:00:00 +0000
    

    So "1 2" is being interpreted as "m d", with an implied year of the current year.

    Which is utterly stupid. But there you go.

提交回复
热议问题