1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/02df5336a7b2/ changeset: 02df5336a7b2 branches: user: greg date: 2011-06-02 22:16:56 summary: Add baseline support for translating special chars to html escape codes for correct html display. Fixes issue # 564. affected #: 1 file (750 bytes) --- a/lib/galaxy/webapps/community/controllers/repository.py Thu Jun 02 15:18:35 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/repository.py Thu Jun 02 16:16:56 2011 -0400 @@ -14,7 +14,12 @@ log = logging.getLogger( __name__ ) VALID_REPOSITORYNAME_RE = re.compile( "^[a-z0-9\_]+$" ) - +# Characters that are valid +VALID_CHARS = set( string.letters + string.digits ) +# Characters that must be html escaped +MAPPED_CHARS = { '>' :'>', + '<' :'<' } + class CategoryListGrid( grids.Grid ): # TODO rename this class to be categoryListGrid when we eliminate all the tools stuff. class NameColumn( grids.TextColumn ): @@ -167,7 +172,18 @@ repository_list_grid = RepositoryListGrid() category_list_grid = CategoryListGrid() - + + # TODO: These translations are costly, so figure out a better way... + def from_html_escaped( self, text ): + """Restores sanitized text""" + for key, value in MAPPED_CHARS.items(): + text = text.replace( value, key ) + return text + def to_html_escape_code( self, text ): + """Restricts the characters that are allowed in a text""" + for key, value in MAPPED_CHARS.items(): + text = text.replace( key, value ) + return text @web.expose def index( self, trans, **kwd ): params = util.Params( kwd ) @@ -564,7 +580,7 @@ for diff in patch.diff( repo, node1=ctx_parent.node(), node2=ctx.node() ): if not util.is_multi_byte( diff ) and not is_binary( diff ): # TODO: is there a better way? - diffs.append( diff ) + diffs.append( self.to_html_escape_code( diff ) ) else: fixed_diff = diff.split( '\n' )[0] + '\nFile contains non-ascii characters that cannot be displayed\n' diffs.append( fixed_diff ) @@ -679,6 +695,7 @@ output = pexpect.run( cmd, events={ pexpect.TIMEOUT : print_ticks }, timeout=10 ) + output = self.to_html_escape_code( output ) return unicode( output.replace( '\r\n', '<br/>' ).replace( ' ', ' ' ) ) @web.expose def help( self, trans, **kwd ): Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.