Skip to content

Commit d556483

Browse files
authored
Merge pull request #115 from lc/lc/fix-panic
fix(panic): fix gau panic when output flag is provided
2 parents abf8b12 + 4fa052d commit d556483

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

cmd/gau/main.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,26 @@ func main() {
3131

3232
results := make(chan string)
3333

34-
var out io.Writer
34+
var out = os.Stdout
3535
// Handle results in background
3636
if config.Output != "" {
37-
out, err := os.OpenFile(config.Output, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
37+
out, err = os.OpenFile(config.Output, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
3838
if err != nil {
3939
log.Fatalf("Could not open output file: %v\n", err)
4040
}
4141
defer out.Close()
42-
} else {
43-
out = os.Stdout
4442
}
4543

46-
writeWg := new(sync.WaitGroup)
44+
var writeWg sync.WaitGroup
4745
writeWg.Add(1)
48-
go func(JSON bool) {
46+
go func(out io.Writer, JSON bool) {
4947
defer writeWg.Done()
5048
if JSON {
5149
output.WriteURLsJSON(out, results, config.Blacklist, config.RemoveParameters)
5250
} else if err = output.WriteURLs(out, results, config.Blacklist, config.RemoveParameters); err != nil {
5351
log.Fatalf("error writing results: %v\n", err)
5452
}
55-
}(config.JSON)
53+
}(out, config.JSON)
5654

5755
workChan := make(chan runner.Work)
5856
gau.Start(workChan, results)

pkg/output/output.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ func WriteURLs(writer io.Writer, results <-chan string, blacklistMap mapset.Set[
2222
if err != nil {
2323
continue
2424
}
25-
if blacklistMap.Contains(strings.ToLower(path.Ext(u.Path))) {
25+
if path.Ext(u.Path) != "" && blacklistMap.Contains(strings.ToLower(path.Ext(u.Path))) {
2626
continue
2727
}
28-
if RemoveParameters && !lastURL.Add(u.Host+u.Path) {
28+
29+
if RemoveParameters && !lastURL.Contains(u.Host+u.Path) {
2930
continue
3031
}
32+
lastURL.Add(u.Host + u.Path)
3133

3234
buf.B = append(buf.B, []byte(result)...)
3335
buf.B = append(buf.B, "\n"...)

pkg/providers/providers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/valyala/fasthttp"
77
)
88

9-
const Version = `2.2.0`
9+
const Version = `2.2.1`
1010

1111
// Provider is a generic interface for all archive fetchers
1212
type Provider interface {

0 commit comments

Comments
 (0)