Permalink
Browse files

Allow question marks in unquoted kernel parameters

  • Loading branch information...
1 parent 81b35c6 commit c6232e67aab415321d4de778aa29af75dbf3acc5 @joshwget joshwget committed Jan 5, 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 c6232e6

Please sign in to comment.