var _proxy_jslib_SCRIPT_NAME= "/70/nph-proxy.cgi" ; var _proxy_jslib_PROXY_GROUP= [] ; var _proxy_jslib_ALL_TYPES= ['', 'application/x-javascript', 'application/x-ecmascript', 'application/x-vbscript', 'application/x-perlscript', 'application/javascript', 'application/ecmascript', 'text/javascript', 'text/ecmascript', 'text/jscript', 'text/livescript', 'text/vbscript', 'text/vbs', 'text/perlscript', 'text/tcl', 'text/x-scriptlet', 'text/scriptlet', 'application/hta', 'text/css'] ; var _proxy_jslib_MIME_TYPE_ID= {'':0, 'text/javascript':7, 'application/x-javascript':1, 'application/x-perlscript':4, 'application/x-vbscript':3, 'text/tcl':14, 'text/vbs':12, 'text/jscript':9, 'text/ecmascript':8, 'application/javascript':5, 'text/perlscript':13, 'text/livescript':10, 'application/ecmascript':6, 'application/x-ecmascript':2, 'text/vbscript':11, 'text/x-scriptlet':15, 'text/css':18, 'text/scriptlet':16, 'application/hta':17} ; function _proxy_jslib_proxy_encode(URL) { URL= URL.replace(/^([\w\+\.\-]+)\:\/\//, '$1/') ; // URL= URL.replace(/(.)/g, function (s,p1) { return p1.charCodeAt(0).toString(16) } ) ; // URL= URL.replace(/([a-mA-M])|[n-zN-Z]/g, function (s,p1) { return String.fromCharCode(s.charCodeAt(0)+(p1?13:-13)) }) ; return URL ; } function _proxy_jslib_proxy_decode(enc_URL) { // enc_URL= enc_URL.replace(/([a-mA-M])|[n-zN-Z]/g, function (s,p1) { return String.fromCharCode(s.charCodeAt(0)+(p1?13:-13)) }) ; // enc_URL= enc_URL.replace(/([\da-fA-F]{2})/g, function (s,p1) { return String.fromCharCode(eval('0x'+p1)) } ) ; enc_URL= enc_URL.replace(/^([\w\+\.\-]+)\//, '$1://') ; return enc_URL ; } function _proxy_jslib_cookie_encode(cookie) { // cookie= cookie.replace(/(.)/g, function (s,p1) { return p1.charCodeAt(0).toString(16) } ) ; // cookie= cookie.replace(/([a-mA-M])|[n-zN-Z]/g, function (s,p1) { return String.fromCharCode(s.charCodeAt(0)+(p1!=null?13:-13)) }) ; cookie= cookie.replace(/(\W)/g, function (s,p1) { return '%'+p1.charCodeAt(0).toString(16) } ) ; return cookie ; } function _proxy_jslib_cookie_decode(enc_cookie) { enc_cookie= enc_cookie.replace(/%([\da-fA-F]{2})/g, function (s,p1) { return String.fromCharCode(eval('0x'+p1)) } ) ; // enc_cookie= enc_cookie.replace(/([a-mA-M])|[n-zN-Z]/g, function (s,p1) { return String.fromCharCode(s.charCodeAt(0)+(p1!=null?13:-13)) }) ; // enc_cookie= enc_cookie.replace(/([\da-fA-F]{2})/g, function (s,p1) { return String.fromCharCode(eval('0x'+p1)) } ) ; return enc_cookie ; } var _proxy_jslib_RE_FULL_URL ; var _proxy_jslib_url_start, _proxy_jslib_url_start_inframe, _proxy_jslib_url_start_noframe, _proxy_jslib_is_in_frame, _proxy_jslib_packed_flags, _proxy_jslib_URL ; var _proxy_jslib_base_url, _proxy_jslib_base_scheme, _proxy_jslib_base_host, _proxy_jslib_base_path, _proxy_jslib_base_file ; var _proxy_jslib_cookies_are_banned_here, _proxy_jslib_doing_insert_here, _proxy_jslib_SESSION_COOKIES_ONLY, _proxy_jslib_COOKIE_PATH_FOLLOWS_SPEC, _proxy_jslib_RESPECT_THREE_DOT_RULE, _proxy_jslib_default_script_type, _proxy_jslib_default_style_type ; var _proxy_jslib_RE, _proxy_jslib_needs_jslib ; var _proxy_jslib_write_buffers= [ {doc:document, has_js:true} ] ; var _proxy_jslib_wins= new Array() ; var _proxy_jslib_ret ; _proxy_jslib_init() ; //---- first, the two initialization functions ------------------------- // set _proxy_jslib_URL, _proxy_jslib_url_start, _proxy_jslib_packed_flags, // _proxy_jslib_is_in_frame, _proxy_jslib_url_start_inframe, _proxy_jslib_url_start_noframe // _proxy_jslib_base_url must be set elsewhere, to handle possibly coming from // HTTP headers. function _proxy_jslib_init() { // create global regex that matches a full URL, needed for _proxy_jslib_parse_full_url() var RE_SCRIPT_NAME= _proxy_jslib_global_replace(_proxy_jslib_SCRIPT_NAME, /(\W)/, function (p) { return '\\'+p[1] } ) ; _proxy_jslib_RE_FULL_URL= new RegExp('^('+RE_SCRIPT_NAME+')\\/?([^\\/]*)\\/?(.*)') ; // Mozilla sometimes adds 'wyciwyg://' to the URL var URL= document.URL.replace(/^wyciwyg:\/\/\d+\//i, '') ; var u= _proxy_jslib_parse_full_url(URL) ; if (_proxy_jslib_PROXY_GROUP.length) { _proxy_jslib_url_start= _proxy_jslib_PROXY_GROUP[Math.floor(Math.random()*_proxy_jslib_PROXY_GROUP.length)] +'/'+u[1]+'/' ; } else { _proxy_jslib_url_start= u[0]+'/'+u[1]+'/' ; } var flags= _proxy_jslib_unpack_flags(u[1]) ; _proxy_jslib_is_in_frame= flags[5] ; flags[5]= 1 ; // that's the frame flag _proxy_jslib_url_start_inframe= u[0]+'/'+_proxy_jslib_pack_flags(flags)+'/' ; flags[5]= 0 ; _proxy_jslib_url_start_noframe= u[0]+'/'+_proxy_jslib_pack_flags(flags)+'/' ; _proxy_jslib_packed_flags= u[1] ; _proxy_jslib_URL= u[2] ; // this begins life as the hostname window._proxy_jslib_document_domain= _proxy_jslib_parse_url(_proxy_jslib_URL)[4] ; _proxy_jslib_wins[0]= window ; //alert('end of init; _p_j_URL=\n['+_proxy_jslib_URL+']') ; } // set variables passed in from Perl program. function _proxy_jslib_pass_vars(base_url, cookies_are_banned_here, doing_insert_here, SESSION_COOKIES_ONLY, COOKIE_PATH_FOLLOWS_SPEC, RESPECT_THREE_DOT_RULE, default_script_type, default_style_type) { // set base_ vars from base_url _proxy_jslib_base_url= base_url.replace(/^\s+|\s+$/g, '') .replace(/^([\w\+\.\-]+\:\/\/[^\/\?]+)\/?/, "$1/") ; _proxy_jslib_base_scheme= _proxy_jslib_base_url.match(/^([\w\+\.\-]+\:)\/\//)[1] ; _proxy_jslib_base_host= _proxy_jslib_base_url.match(/^([\w\+\.\-]+\:\/\/[^\/\?]+)/)[1] ; _proxy_jslib_base_path= _proxy_jslib_base_url.match(/^([^\?]*\/)/)[1] ; _proxy_jslib_base_file= _proxy_jslib_base_url.match(/^([^\?]*)/)[1] ; // other settings _proxy_jslib_cookies_are_banned_here= cookies_are_banned_here ; _proxy_jslib_doing_insert_here= doing_insert_here ; _proxy_jslib_SESSION_COOKIES_ONLY= SESSION_COOKIES_ONLY ; _proxy_jslib_COOKIE_PATH_FOLLOWS_SPEC= COOKIE_PATH_FOLLOWS_SPEC ; _proxy_jslib_RESPECT_THREE_DOT_RULE= RESPECT_THREE_DOT_RULE ; _proxy_jslib_default_script_type= default_script_type.toLowerCase() ; _proxy_jslib_default_style_type= default_style_type.toLowerCase() ; } //---- the general handler routines _proxy_jslib_handle() and _proxy_jslib_assign() ---- // This is used when the property in question IS NOT being assigned to. function _proxy_jslib_handle (o, property, cur_val) { //alert('starting handle; o, property, URL=['+o+']['+property+']\n['+_proxy_jslib_URL+']') ; // guess when the window object is implied; this only matters with Window's // properties that we handle below if ((o===null) && property.match(/^(location|open|setInterval|setTimeout|frames|parent|top|opener|execScript|navigate|showModalDialog|showModelessDialog|parentWindow)$/) && (window[property]===cur_val)) o= window ; // handle eval() specially-- it (oddly) can be a property of any object if (property=='eval') return function (code) { if (o!=null) return o.eval(_proxy_jslib_proxify_js(code, 0)) ; else return eval(_proxy_jslib_proxify_js(code, 0)) ; } ; // if object is still null, merely return property value if (o==null) return cur_val ; var otype= _proxy_jslib_object_type(o) ; // handle any non-type-specific properties first, or properties that may // apply to different object types (e.g. the properties of Node) switch (property) { case 'insertAdjacentHTML': return function (where, text) { if (_proxy_jslib_node_is_in_document(o)) return o.insertAdjacentHTML(where, _proxy_jslib_proxify_html(text, false, o.document)[0]) ; return o.insertAdjacentHTML(where, text) ; } ; case 'setAttribute': return function (name, value) { if (_proxy_jslib_node_is_in_document(o)) return o.setAttribute(name.toLowerCase(), _proxy_jslib_proxify_attribute(name, value)) ; return o.setAttribute(name, value) ; } case 'setAttributeNode': return function (newAttr) { if (_proxy_jslib_node_is_in_document(o)) newAttr.nodeValue= _proxy_jslib_proxify_attribute(newAttr.nodeName, newAttr.nodeValue) ; return o.setAttributeNode(newAttr) ; } case 'appendChild': return function (newChild) { if (_proxy_jslib_node_is_in_document(o) && !_proxy_jslib_node_is_in_document(newChild)) return o.appendChild(_proxy_jslib_proxify_element(newChild)) ; return o.appendChild(newChild) ; } case 'insertBefore': return function (newChild, refChild) { if (_proxy_jslib_node_is_in_document(o) && !_proxy_jslib_node_is_in_document(newChild)) return o.insertBefore(_proxy_jslib_proxify_element(newChild), refChild) ; return o.insertBefore(newChild, refChild) ; } case 'replaceChild': return function (newChild, oldChild) { if (_proxy_jslib_node_is_in_document(o) && !_proxy_jslib_node_is_in_document(newChild)) return o.replaceChild(_proxy_jslib_proxify_element(newChild), oldChild) ; return o.replaceChild(newChild, oldChild) ; } case 'insertRule': return function (rule, index) { return o.insertRule(_proxy_jslib_proxify_css(rule), index) ; } // because some sites modify these in place, we must un-proxify these // when retrieving the value. // for Location objects, return the object, but handle toString() below // to unproxify it when needed. // jsm-- this will still leave Location proxified when toString() is // called implicitly. case 'src': case 'href': case 'background': case 'lowsrc': case 'action': case 'useMap': case 'longDesc': case 'cite': case 'codeBase': case 'location': var u= (o!=void 0) ? o[property] : cur_val ; if (u==void 0) return void 0 ; // return unchanged if u is a non-String object if ((typeof u=='object') && (u.toLowerCase==void 0)) return u ; // if o is a node, then deproxify only if it's in doc or is an Image if ((o.nodeName!==void 0) && (o.nodeType!==void 0) && (o.nodeValue!==void 0)) { if (_proxy_jslib_node_is_in_document(o) || (otype=='Image')) return _proxy_jslib_parse_full_url(u)[2] ; else return u ; } //if (u=='') alert('in handle, first switch; typeof, o, property, u, caller=['+typeof(o)+']['+o+']['+property+']['+u+']\n['+arguments.callee.caller+']') ; return _proxy_jslib_parse_full_url(u)[2] ; } // note use of closures to remember the object o switch (otype+'.'+property) { // Store new windows in a list so we can insert JS later if needed. // Store windows instead of documents, because docs may not be created yet. case 'Window.open': return function (url, name, features, replace) { var win= o.open(_proxy_jslib_full_url(url), name, features, replace) ; if (url) win._proxy_jslib_document_domain= _proxy_jslib_parse_url(url)[4] ; _proxy_jslib_wins[_proxy_jslib_wins.length]= win ; return win ; } ; case 'Document.open': return function(arg1, name, features, replace) { if (arguments.length<=2) { return o.open(arg1, name) ; } else { // MSIE-specific return o.open(_proxy_jslib_full_url(arg1), name, features, replace) ; } } case 'Document.write': // buffer the output by document // no return value return function () { for (var i= 0 ; i; not setting cookie.") ; return '' ; } var source_server= u[4] ; var source_path= u[6] ; if (source_path.substr(0,1)!='/') source_path= '/' + source_path ; var name, value, expires_clause, path, domain, secure_clause ; var new_name, new_value, new_cookie ; name= value= expires_clause= path= domain= secure_clause= new_name= new_value= new_cookie= '' ; if (/^\s*([^\=\;\,\s]*)\s*\=?\s*([^\;\,\s]*)/.test(cookie)) { name= RegExp.$1 ; value= RegExp.$2 ; } if (/\;\s*(expires\s*\=[^\;]*)/i.test(cookie)) expires_clause= RegExp.$1 ; if (/\;\s*path\s*\=\s*([^\;\,\s]*)/i.test(cookie)) path= RegExp.$1 ; if (/\;\s*domain\s*\=\s*([^\;\,\s]*)/i.test(cookie)) domain= RegExp.$1 ; if (/\;\s*(secure\b)/i.test(cookie)) secure_clause= RegExp.$1 ; if (path=='') path= _proxy_jslib_COOKIE_PATH_FOLLOWS_SPEC ? source_path : '/' ; if (domain=='') { domain= source_server ; } else { domain= domain.replace(/\.+$/, '') ; domain= domain.replace(/\.{2,}/g, '.') ; if ( (source_server.substr(source_server.length-domain.length)!=domain.toLowerCase()) && ('.'+source_server!=domain) ) return '' ; var dots= domain.match(/\./g) ; if (_proxy_jslib_RESPECT_THREE_DOT_RULE) { if (dots.length<3 && !( dots.length>=2 && /\.(com|edu|net|org|gov|mil|int)$/i.test(domain) ) ) return '' ; } else { if (dots.length<2) { if (domain.match(/^\./)) return '' ; domain= '.'+domain ; if (dots.length<1) return '' ; } } } new_name= _proxy_jslib_cookie_encode('COOKIE;'+name+';'+path+';'+domain) ; new_value= _proxy_jslib_cookie_encode(value+';'+secure_clause) ; if (_proxy_jslib_SESSION_COOKIES_ONLY && (expires_clause!='')) { /^expires\s*\=\s*(.*)$/i.test(expires_clause) ; var expires_date= RegExp.$1.replace(/\-/g, ' ') ; // Date.parse() can't handle "-" if ( Date.parse(expires_date) > (new Date()).getTime() ) expires_clause= '' ; } new_cookie= new_name+'='+new_value ; if (expires_clause!='') new_cookie= new_cookie+'; '+expires_clause ; new_cookie= new_cookie+'; path='+_proxy_jslib_SCRIPT_NAME+'/' ; if (secure_clause!='') new_cookie= new_cookie+'; '+secure_clause ; return new_cookie ; } function _proxy_jslib_cookie_from_client() { if (_proxy_jslib_cookies_are_banned_here) return '' ; if (!document.cookie) return '' ; var target_path, target_server, target_scheme ; var u= _proxy_jslib_parse_url(_proxy_jslib_URL) ; if (u==null) { alert("CGIProxy Error: Can't parse URL <"+_proxy_jslib_URL+">; not using cookie.") ; return ; } target_scheme= u[1] ; target_server= u[4] ; target_path= u[6] ; if (target_path.substr(0,1)!='/') target_path= '/' + target_path ; var matches= new Array() ; var pathlen= new Object() ; var cookies= document.cookie.split(/\s*;\s*/) ; for (var c in cookies) { var nv= cookies[c].split(/=/, 2) ; var name= _proxy_jslib_cookie_decode(nv[0]) ; var value= _proxy_jslib_cookie_decode(nv[1]) ; var n= name.split(/;/) ; if (n[0]=='COOKIE') { var cname, path, domain, cvalue, secure ; cname= n[1] ; path= n[2] ; domain= n[3].toLowerCase() ; var v= value.split(/;/) ; cvalue= v[0] ; secure= v[1] ; if (secure!='' && secure!=null && target_scheme!='https:') continue ; if ( ((target_server.substr(target_server.length-domain.length)==domain) || (domain=='.'+target_server)) && target_path.substr(0, path.length)==path ) { matches[matches.length]= cname ? cname+'='+cvalue : cvalue ; pathlen[cname+'='+cvalue]= path.length ; } } } matches.sort(function (v1,v2) { return (pathlen[v2]-pathlen[v1]) } ) ; return matches.join('; ') ; } // returns [new_html, needs_jslib, found_frameset] function _proxy_jslib_proxify_html(html, is_full_page, doc) { var out= '' ; var m1, m2, m3, rem ; var html_pos, head_pos ; if (is_full_page) _proxy_jslib_needs_jslib= false ; while (html!='') { var start= html.match(/^[^\<]*/) ; out+= start[0] ; html= html.substr(start[0].length) ; // because not all browsers support non-greedy matching, next six // blocks emulate it. if (m1= html.match(/^\<\!\-\-/)) { rem= html.substr(4) ; if (rem.match(/\-\-\>/)) { m2= rem.match(/\-\-\s*\>/) ; } else if (m2= rem.match(/\>/)) { } else { html= '' ; break ; } var comment= html.substr(0, 4+m2.index+m2[0].length) ; html= html.substr(comment.length) ; out+= _proxy_jslib_proxify_comment(comment) ; continue ; } if (m1= html.match(/^\<\s*script\b/i)) { rem= html.substr(m1[0].length) ; if (m2= rem.match(/\<\s*\/script\b/i)) { rem= html.substr(m1[0].length+m2.index+m2[0].length) ; if (m3= rem.match(/\>/)) { var script_block= html.substr(0, m1[0].length+m2.index+m2[0].length+m3.index+1) ; html= html.substr(script_block.length) ; out+= _proxy_jslib_proxify_script_block(script_block) ; continue ; } } } if (m1= html.match(/^\<\s*style\b/i)) { rem= html.substr(m1[0].length) ; if (m2= rem.match(/\<\s*\/style\b/i)) { rem= html.substr(m1[0].length+m2.index+m2[0].length) ; if (m3= rem.match(/\>/)) { var style_block= html.substr(0, m1[0].length+m2.index+m2[0].length+m3.index+1) ; html= html.substr(style_block.length) ; out+= _proxy_jslib_proxify_style_block(style_block) ; continue ; } } } if (m1= html.match(/^\<\![^\>]*\>?/)) { out+= _proxy_jslib_proxify_decl_bang(m1[0]) ; html= html.substr(m1[0].length) ; continue ; } if (m1= html.match(/^\<\?[^\>]*\>?/)) { out+= _proxy_jslib_proxify_decl_question(m1[0]) ; html= html.substr(m1[0].length) ; continue ; } // gmail has a bug where a tag is missing the closing ">", // so disallow "<" in tag here to avoid including following tag. //if (m1= html.match(/^\<[^\>]*\>?/)) { if (m1= html.match(/^\<[^\<>]*\>?/)) { //if (m1[0].match(/[01]{6}[A-Z]/)) alert('in proxify_html; m1[0], caller=\n['+m1[0]+']\n'+arguments.callee.caller+']') ; // For JS insertions, and tags. Ignore declarations for now. if (m2= m1[0].match(/^\<\s*([A-Za-z][\w\.\:\-]*)/)) { var tag_name= m2[1].toLowerCase() ; if ((tag_name=='frameset') && _proxy_jslib_doing_insert_here && !_proxy_jslib_is_in_frame) { _proxy_jslib_return_frame_doc(_proxy_jslib_wrap_proxy_encode(_proxy_jslib_URL), doc) ; return ['', false, true] ; } if (tag_name=='html') { html_pos= out.length } else if (tag_name=='head') { head_pos= out.length } } out+= _proxy_jslib_proxify_element(m1[0]) ; html= html.substr(m1[0].length) ; continue ; } break ; } // This handles rare case. Don't worry about top insertion. Hacky. if (is_full_page && _proxy_jslib_needs_jslib) { var jslib_block= '