Co-authored-by: Mathias <mthbqv@gmail.com>
This commit was merged in pull request #152.
This commit is contained in:
@@ -447,6 +447,12 @@ func (h *Handler) IngestPath(w http.ResponseWriter, r *http.Request) {
|
||||
writeError(w, http.StatusBadRequest, "path is required")
|
||||
return
|
||||
}
|
||||
resolved, err := ResolveIngestPath(h.brainDir, req.Path)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
req.Path = resolved
|
||||
|
||||
info, err := os.Stat(req.Path)
|
||||
if err != nil {
|
||||
@@ -469,6 +475,12 @@ func (h *Handler) IngestPath(w http.ResponseWriter, r *http.Request) {
|
||||
if !isSupportedExtension(ext) {
|
||||
return nil
|
||||
}
|
||||
// Each walked file is re-resolved: a symlinked file inside raw/
|
||||
// would otherwise lead extract.Text out of the inbox (#149).
|
||||
if _, rerr := ResolveIngestPath(h.brainDir, path); rerr != nil {
|
||||
allWarnings = append(allWarnings, fmt.Sprintf("skipped %s: %v", path, rerr))
|
||||
return nil
|
||||
}
|
||||
content, readErr := extract.Text(path)
|
||||
if readErr != nil {
|
||||
allWarnings = append(allWarnings, fmt.Sprintf("extract %s: %v", path, readErr))
|
||||
|
||||
Reference in New Issue
Block a user