Improve the UUID validation to prevent false positives (see #7010)