From c20c025c8eb5913f93d28b1dd6594425226bde1b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 17 Jul 2012 18:30:58 -0400 Subject: [PATCH] Bug - Fixed a bug that caused a commond dateformat (YDM-HN) to be misinterpreted as a UUID. Solution is to increase minimum partial UUID length from 9 to 14. --- NEWS | 2 ++ src/Nibbler.cpp | 2 +- test/feature.891.t | 10 +++++----- test/nibbler.t.cpp | 33 ++++++++++++++------------------- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/NEWS b/NEWS index 132749d3e..5079f51e8 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ New Features in taskwarrior 2.1.0 and are deleted. - Improved UTF8 handling for wide characters. - User defined attributes. + - Partial UUIDs must now be at least 14 characters, up from 9. This + disambiguates a commonly date format. Please refer to the ChangeLog file for full details. There are too many to list here. diff --git a/src/Nibbler.cpp b/src/Nibbler.cpp index 3321f566f..41f816b25 100644 --- a/src/Nibbler.cpp +++ b/src/Nibbler.cpp @@ -41,7 +41,7 @@ #include static const char* _uuid_pattern = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; -static const unsigned int _uuid_min_length = 9; +static const unsigned int _uuid_min_length = 14; //////////////////////////////////////////////////////////////////////////////// Nibbler::Nibbler () diff --git a/test/feature.891.t b/test/feature.891.t index bc27c8508..1db785a73 100755 --- a/test/feature.891.t +++ b/test/feature.891.t @@ -137,23 +137,23 @@ like ($output, qr/one/, "Found with $short"); ($short) = $uuid =~ /^(.{13})/; $output = qx{../src/task rc:bug.rc $short list 2>&1}; -like ($output, qr/one/, "Found with $short"); +unlike ($output, qr/one/, "Not found with $short"); ($short) = $uuid =~ /^(.{12})/; $output = qx{../src/task rc:bug.rc $short list 2>&1}; -like ($output, qr/one/, "Found with $short"); +unlike ($output, qr/one/, "Not found with $short"); ($short) = $uuid =~ /^(.{11})/; $output = qx{../src/task rc:bug.rc $short list 2>&1}; -like ($output, qr/one/, "Found with $short"); +unlike ($output, qr/one/, "Not found with $short"); ($short) = $uuid =~ /^(.{10})/; $output = qx{../src/task rc:bug.rc $short list 2>&1}; -like ($output, qr/one/, "Found with $short"); +unlike ($output, qr/one/, "Not found with $short"); ($short) = $uuid =~ /^(.{9})/; $output = qx{../src/task rc:bug.rc $short list 2>&1}; -like ($output, qr/one/, "Found with $short"); +unlike ($output, qr/one/, "Not found with $short"); ($short) = $uuid =~ /^(.{8})/; $output = qx{../src/task rc:bug.rc $short list 2>&1}; diff --git a/test/nibbler.t.cpp b/test/nibbler.t.cpp index 5c582e968..0ff482e6e 100644 --- a/test/nibbler.t.cpp +++ b/test/nibbler.t.cpp @@ -39,15 +39,15 @@ int main (int argc, char** argv) { #ifdef NIBBLER_FEATURE_DATE #ifdef NIBBLER_FEATURE_REGEX - UnitTest t (387); + UnitTest t (382); #else - UnitTest t (363); + UnitTest t (358); #endif #else #ifdef NIBBLER_FEATURE_REGEX - UnitTest t (337); + UnitTest t (332); #else - UnitTest t (313); + UnitTest t (308); #endif #endif @@ -465,29 +465,24 @@ int main (int argc, char** argv) t.ok (n.depleted (), "depleted"); n = Nibbler ("a0b1c2d3-e4f5"); - t.ok (n.getPartialUUID (s), "partial uuid [13] found"); - t.is (s, "a0b1c2d3-e4f5", "partial uuid [13] -> correct"); - t.ok (n.depleted (), "depleted"); + t.notok (n.getPartialUUID (s), "partial uuid [13] not found"); + t.notok (n.depleted (), "depleted"); n = Nibbler ("a0b1c2d3-e4f"); - t.ok (n.getPartialUUID (s), "partial uuid [12] found"); - t.is (s, "a0b1c2d3-e4f", "partial uuid [12] -> correct"); - t.ok (n.depleted (), "depleted"); + t.notok (n.getPartialUUID (s), "partial uuid [12] not found"); + t.notok (n.depleted (), "depleted"); n = Nibbler ("a0b1c2d3-e4"); - t.ok (n.getPartialUUID (s), "partial uuid [11] found"); - t.is (s, "a0b1c2d3-e4", "partial uuid [11] -> correct"); - t.ok (n.depleted (), "depleted"); + t.notok (n.getPartialUUID (s), "partial uuid [11] not found"); + t.notok (n.depleted (), "depleted"); n = Nibbler ("a0b1c2d3-e"); - t.ok (n.getPartialUUID (s), "partial uuid [10] found"); - t.is (s, "a0b1c2d3-e", "partial uuid [10] -> correct"); - t.ok (n.depleted (), "depleted"); + t.notok (n.getPartialUUID (s), "partial uuid [10] not found"); + t.notok (n.depleted (), "depleted"); n = Nibbler ("a0b1c2d3-"); - t.ok (n.getPartialUUID (s), "partial uuid [9] found"); - t.is (s, "a0b1c2d3-", "partial uuid [9] -> correct"); - t.ok (n.depleted (), "depleted"); + t.notok (n.getPartialUUID (s), "partial uuid [9] not found"); + t.notok (n.depleted (), "depleted"); n = Nibbler ("a0b1c2d3"); t.notok (n.getPartialUUID (s), "partial uuid [8] not found");