1 # ===================================================================== 2 # deleteAttachment.awk: RPC I/O function for rpclib/deleteAttachment. 3 # 4 # Copyright (c) 2007-2011 Carlo Strozzi 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; version 2 dated June, 1991. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 # 19 # ===================================================================== 20 21 # ===================================================================== 22 # void _userproc(int mode) 23 # ===================================================================== 24 25 function _userproc(mode, value) { 26 27 if (mode == _O_REQUEST) { # request. 28 29 # target group. 30 value = substr(_request("1",1),1,ENVIRON["TNS_GROUP_MAXLEN"]) 31 32 # group must not be null and it may not contain the 33 # unescaped ``.'' character. 34 35 if (value != _NULL && value !~ /\./) { 36 _rcset("cgi.group",unixify(value)) 37 _rcset("cgi.group.literal",value) 38 } 39 40 # target page within group (only used for private attachments). 41 value = substr(_request("2",1),1,ENVIRON["TNS_PAGE_MAXLEN"]) 42 43 # page name must be at least 2-character long. 44 if (length(value) > 1) { 45 gsub(/[ \t\n\r]/," ",value) # neutralize real junk. 46 _rcset("cgi.page.literal",value) 47 value = unixify(value,1) 48 _rcset("cgi.page",value) 49 } 50 51 # Attachment file name. 52 value = _request("3",1) 53 _rcset("cgi.attname.literal",value) 54 55 # This is for compatibility with old page-level 56 # public attachments. 57 gsub(/ /,"+",value) 58 59 # Filename checks need to be relaxed for strongly non-latin 60 # alphabets. 61 #if (value ~ /^[a-zA-Z0-9]+[-_+.a-zA-Z0-9]+[a-zA-Z]$/) { 62 if (value ~ /^[^-\/]+[^\/]+[a-zA-Z]$/) { 63 64 _rcset("cgi.attname",value) 65 66 # Attachment file name, escaped for sed(1)/grep(1). 67 gsub(/\./,"\\.",value) 68 _rcset("cgi.attname.esc",value) 69 } 70 71 # where to delete this file from. 72 # 73 # web: stuff in the public Web area 74 # wiki: stuff in the private Wiki area 75 76 value = _request("4",1) 77 78 # add more types as needed. 79 if (value ~ /^(web|wiki)$/) _rcset("cgi.where",value) 80 81 # The following test is necessary since the address could, 82 # at least in theory, have been set to any string by the 83 # remote user, due to how it is handled to cope with stunnel(8) 84 # and the lack of transproxy support in kernel 2.4.x. 85 86 if (_isipaddr(ENVIRON["REMOTE_ADDR"]) == _TRUE) 87 value = ENVIRON["REMOTE_ADDR"] 88 else value = "0.0.0.0" 89 90 _rcset("REMOTE_ADDR",value) 91 } 92 } 93 94 # EOF