Skip to content

Commit

Permalink
Merge pull request #3449 from dannon/backport_mistargeted_3429
Browse files Browse the repository at this point in the history
[16.10] Backport of 3429, safestringwrapper
  • Loading branch information
jmchilton committed Jan 19, 2017
2 parents 02a8a7d + f508260 commit c9fdb6e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/galaxy/util/object_wrapper.py
Expand Up @@ -184,6 +184,7 @@ def pickle_safe_object( safe_object ):
# Set pickle and copy properties
copy_reg.pickle( wrapped_class, pickle_safe_object, do_wrap_func )
return wrapped_class( value, safe_string_wrapper_function=do_wrap_func )

# Determine classes not to wrap
if no_wrap_classes:
if not isinstance( no_wrap_classes, ( tuple, list ) ):
Expand Down Expand Up @@ -214,7 +215,7 @@ class SafeStringWrapper( object ):
will still be sanitized, but not wrapped), and e.g. integers will have neither.
"""
__UNSANITIZED_ATTRIBUTE_NAME__ = 'unsanitized'
__NO_WRAP_NAMES__ = [ '__safe_string_wrapper_function__', __UNSANITIZED_ATTRIBUTE_NAME__]
__NO_WRAP_NAMES__ = [ '__safe_string_wrapper_function__', '__class__', __UNSANITIZED_ATTRIBUTE_NAME__]

def __new__( cls, *arg, **kwd ):
# We need to define a __new__ since, we are subclassing from e.g. immutable str, which internally sets data
Expand Down Expand Up @@ -284,7 +285,7 @@ def __bool__( self ):
def __getattr__( self, name ):
if name in SafeStringWrapper.__NO_WRAP_NAMES__:
# FIXME: is this ever reached?
return object.__getattr__( self, name )
return object.__getattribute__( self, name )
return self.__safe_string_wrapper_function__( getattr( self.unsanitized, name ) )

def __setattr__( self, name, value ):
Expand Down

0 comments on commit c9fdb6e

Please sign in to comment.