10
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
// See the License for the specific language governing permissions and
12
12
// limitations under the License.
13
+ //
14
+ // NOTE: The functions in this file (Unquote, unquoteChar, contains, unhex)
15
+ // have been adapted from the "strconv" package of the Go standard library
16
+ // to work for Prometheus-style strings. Go's special-casing for single
17
+ // quotes was removed and single quoted strings are now treated the same as
18
+ // double-quoted ones.
19
+ //
20
+ // The original copyright notice from the Go project for these parts is
21
+ // reproduced here:
22
+ //
23
+ // ========================================================================
24
+ // Copyright (c) 2009 The Go Authors. All rights reserved.
25
+ //
26
+ // Redistribution and use in source and binary forms, with or without
27
+ // modification, are permitted provided that the following conditions are
28
+ // met:
29
+ //
30
+ // * Redistributions of source code must retain the above copyright
31
+ // notice, this list of conditions and the following disclaimer.
32
+ // * Redistributions in binary form must reproduce the above
33
+ // copyright notice, this list of conditions and the following disclaimer
34
+ // in the documentation and/or other materials provided with the
35
+ // distribution.
36
+ // * Neither the name of Google Inc. nor the names of its
37
+ // contributors may be used to endorse or promote products derived from
38
+ // this software without specific prior written permission.
39
+ //
40
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51
+ // ========================================================================
13
52
14
53
package strutil
15
54
@@ -24,13 +63,6 @@ var ErrSyntax = errors.New("invalid syntax")
24
63
// Unquote interprets s as a single-quoted, double-quoted, or backquoted
25
64
// Prometheus query language string literal, returning the string value that s
26
65
// quotes.
27
- //
28
- // NOTE: This function as well as the necessary helper functions below
29
- // (unquoteChar, contains, unhex) and associated tests have been adapted from
30
- // the corresponding functions in the "strconv" package of the Go standard
31
- // library to work for Prometheus-style strings. Go's special-casing for single
32
- // quotes was removed and single quoted strings are now treated the same as
33
- // double quoted ones.
34
66
func Unquote (s string ) (t string , err error ) {
35
67
n := len (s )
36
68
if n < 2 {
0 commit comments