1 const char killpopup_rcs[] = "$Id: killpopup.c,v 1.3 2001/05/22 18:56:28 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.3 2001/05/22 18:56:28 oes
38 * Revision 1.2 2001/05/20 01:21:20 jongfoster
39 * Version 2.9.4 checkin.
40 * - Merged popupfile and cookiefile, and added control over PCRS
41 * filtering, in new "permissionsfile".
42 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
43 * file error you now get a message box (in the Win32 GUI) rather
44 * than the program exiting with no explanation.
45 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
47 * - Removed tabs from "config"
48 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
49 * - Bumped up version number.
51 * Revision 1.1.1.1 2001/05/15 13:58:58 oes
52 * Initial import of version 2.9.3 source tree
55 *********************************************************************/
62 #include <sys/types.h>
74 #include "killpopup.h"
77 const char killpopup_h_rcs[] = KILLPOPUP_H_VERSION;
81 /* Change these for debug output. *lots*. */
82 /*#define POPUP_VERBOSE 1*/
86 /*********************************************************************
88 * Function : filter_popups
90 * Description : Filter the block of data that's been read from the server.
91 * Caller is responsible for checking permissons list
92 * to determine if this function should be called.
95 * 1 : buff = Buffer to scan and modify. Null terminated.
96 * 2 : size = Buffer size, excluding null terminator.
100 *********************************************************************/
101 void filter_popups(char *buff, int size)
107 while ((popup = strstr( buff, "window.open(" )) != NULL)
110 fprintf(logfp, "Found start of window open" );
112 close = strstr( popup+1, ");" );
116 fprintf(logfp, "Found end of window open" );
120 for ( ; p != (close+1); p++ )
125 fprintf(logfp, "Blocked %s\n", host_name );
131 fprintf(logfp, "Couldn't find end, turned into comment. Read boundary?\n" );
138 * result of popup is assigned to variable and the rest commented out
140 * will be translated to
143 * myWindow = window.open(blah
144 * will be translated to
145 * myWindow = 1;//ow.open(blah
150 /* Filter all other crap like onUnload onExit etc. (by BREITENB) NEW!*/
151 popup=strstr( buff, "<body");
152 if (!popup) popup=strstr( buff, "<BODY");
153 if (!popup) popup=strstr( buff, "<Body");
154 if (!popup) popup=strstr( buff, "<BOdy");
157 close=strchr(popup,'>');
160 /* we are now between <body and the ending > FIXME: No, we're anywhere! --oes*/
161 p=strstr(popup, "onUnload");
166 p=strstr(popup, "onExit");
176 #endif /* def KILLPOPUPS */