@@ -676,6 +676,7 @@ def get(self, path_segment="", owner=None, app=None, sharing=None, **query):
676676 # self.path to the Endpoint is relative in the SDK, so passing
677677 # owner, app, sharing, etc. along will produce the correct
678678 # namespace in the final request.
679+ if not isinstance (path_segment , UrlEncoded ): path_segment = UrlEncoded (path_segment , encode_slash = True )
679680 if path_segment .startswith ('/' ):
680681 path = path_segment
681682 else :
@@ -1519,6 +1520,7 @@ def delete(self, name, **params):
15191520 saved_searches.delete('my_saved_search')
15201521 assert 'my_saved_search' not in saved_searches
15211522 """
1523+ if not isinstance (name , UrlEncoded ): name = UrlEncoded (name , encode_slash = True )
15221524 if 'namespace' in params :
15231525 namespace = params .pop ('namespace' )
15241526 params ['owner' ] = namespace .owner
@@ -1959,15 +1961,10 @@ def __getitem__(self, key):
19591961 # The key needed to retrieve the input needs it's parenthesis to be URL encoded
19601962 # based on the REST API for input
19611963 # <http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTinput>
1962- def checkKey (url ):
1963- while True :
1964- if url is urllib .unquote (url ): break
1965- else : url = urllib .unquote (url )
1966- return urllib .quote (url ,'' )
19671964 if isinstance (key , tuple ) and len (key ) == 2 :
19681965 # Fetch a single kind
19691966 key , kind = key
1970- key = checkKey (key )
1967+ if not isinstance ( key , UrlEncoded ): key = UrlEncoded (key , encode_slash = True )
19711968 try :
19721969 response = self .get (self .kindpath (kind ) + "/" + key )
19731970 entries = self ._load_list (response )
@@ -1984,7 +1981,7 @@ def checkKey(url):
19841981 raise
19851982 else :
19861983 # Iterate over all the kinds looking for matches.
1987- key = checkKey (key )
1984+ if not isinstance ( key , UrlEncoded ): key = UrlEncoded (key , encode_slash = True )
19881985 kind = None
19891986 candidate = None
19901987 for kind in self .kinds :
@@ -2078,11 +2075,15 @@ def create(self, name, kind, **kwargs):
20782075 # If we created an input with restrictToHost set, then
20792076 # its path will be <restrictToHost>:<name>, not just <name>,
20802077 # and we have to adjust accordingly.
2078+
2079+ # Must check if the name passed in is UrlEncoded and change it accordingly.
2080+ if not isinstance (name , UrlEncoded ): name = UrlEncoded (name , encode_slash = True )
2081+
20812082 path = _path (
20822083 self .path + kindpath ,
2083- '%s:%s' % urllib . quote (( kwargs ['restrictToHost' ], name ), '' ) \
2084- if kwargs .has_key ('restrictToHost' ) else urllib . quote ( name , '' ) # Need to change path to URL encoded name
2085- )
2084+ '%s:%s' % ( kwargs ['restrictToHost' ], name ) \
2085+ if kwargs .has_key ('restrictToHost' ) else name
2086+ )
20862087 return Input (self .service , path , kind )
20872088
20882089 def delete (self , name , kind = None ):
0 commit comments