From 0e86609f764bb8aa231be43a4924fa486b553419 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Tue, 27 Apr 2021 08:54:46 +0300 Subject: [PATCH] Trim the newline at the end of raw request file --- CHANGELOG.md | 1 + pkg/ffuf/optionsparser.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32c39af6..60e70297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - New - Added a CLI flag to disable the interactive mode - Changed + - Do not read the last newline in the end of the raw request file when using -request - Fixed an issue with storing the matches for recursion jobs - Fixed the way the "size" is calculated, it should match content-length now - Fixed an issue with header canonicalization when a keyword was just a part of the header name diff --git a/pkg/ffuf/optionsparser.go b/pkg/ffuf/optionsparser.go index c6034130..e04aa485 100644 --- a/pkg/ffuf/optionsparser.go +++ b/pkg/ffuf/optionsparser.go @@ -489,6 +489,12 @@ func parseRawRequest(parseOpts *ConfigOptions, conf *Config) error { } conf.Data = string(b) + // Remove newline (typically added by the editor) at the end of the file + if strings.HasSuffix(conf.Data, "\r\n") { + conf.Data = conf.Data[:len(conf.Data)-2] + } else if strings.HasSuffix(conf.Data, "\n") { + conf.Data = conf.Data[:len(conf.Data)-1] + } return nil }