revel/revel#1014 added check for path like ../dir & ./dir for new command

This commit is contained in:
Jeevanandam M
2016-05-25 22:49:11 -07:00
parent 4c628ef3db
commit 5282ce262b

View File

@@ -8,6 +8,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings"
"github.com/revel/revel" "github.com/revel/revel"
) )
@@ -111,7 +112,11 @@ func initGoPaths() {
func setApplicationPath(args []string) { func setApplicationPath(args []string) {
var err error var err error
importPath = args[0] importPath = args[0]
if filepath.IsAbs(importPath) {
// revel/revel#1014 validate relative path, we cannot use built-in functions
// since Go import path is valid relative path too.
// so check basic part of the path, which is "."
if filepath.IsAbs(importPath) || strings.HasPrefix(importPath, ".") {
errorf("Abort: '%s' looks like a directory. Please provide a Go import path instead.", errorf("Abort: '%s' looks like a directory. Please provide a Go import path instead.",
importPath) importPath)
} }