def fixup_ff4(p):
 name = []
 num = 0
 start = amp = False
 for ch in p:
  if start:
   if ch.isdigit():
    num += ch
   elif (ch == ';'):
    name.append(unichr(int(num)).encode('utf8'))
    start = False
   else:
    name.append(('&#%s%s' % (num, ch)))
    start = False
  elif (ch == '&'):
   amp = True
  elif amp:
   amp = False
   if (ch == '#'):
    start = True
    num = ''
   else:
    name.append(('&' + ch))
  else:
   name.append(ch)
 return ''.join(name)

def fixup_ff4 ( p ) : name = [ ] num = 0 start = amp = False for ch in p : if start : if ch . isdigit ( ) : num += ch elif ( ch == ';' ) : name . append ( unichr ( int ( num ) ) . encode ( 'utf8' ) ) start = False else : name . append ( ( '&#%s%s' % ( num , ch ) ) ) start = False elif ( ch == '&' ) : amp = True elif amp : amp = False if ( ch == '#' ) : start = True num = '' else : name . append ( ( '&' + ch ) ) else : name . append ( ch ) return '' . join ( name )
fix incompatibility between cherrypy and firefox-4 on osx .