Changeset c02bb9c in github


Ignore:
Timestamp:
Oct 7, 2008 3:27:29 AM (5 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
27a12ed
Parents:
2727053
Message:

#1485472: added js keywords escaping in json_serialize()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_shared.inc

    rf613a1e rc02bb9c  
    110110 
    111111/** 
     112 * Returns whether an $str is a reserved word for any of the version of Javascript or ECMAScript 
     113 * @param str String to check 
     114 * @return boolean True if $str is a reserver word, False if not 
     115 */ 
     116function is_js_reserved_word($str) 
     117{ 
     118  return in_array($str, array( 
     119    // ECMASript ver 4 reserved words 
     120    'as','break','case','catch','class','const','continue', 
     121    'default','delete','do','else','export','extends','false','finally','for','function', 
     122    'if','import','in','instanceof','is','namespace','new','null','package','private', 
     123    'public','return','super','switch','this','throw','true','try','typeof','use','var', 
     124    'void','while','with', 
     125    // ECMAScript ver 4 future reserved words 
     126    'abstract','debugger','enum','goto','implements','interface','native','protected', 
     127    'synchronized','throws','transient','volatile', 
     128    // special meaning in some contexts 
     129    'get','set', 
     130    // were reserved in ECMAScript ver 3 
     131    'boolean','byte','char','double','final','float','int','long','short','static' 
     132  )); 
     133} 
     134 
     135 
     136/** 
    112137 * Convert a variable into a javascript object notation 
    113138 * 
     
    146171      { 
    147172        // enclose key with quotes if it is not variable-name conform 
    148         if (!ereg("^[_a-zA-Z]{1}[_a-zA-Z0-9]*$", $key) /* || is_js_reserved_word($key) */) 
     173        if (!ereg("^[_a-zA-Z]{1}[_a-zA-Z0-9]*$", $key) || is_js_reserved_word($key)) 
    149174          $key = "'$key'"; 
    150175 
     
    163188 
    164189} 
     190 
    165191 
    166192/** 
Note: See TracChangeset for help on using the changeset viewer.