diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit
index cfacbb4213491852819274e6eb6bfd662c2ef5e5..3586a79405763a9a241dd0a10e2383a95a618e66 100755
--- a/git-hooks/sanitize-commit
+++ b/git-hooks/sanitize-commit
@@ -572,7 +572,7 @@ while (<DIFF>) {
                     complain("Changing this file is risky. Please add $watch_people{$key} as reviewer(s).", "", -1);
                 }
             }
-            my $foreign = ($file =~ /\/3rdparty\//);
+            my $foreign = ($file =~ /(^|\/)3rdparty\//);
             $new_file = 0;
             $maybe_bin = 0;
             $is_special = 0;