1 const char killpopup_rcs[] = "$Id: killpopup.c,v 1.9 2001/07/31 14:44:22 oes Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/killpopup.c,v $
6 * Purpose : Handles the filtering of popups.
8 * Copyright : Written by and Copyright (C) 2001 the SourceForge
9 * IJBSWA team. http://ijbswa.sourceforge.net
11 * Based on the Internet Junkbuster originally written
12 * by and Copyright (C) 1997 Anonymous Coders and
13 * Junkbusters Corporation. http://www.junkbusters.com
15 * This program is free software; you can redistribute it
16 * and/or modify it under the terms of the GNU General
17 * Public License as published by the Free Software
18 * Foundation; either version 2 of the License, or (at
19 * your option) any later version.
21 * This program is distributed in the hope that it will
22 * be useful, but WITHOUT ANY WARRANTY; without even the
23 * implied warranty of MERCHANTABILITY or FITNESS FOR A
24 * PARTICULAR PURPOSE. See the GNU General Public
25 * License for more details.
27 * The GNU General Public License should be included with
28 * this file. If not, you can view it at
29 * http://www.gnu.org/copyleft/gpl.html
30 * or write to the Free Software Foundation, Inc., 59
31 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 * $Log: killpopup.c,v $
35 * Revision 1.9 2001/07/31 14:44:22 oes
36 * Deleted unused size parameter from filter_popups()
38 * Revision 1.8 2001/07/30 22:08:36 jongfoster
39 * Tidying up #defines:
40 * - All feature #defines are now of the form FEATURE_xxx
41 * - Permanently turned off WIN_GUI_EDIT
42 * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
44 * Revision 1.7 2001/07/20 19:29:25 haroon
45 * - In v1.5 forgot to add that I implemented LOG_LEVEL_POPUPS in errlog.c,
46 * errlog.h and killpopup.c. In that case, it is superfluous to have define for
47 * POPUP_VERBOSE, so I removed the defines and logging is now done
48 * via log_error(LOG_LEVEL_POPUPS, ....)
50 * Revision 1.6 2001/07/19 19:11:35 haroon
51 * - Implemented Guy's idea of replacing window.open( with 1;''.concat(
52 * - Implemented Guy's idea of replacing .resizeTo( with .scrollTo(
54 * Revision 1.5 2001/07/18 15:02:52 haroon
55 * improved nuking of window.open
57 * Revision 1.4 2001/06/29 13:29:55 oes
58 * Added FIXMEs (and didn't repair, hehe)
60 * Revision 1.3 2001/05/22 18:56:28 oes
63 * Revision 1.2 2001/05/20 01:21:20 jongfoster
64 * Version 2.9.4 checkin.
65 * - Merged popupfile and cookiefile, and added control over PCRS
66 * filtering, in new "permissionsfile".
67 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
68 * file error you now get a message box (in the Win32 GUI) rather
69 * than the program exiting with no explanation.
70 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
72 * - Removed tabs from "config"
73 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
74 * - Bumped up version number.
76 * Revision 1.1.1.1 2001/05/15 13:58:58 oes
77 * Initial import of version 2.9.3 source tree
80 *********************************************************************/
87 #include <sys/types.h>
99 #include "killpopup.h"
102 const char killpopup_h_rcs[] = KILLPOPUP_H_VERSION;
104 #ifdef FEATURE_KILL_POPUPS
106 /*********************************************************************
108 * Function : filter_popups
110 * Description : Filter the block of data that's been read from the server.
111 * Caller is responsible for checking permissons list
112 * to determine if this function should be called.
113 * Remember not to change the content length (substitute char by char)
116 * 1 : buff = Buffer to scan and modify. Null terminated.
120 *********************************************************************/
121 void filter_popups(char *buff)
127 while ((popup = strstr( buff, "window.open(" )) != NULL)
132 * replace the window.open( with a harmless JavaScript replacement (notice the two single quotes)
133 * Guy's idea (thanks)
135 strncpy(popup, "1;''.concat(", 12);
136 log_error(LOG_LEVEL_POPUPS, "Blocked popup window open");
140 while ((popup = strstr( buff, ".resizeTo(" )) != NULL)
145 * replace the .resizeTo( with a harmless JavaScript replacement
146 * Guy's idea (thanks)
148 strncpy(popup, ".scrollTo(", 10);
149 log_error(LOG_LEVEL_POPUPS, "Blocked popup window resize");
153 /* Filter onUnload and onExit */
154 popup=strstr( buff, "<body");
155 if (!popup) popup=strstr( buff, "<BODY");
156 if (!popup) popup=strstr( buff, "<Body");
157 if (!popup) popup=strstr( buff, "<BOdy");
160 close=strchr(popup,'>');
163 /* we are now between <body and the ending > FIXME: No, we're anywhere! --oes */
164 p=strstr(popup, "onUnload");
169 p=strstr(popup, "onExit");
179 #endif /* def FEATURE_KILL_POPUPS */