1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Cloudflare Redirects (#119)

* function sig

* sig

* some custom record infrastructure

* CLOUDFLARE REDIRECTS!

* comments out

* guarding redirects behind provider metadata to manage

* catch commas in js to ensure proper encoding.

* gen

* small fix

* revendor otto

* docs
This commit is contained in:
Craig Peterson
2017-05-19 14:15:57 -04:00
committed by GitHub
parent a355b8e438
commit f1a0d65198
18 changed files with 471 additions and 99 deletions

View File

@@ -88,7 +88,7 @@ Set a Go function that returns something useful
```go
vm.Set("twoPlus", func(call otto.FunctionCall) otto.Value {
right, _ := call.Argument(0).ToInteger()
return, _ := vm.ToValue(2 + right)
result, _ := vm.ToValue(2 + right)
return result
})
```
@@ -114,7 +114,7 @@ http://godoc.org/github.com/robertkrimen/otto/parser
Parse and return an AST
```go
filenamee := "" // A filename is optional
filename := "" // A filename is optional
src := `
// Sample xyzzy example
(function(){
@@ -167,6 +167,7 @@ The following are some limitations with otto:
* "use strict" will parse, but does nothing.
* The regular expression engine (re2/regexp) is not fully compatible with the ECMA5 specification.
* Otto targets ES5. ES6 features (eg: Typed Arrays) are not supported.
### Regular Expression Incompatibility

View File

@@ -70,7 +70,7 @@ func digitValue(chr rune) int {
}
func builtinGlobal_parseInt(call FunctionCall) Value {
input := strings.TrimSpace(call.Argument(0).string())
input := strings.Trim(call.Argument(0).string(), builtinString_trim_whitespace)
if len(input) == 0 {
return NaNValue()
}
@@ -153,7 +153,8 @@ var parseFloat_matchValid = regexp.MustCompile(`[0-9eE\+\-\.]|Infinity`)
func builtinGlobal_parseFloat(call FunctionCall) Value {
// Caveat emptor: This implementation does NOT match the specification
input := strings.TrimSpace(call.Argument(0).string())
input := strings.Trim(call.Argument(0).string(), builtinString_trim_whitespace)
if parseFloat_matchBadSpecial.MatchString(input) {
return NaNValue()
}

View File

@@ -132,6 +132,7 @@ The following are some limitations with otto:
* "use strict" will parse, but does nothing.
* The regular expression engine (re2/regexp) is not fully compatible with the ECMA5 specification.
* Otto targets ES5. ES6 features (eg: Typed Arrays) are not supported.
Regular Expression Incompatibility

View File

@@ -302,7 +302,11 @@ func (self *_runtime) convertCallParameter(v Value, t reflect.Type) reflect.Valu
}
if t.Kind() == reflect.Interface {
iv := reflect.ValueOf(v.export())
e := v.export()
if e == nil {
return reflect.Zero(t)
}
iv := reflect.ValueOf(e)
if iv.Type().AssignableTo(t) {
return iv
}
@@ -352,20 +356,52 @@ func (self *_runtime) convertCallParameter(v Value, t reflect.Type) reflect.Valu
tt := t.Elem()
for i := int64(0); i < l; i++ {
p, ok := o.property[strconv.FormatInt(i, 10)]
if !ok {
continue
if o.class == "Array" {
for i := int64(0); i < l; i++ {
p, ok := o.property[strconv.FormatInt(i, 10)]
if !ok {
continue
}
e, ok := p.value.(Value)
if !ok {
continue
}
ev := self.convertCallParameter(e, tt)
s.Index(int(i)).Set(ev)
}
} else if o.class == "GoArray" {
var gslice bool
switch o.value.(type) {
case *_goSliceObject:
gslice = true
case *_goArrayObject:
gslice = false
}
e, ok := p.value.(Value)
if !ok {
continue
for i := int64(0); i < l; i++ {
var p *_property
if gslice {
p = goSliceGetOwnProperty(o, strconv.FormatInt(i, 10))
} else {
p = goArrayGetOwnProperty(o, strconv.FormatInt(i, 10))
}
if p == nil {
continue
}
e, ok := p.value.(Value)
if !ok {
continue
}
ev := self.convertCallParameter(e, tt)
s.Index(int(i)).Set(ev)
}
ev := self.convertCallParameter(e, tt)
s.Index(int(i)).Set(ev)
}
return s

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"math"
"reflect"
"unicode/utf16"
)
func (value Value) bool() bool {
@@ -32,6 +33,8 @@ func (value Value) bool() bool {
return true
case string:
return 0 != len(value)
case []uint16:
return 0 != len(utf16.Decode(value))
}
if value.IsObject() {
return true

View File

@@ -11,7 +11,7 @@ import (
var stringToNumberParseInteger = regexp.MustCompile(`^(?:0[xX])`)
func parseNumber(value string) float64 {
value = strings.TrimSpace(value)
value = strings.Trim(value, builtinString_trim_whitespace)
if value == "" {
return 0

6
vendor/vendor.json vendored
View File

@@ -303,10 +303,10 @@
"revisionTime": "2016-04-18T18:49:04Z"
},
{
"checksumSHA1": "UH75lsKCrVFdCZvJchkAPo2QXjw=",
"checksumSHA1": "EqyHXBcg5cWi4ERsMXN6g1opi1o=",
"path": "github.com/robertkrimen/otto",
"revision": "7d9cbc2befca39869eb0e5bcb0f44c0692c2f8ff",
"revisionTime": "2016-07-28T22:04:12Z"
"revision": "21ec96599b1279b5673e4df0097dd56bb8360068",
"revisionTime": "2017-04-24T10:46:44Z"
},
{
"checksumSHA1": "qgziiO3/QDVJMKw2nGrUbC8QldY=",