summaryrefslogtreecommitdiffstats
path: root/app/plugin.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-12-01 23:20:11 -0800
committerGitHub <noreply@github.com>2017-12-01 23:20:11 -0800
commit81c1fad4d4fcc48eebc61905fe4a6226350edd88 (patch)
tree528bbaa725b26b6b3743ac16adff5cb44a81d8d9 /app/plugin.go
parentc3af8785734803b6199a28249537ef3e47fe4caa (diff)
downloadchat-81c1fad4d4fcc48eebc61905fe4a6226350edd88.tar.gz
chat-81c1fad4d4fcc48eebc61905fe4a6226350edd88.tar.bz2
chat-81c1fad4d4fcc48eebc61905fe4a6226350edd88.zip
Revert "Hash key for plugin store table and limit plugin ID length (#7915)" (#7931)
This reverts commit c3af8785734803b6199a28249537ef3e47fe4caa.
Diffstat (limited to 'app/plugin.go')
-rw-r--r--app/plugin.go23
1 files changed, 3 insertions, 20 deletions
diff --git a/app/plugin.go b/app/plugin.go
index e8844d821..29031b9d7 100644
--- a/app/plugin.go
+++ b/app/plugin.go
@@ -6,15 +6,12 @@ package app
import (
"bytes"
"context"
- "crypto/sha256"
- "encoding/base64"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"strings"
- "unicode/utf8"
l4g "github.com/alecthomas/log4go"
@@ -30,10 +27,6 @@ import (
"github.com/mattermost/mattermost-server/plugin/pluginenv"
)
-const (
- PLUGIN_MAX_ID_LENGTH = 200
-)
-
var prepackagedPlugins map[string]func(string) ([]byte, error) = map[string]func(string) ([]byte, error){
"jira": jira.Asset,
}
@@ -154,10 +147,6 @@ func (a *App) installPlugin(pluginFile io.Reader, allowPrepackaged bool) (*model
return nil, model.NewAppError("installPlugin", "app.plugin.prepackaged.app_error", nil, "", http.StatusBadRequest)
}
- if utf8.RuneCountInString(manifest.Id) > PLUGIN_MAX_ID_LENGTH {
- return nil, model.NewAppError("installPlugin", "app.plugin.id_length.app_error", map[string]interface{}{"Max": PLUGIN_MAX_ID_LENGTH}, err.Error(), http.StatusBadRequest)
- }
-
bundles, err := a.PluginEnv.Plugins()
if err != nil {
return nil, model.NewAppError("installPlugin", "app.plugin.install.app_error", nil, err.Error(), http.StatusInternalServerError)
@@ -484,16 +473,10 @@ func (a *App) ShutDownPlugins() {
a.PluginEnv = nil
}
-func getKeyHash(key string) string {
- hash := sha256.New()
- hash.Write([]byte(key))
- return base64.StdEncoding.EncodeToString(hash.Sum(nil))
-}
-
func (a *App) SetPluginKey(pluginId string, key string, value []byte) *model.AppError {
kv := &model.PluginKeyValue{
PluginId: pluginId,
- Key: getKeyHash(key),
+ Key: key,
Value: value,
}
@@ -507,7 +490,7 @@ func (a *App) SetPluginKey(pluginId string, key string, value []byte) *model.App
}
func (a *App) GetPluginKey(pluginId string, key string) ([]byte, *model.AppError) {
- result := <-a.Srv.Store.Plugin().Get(pluginId, getKeyHash(key))
+ result := <-a.Srv.Store.Plugin().Get(pluginId, key)
if result.Err != nil {
if result.Err.StatusCode == http.StatusNotFound {
@@ -523,7 +506,7 @@ func (a *App) GetPluginKey(pluginId string, key string) ([]byte, *model.AppError
}
func (a *App) DeletePluginKey(pluginId string, key string) *model.AppError {
- result := <-a.Srv.Store.Plugin().Delete(pluginId, getKeyHash(key))
+ result := <-a.Srv.Store.Plugin().Delete(pluginId, key)
if result.Err != nil {
l4g.Error(result.Err.Error())