Convert \n to \r?\n because of windows thank you windows :)

This commit is contained in:
2025-10-26 17:04:34 +01:00
parent 30246fd626
commit b74e4724d4

View File

@@ -53,7 +53,7 @@ func ProcessRegex(content string, command utils.ModifyCommand, filename string)
processRegexLogger.Error("Error compiling pattern %q: %v", pattern, err)
return commands, fmt.Errorf("error compiling pattern: %v", err)
}
processRegexLogger.Debug("Compiled pattern successfully in %v", time.Since(patternCompileStart))
processRegexLogger.Debug("Compiled pattern successfully in %v. Pattern: %s", time.Since(patternCompileStart), pattern)
// Same here, it's just string concatenation, it won't kill us
// More important is that we don't fuck up the command
@@ -335,6 +335,9 @@ func resolveRegexPlaceholders(pattern string) string {
pattern = strings.ReplaceAll(pattern, "!any", `.*?`)
resolveLogger.Debug("Replaced !any with non-greedy wildcard")
pattern = strings.ReplaceAll(pattern, "\n", "\r?\n")
resolveLogger.Debug("Added optional carriage return support for Windows line endings")
repPattern := regexp.MustCompile(`!rep\(([^,]+),\s*(\d+)\)`)
// !rep(pattern, count) repeats the pattern n times
// Inserting !any between each repetition