Browse Source

Handle non-word characters in repo name (fixes #152)

Jakob Borg 11 years ago
parent
commit
3e4d628f54
3 changed files with 5 additions and 16 deletions
  1. 0 0
      auto/gui.files.go
  2. 4 15
      cmd/syncthing/gui.go
  3. 1 1
      gui/app.js

File diff suppressed because it is too large
+ 0 - 0
auto/gui.files.go


+ 4 - 15
cmd/syncthing/gui.go

@@ -35,11 +35,10 @@ func startGUI(cfg GUIConfiguration, m *Model) {
 	router := martini.NewRouter()
 	router.Get("/", getRoot)
 	router.Get("/rest/version", restGetVersion)
-	router.Get("/rest/model/:repo", restGetModel)
+	router.Get("/rest/model", restGetModel)
 	router.Get("/rest/connections", restGetConnections)
 	router.Get("/rest/config", restGetConfig)
 	router.Get("/rest/config/sync", restGetConfigInSync)
-	router.Get("/rest/need/:repo", restGetNeed)
 	router.Get("/rest/system", restGetSystem)
 	router.Get("/rest/errors", restGetErrors)
 
@@ -80,8 +79,9 @@ func restGetVersion() string {
 	return Version
 }
 
-func restGetModel(m *Model, w http.ResponseWriter, params martini.Params) {
-	var repo = params["repo"]
+func restGetModel(m *Model, w http.ResponseWriter, r *http.Request) {
+	var qs = r.URL.Query()
+	var repo = qs.Get("repo")
 	var res = make(map[string]interface{})
 
 	globalFiles, globalDeleted, globalBytes := m.GlobalSize(repo)
@@ -168,17 +168,6 @@ func (f guiFile) MarshalJSON() ([]byte, error) {
 	})
 }
 
-func restGetNeed(m *Model, w http.ResponseWriter, params martini.Params) {
-	repo := params["repo"]
-	files := m.NeedFilesRepo(repo)
-	gfs := make([]guiFile, len(files))
-	for i, f := range files {
-		gfs[i] = guiFile(f)
-	}
-	w.Header().Set("Content-Type", "application/json")
-	json.NewEncoder(w).Encode(gfs)
-}
-
 var cpuUsagePercent [10]float64 // The last ten seconds
 var cpuUsageLock sync.RWMutex
 

+ 1 - 1
gui/app.js

@@ -82,7 +82,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
             getFailed();
         });
         $scope.repos.forEach(function (repo) {
-            $http.get('/rest/model/' + repo.ID).success(function (data) {
+            $http.get('/rest/model?repo=' + encodeURIComponent(repo.ID)).success(function (data) {
                 $scope.model[repo.ID] = data;
             });
         });

Some files were not shown because too many files changed in this diff