Changeset 944 for branches


Ignore:
Timestamp:
01/16/14 15:28:14 (7 years ago)
Author:
ramonb
Message:

jobmond/jobmond.py:

  • cgi escaping was not working: still errors occured
  • now just replace special characters with underscores
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.1/jobmond/jobmond.py

    r943 r944  
    3030from collections import deque
    3131from glob import glob
    32 import cgi
    3332
    3433VERSION='__VERSION__'
     
    9594
    9695    return loadConfig( JOBMOND_CONF )
     96
     97html_escape_table = {
     98    "&": "_",
     99    '"': "_",
     100    "'": "_",
     101    ">": "_",
     102    "<": "_",
     103}
     104
     105# If this is too slow:
     106# - re.sub(r'[\&|\>\<\'\"]','_', variable )
     107# - re.sub(r'[\&\>\<\'\"]','_', variable )
     108# - and even faster: compile regex
     109
     110def html_escape(text):
     111    """Produce entities within text."""
     112    return string.join((html_escape_table.get(c,c) for c in text), '')
    97113
    98114class GangliaConfigParser:
     
    10001016                        # fixme: It's getting
    10011017                        # ('nodes', None) items
    1002                         my_val_str = my_val_str + ' ' + val_name + '=' + cgi.escape(val_value)
     1018                        my_val_str = my_val_str + ' ' + val_name + '=' + html_escape(val_value)
    10031019                    except:
    10041020                        pass
    10051021
    10061022                else:
    1007                     my_val_str = val_name + '=' + cgi.escape(val_value)
     1023                    my_val_str = val_name + '=' + html_escape(val_value)
    10081024
    10091025            str_list.append( my_val_str )
Note: See TracChangeset for help on using the changeset viewer.