The Daily WTF
Follow
CodeSOD: Sanitary Paths
SanitizePath is a C# method that takes a path as input and validates its characters. It splits the path into filename and directory name, and replaces any invalid characters according to application-specific rules. If the path contains invalid characters, it logs an error and returns the original path. This behavior is problematic because it provides no meaningful information to the caller. Additionally, the method's validation rules may not align with the filesystem's own rules. An analysis revealed that the method had no impact on the application's behavior and was subsequently removed.