From 02173be81a87bbad4a025386a9e45e80d8d63144 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 9 Aug 2015 11:45:09 -0400 Subject: [PATCH] Duration: Addressed problem of UUID/Duration overlap - The "d" unit is a special case, because it is the only one that can legitimately occur at the beginning of a UUID, and be followed by an operator: 1111111d-0000-0000-0000-000000000000 Because Lexer::isDuration is higher precedence than Lexer::isUUID, the above UUID looks like: <1111111d> <-> ... duration op ... So as a special case, durations, with units of "d" are rejected if the quantity exceeds 10000. --- src/Duration.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Duration.cpp b/src/Duration.cpp index 05378e702..a90506a12 100644 --- a/src/Duration.cpp +++ b/src/Duration.cpp @@ -341,6 +341,25 @@ bool Duration::parse (const std::string& input, std::string::size_type& start) n.skipWS (); if (n.getOneOf (units, unit)) { + // The "d" unit is a special case, because it is the only one that can + // legitimately occur at the beginning of a UUID, and be followed by an + // operator: + // + // 1111111d-0000-0000-0000-000000000000 + // + // Because Lexer::isDuration is higher precedence than Lexer::isUUID, + // the above UUID looks like: + // + // <1111111d> <-> ... + // duration op ... + // + // So as a special case, durations, with units of "d" are rejected if the + // quantity exceeds 10000. + // + if (unit == "d" && + strtol (number.c_str (), NULL, 10) > 10000) + return false; + if (n.depleted () || Lexer::isWhitespace (n.next ()) || Lexer::isSingleCharOperator (n.next ()))