mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-23 00:26:50 +00:00
Categories: Sanitize names before processing
This commit is contained in:
parent
cdeb378327
commit
cc4f3c9aed
@ -40,7 +40,7 @@ func Contents(catName string) (hyphaList []string) {
|
|||||||
|
|
||||||
var mutex sync.RWMutex
|
var mutex sync.RWMutex
|
||||||
|
|
||||||
// AddHyphaToCategory adds the hypha to the category and updates the records on the disk. If the hypha is already in the category, nothing happens.
|
// AddHyphaToCategory adds the hypha to the category and updates the records on the disk. If the hypha is already in the category, nothing happens. Pass canonical names.
|
||||||
func AddHyphaToCategory(hyphaName, catName string) {
|
func AddHyphaToCategory(hyphaName, catName string) {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
if node, ok := hyphaToCategories[hyphaName]; ok {
|
if node, ok := hyphaToCategories[hyphaName]; ok {
|
||||||
@ -58,7 +58,7 @@ func AddHyphaToCategory(hyphaName, catName string) {
|
|||||||
go saveToDisk()
|
go saveToDisk()
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveHyphaFromCategory removes the hypha from the category and updates the records on the disk. If the hypha is not in the category, nothing happens.
|
// RemoveHyphaFromCategory removes the hypha from the category and updates the records on the disk. If the hypha is not in the category, nothing happens. Pass canonical names.
|
||||||
func RemoveHyphaFromCategory(hyphaName, catName string) {
|
func RemoveHyphaFromCategory(hyphaName, catName string) {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
if node, ok := hyphaToCategories[hyphaName]; ok {
|
if node, ok := hyphaToCategories[hyphaName]; ok {
|
||||||
|
@ -25,8 +25,8 @@ func handlerCategory(w http.ResponseWriter, rq *http.Request) {
|
|||||||
func handlerRemoveFromCategory(w http.ResponseWriter, rq *http.Request) {
|
func handlerRemoveFromCategory(w http.ResponseWriter, rq *http.Request) {
|
||||||
util.PrepareRq(rq)
|
util.PrepareRq(rq)
|
||||||
var (
|
var (
|
||||||
hyphaName = rq.PostFormValue("hypha")
|
hyphaName = util.CanonicalName(rq.PostFormValue("hypha"))
|
||||||
catName = rq.PostFormValue("cat")
|
catName = util.CanonicalName(rq.PostFormValue("cat"))
|
||||||
redirectTo = rq.PostFormValue("redirect-to")
|
redirectTo = rq.PostFormValue("redirect-to")
|
||||||
)
|
)
|
||||||
categories.RemoveHyphaFromCategory(hyphaName, catName)
|
categories.RemoveHyphaFromCategory(hyphaName, catName)
|
||||||
@ -36,8 +36,8 @@ func handlerRemoveFromCategory(w http.ResponseWriter, rq *http.Request) {
|
|||||||
func handlerAddToCategory(w http.ResponseWriter, rq *http.Request) {
|
func handlerAddToCategory(w http.ResponseWriter, rq *http.Request) {
|
||||||
util.PrepareRq(rq)
|
util.PrepareRq(rq)
|
||||||
var (
|
var (
|
||||||
hyphaName = rq.PostFormValue("hypha")
|
hyphaName = util.CanonicalName(rq.PostFormValue("hypha"))
|
||||||
catName = rq.PostFormValue("cat")
|
catName = util.CanonicalName(rq.PostFormValue("cat"))
|
||||||
redirectTo = rq.PostFormValue("redirect-to")
|
redirectTo = rq.PostFormValue("redirect-to")
|
||||||
)
|
)
|
||||||
categories.AddHyphaToCategory(hyphaName, catName)
|
categories.AddHyphaToCategory(hyphaName, catName)
|
||||||
|
Loading…
Reference in New Issue
Block a user