Multiplay Labs

tech hits and tips from Multiplay

Archive for February 21st, 2009

Perl CGI.pm problems with query strings under Apache

without comments

Ever had a problem with query strings causing strange behaviour in apache when using the CGI module?
If you have the patch below might just save you some time and effort hunting down the problem.

--- CGI.pm.orig	Sat Mar  1 16:58:19 2008
+++ CGI.pm	Sat Mar  1 18:39:21 2008
@@ -2779,5 +2779,10 @@
    my $raw_script_name = $ENV{SCRIPT_NAME} || '';
    my $raw_path_info   = $ENV{PATH_INFO}   || '';
-   my $uri             = unescape($self->request_uri) || '';
+   my $uri             = $self->request_uri || '';
+
+   # ensure we dont get any query string as that can include escaped //
+   # e.g. a url parameter, which will break the apache bug fix
+   $uri =~ s/\?(.*)$//; 
+   $uri = unescape($uri);
 
    my $protected    = quotemeta($raw_path_info);

Written by Dilbert

February 21st, 2009 at 11:45 pm

Posted in Code,Hackery,Perl

Tagged with , , ,

Running perl scripts from rc.d under FreeBSD

without comments

If you have even tried to run a perl script under FreeBSD’s startup system rc.d then you’ll have hit upon a little problem where it doesnt correctly recognise the running process on shutdown. There’s a simple fix for this just apply the patch below and you’ll be good to go.

--- /etc/rc.subr.orig	Mon Oct  8 18:31:34 2007
+++ /etc/rc.subr	Mon Oct  8 18:32:31 2007
@@ -271,5 +271,5 @@
 		_fp_args='_argv'
 		_fp_match='case "$_argv" in
-		    ${_interp}|"${_interp} "*|"${_interpbn}: ${_procname}"*)'
+		    ${_interp}|"${_interp} "*|"[${_interpbn}]"|"${_interpbn}: ${_procname}"*)'
 	else					# a normal daemon
 		_procnamebn=${_procname##*/}

Written by Dilbert

February 21st, 2009 at 11:40 pm

Posted in Hackery,Perl

Tagged with , , ,

Halflife patches break query protocol

without comments

Always on of those things you love to get you install an update and it breaks things. Anyway some of the recent updates to valves old none source games updated to use the new a2s query, all good but this implementation doesn’t properly support the handshake in the challenge response. More specifically the server never responds to the request for a challenge.

In order to fix this in qstat I’ve had to make it do a bogus request which makes the server send a challenge and hence allows the handshake to complete correctly.

Anyone who uses qstat should update to the latest version in svn.

Written by Dilbert

February 21st, 2009 at 11:36 pm

Posted in Hackery

Tagged with , , , ,

YUI Treeview editComplete event

without comments

While using YUI‘s excellent little treeview library I needed the ability to hook into the completion of the edit node event. This isnt present in 2.6.0 so came up with this little patch to add it:

Index: docs/yui/treeview/treeview.js
===================================================================
--- docs/yui/treeview/treeview.js	(revision 214)
+++ docs/yui/treeview/treeview.js	(working copy)
@@ -306,6 +306,15 @@
         this.createEvent("enterKeyPressed", this);
 
     /**
+         * Fires when the edit of a node is complete
+         * @event editComplete
+         * @type CustomEvent
+         * @param {YAHOO.widget.Node} node the node that has the focus
+         * @param {Boolean} true if the editor saved, false otherwise
+         */
+        this.createEvent("editComplete", this);
+
+    /**
          * Fires when the label in a TextNode or MenuNode or content in an HTMLNode receives a Click.
 	* The listener may return false to cancel toggling and focusing on the node.
          * @event clickEvent
@@ -3052,9 +3061,11 @@
 		if (save) {
 			ed.node.saveEditorValue(ed);
 		}
+
 		Dom.setStyle(ed.editorPanel,'display','none');
 		ed.active = false;
 		node.focus();
+		this.fireEvent( 'editComplete', node, save );
 	};
 
 	/**

Written by Dilbert

February 21st, 2009 at 11:35 pm

Posted in Hackery

Tagged with , , ,