Permalink
Browse files

Merge pull request #1493 from joshwget/unquoted-question-marks

Allow question marks in unquoted kernel parameters
  • Loading branch information...
2 parents 95a8aa6 + c6232e6 commit 190749f6c19d45053bca56d0aef930426ff87d63 @SvenDowideit SvenDowideit committed on GitHub Jan 8, 2017
Showing with 10 additions and 7 deletions.
  1. +4 −4 config/config_test.go
  2. +6 −3 config/data_funcs.go
@@ -148,15 +148,15 @@ func TestParseCmdline(t *testing.T) {
assert.Equal(map[interface{}]interface{}{
"rancher": map[interface{}]interface{}{
- "strArray": []interface{}{"url:http://192.168.1.100/cloud-config"},
+ "strArray": []interface{}{"url:http://192.168.1.100/cloud-config?a=b"},
},
- }, parseCmdline("rancher.strArray=[\"url:http://192.168.1.100/cloud-config\"]"))
+ }, parseCmdline("rancher.strArray=[\"url:http://192.168.1.100/cloud-config?a=b\"]"))
assert.Equal(map[interface{}]interface{}{
"rancher": map[interface{}]interface{}{
- "strArray": []interface{}{"url:http://192.168.1.100/cloud-config"},
+ "strArray": []interface{}{"url:http://192.168.1.100/cloud-config?a=b"},
},
- }, parseCmdline("rancher.strArray=[url:http://192.168.1.100/cloud-config]"))
+ }, parseCmdline("rancher.strArray=[url:http://192.168.1.100/cloud-config?a=b]"))
}
func TestGet(t *testing.T) {
@@ -116,11 +116,12 @@ func getOrSetVal(args string, data map[interface{}]interface{}, value interface{
return "", tData
}
-// Replace newlines and colons with random strings
+// Replace newlines, colons, and question marks with random strings
// This is done to avoid YAML treating these as special characters
var (
- newlineMagicString = "9XsJcx6dR5EERYCC"
- colonMagicString = "V0Rc21pIVknMm2rr"
+ newlineMagicString = "9XsJcx6dR5EERYCC"
+ colonMagicString = "V0Rc21pIVknMm2rr"
+ questionMarkMagicString = "FoPL6JLMAaJqKMJT"
)
func reverseReplacement(result interface{}) interface{} {
@@ -138,6 +139,7 @@ func reverseReplacement(result interface{}) interface{} {
case string:
val = strings.Replace(val, newlineMagicString, "\n", -1)
val = strings.Replace(val, colonMagicString, ":", -1)
+ val = strings.Replace(val, questionMarkMagicString, "?", -1)
return val
}
@@ -147,6 +149,7 @@ func reverseReplacement(result interface{}) interface{} {
func unmarshalOrReturnString(value string) (result interface{}) {
value = strings.Replace(value, "\n", newlineMagicString, -1)
value = strings.Replace(value, ":", colonMagicString, -1)
+ value = strings.Replace(value, "?", questionMarkMagicString, -1)
if err := yaml.Unmarshal([]byte(value), &result); err != nil {
result = value
}

0 comments on commit 190749f

Please sign in to comment.