mirror of
https://github.com/pldubouilh/gossa.git
synced 2026-08-28 12:56:35 -04:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d8b8d87ee | ||
|
|
355752f9a7 |
@@ -100,9 +100,8 @@ func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path str
|
||||
p.Title = template.HTML(html.EscapeString(title))
|
||||
|
||||
for _, el := range files {
|
||||
info, errInfo := el.Info()
|
||||
el, err := os.Stat(fullPath + "/" + el.Name())
|
||||
if err != nil || errInfo != nil {
|
||||
info, err := el.Info()
|
||||
if err != nil {
|
||||
log.Println("error - cant stat a file", err)
|
||||
continue
|
||||
}
|
||||
@@ -110,7 +109,7 @@ func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path str
|
||||
if *skipHidden && strings.HasPrefix(el.Name(), ".") {
|
||||
continue // dont print hidden files if we're not allowed
|
||||
}
|
||||
if !*symlinks && info.Mode()&os.ModeSymlink != 0 {
|
||||
if *symlinks && info.Mode()&os.ModeSymlink != 0 {
|
||||
continue // dont follow symlinks if we're not allowed
|
||||
}
|
||||
|
||||
@@ -127,7 +126,7 @@ func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path str
|
||||
} else {
|
||||
sl := strings.Split(name, ".")
|
||||
ext := strings.ToLower(sl[len(sl)-1])
|
||||
row := rowTemplate{name, template.URL(href), humanize(el.Size()), ext}
|
||||
row := rowTemplate{name, template.URL(href), humanize(info.Size()), ext}
|
||||
p.RowsFiles = append(p.RowsFiles, row)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,8 +238,6 @@ func doTestRegular(t *testing.T, url string, testExtra bool) {
|
||||
hasListing := strings.Contains(body0, `readme.md`)
|
||||
body1 = get(t, url+"/support/readme.md")
|
||||
hasReadme := strings.Contains(body1, `the master branch is automatically built and pushed`)
|
||||
body2 = get(t, url)
|
||||
hasMainListing := strings.Contains(body2, `href="support">support/</a>`)
|
||||
|
||||
if !testExtra && hasReadme {
|
||||
t.Fatal("error symlink file reached where illegal")
|
||||
@@ -251,11 +249,6 @@ func doTestRegular(t *testing.T, url string, testExtra bool) {
|
||||
} else if testExtra && !hasListing {
|
||||
t.Fatal("error symlink folder unreachable")
|
||||
}
|
||||
if !testExtra && hasMainListing {
|
||||
t.Fatal("error symlink folder where illegal")
|
||||
} else if testExtra && !hasMainListing {
|
||||
t.Fatal("error symlink folder unreachable")
|
||||
}
|
||||
|
||||
if testExtra {
|
||||
fmt.Println("\r\n~~~~~~~~~~ test symlink mkdir & cleanup")
|
||||
|
||||
Reference in New Issue
Block a user