Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2021-02-04 08:30:43 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-02-05 06:46:58 +0300
commit754454c5ca27893406d5b1d329395bf4f633dc2b (patch)
tree43c84413469a8f234c450adb5a1bd5f696eec917
parentb164b4ad89637327dacfcbcd11b6f624b2acf23e (diff)
Add copyright and license
Also make sure we resolve the absolute path for allowedPaths
-rw-r--r--internal/httpfs/LICENSE27
-rw-r--r--internal/httpfs/http_fs.go16
2 files changed, 43 insertions, 0 deletions
diff --git a/internal/httpfs/LICENSE b/internal/httpfs/LICENSE
new file mode 100644
index 00000000..6a66aea5
--- /dev/null
+++ b/internal/httpfs/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/internal/httpfs/http_fs.go b/internal/httpfs/http_fs.go
index 671ab521..ae9aa269 100644
--- a/internal/httpfs/http_fs.go
+++ b/internal/httpfs/http_fs.go
@@ -1,7 +1,14 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Based on https://golang.org/src/net/http/fs.go
+
package httpfs
import (
"errors"
+ "log"
"net/http"
"os"
"path"
@@ -21,6 +28,15 @@ type fileSystemPaths struct {
// NewFileSystemPath creates a new fileSystemPaths that can be used to register
// a file:// protocol with an http.Transport
func NewFileSystemPath(allowedPaths []string) http.FileSystem {
+ for k, path := range allowedPaths {
+ var err error
+
+ allowedPaths[k], err = filepath.Abs(path)
+ if err != nil {
+ log.Fatal(err)
+ }
+ }
+
return &fileSystemPaths{
allowedPaths: allowedPaths,
}