[ic] css.tag doesn't return any css content when file path is not writable

Justin Otten justin.lasotten at gmail.com
Wed Mar 24 02:36:00 UTC 2010


css.tag attempts to write a file out to the filesystem after reading
in the css via either variable or literal.
If the file path it attempts to write to is not writable, for whatever
reason, instead of creating a <link> tag
to the written file, it attempts to create a <style> tag containing the css.

The problem is, if it ever creates the style tag, it will never contain the css.
When the location is not writable, it skips the portion of code that
reads in the actual css, either from the literal option or the
contents of the variable.
The following patch moves the reading of the css up to a point where
it can't be skipped. Allowing both the link and style tags to be
created properly.


diff --git a/interchange/code/UserTag/css.tag b/interchange/code/UserTag/css.tag
index 1327baa..82db7c9 100644
--- a/interchange/code/UserTag/css.tag
+++ b/interchange/code/UserTag/css.tag
@@ -93,6 +93,11 @@ sub {
 	$extra .= qq{ media="$opt->{media}"} if $opt->{media};

 	my $css;
+	$css = length($opt->{literal})
+				? $opt->{literal}
+				: interpolate_html($Tag->var($name));
+	$css =~ s/^\s*<style.*?>\s*//si;
+	$css =~ s:\s*</style>\s*$:\n:i;

 	WRITE: {
 		last WRITE unless $write;
@@ -111,11 +116,6 @@ sub {
 			last WRITE;
 		}
 		my $mode = $opt->{mode} ? oct($opt->{mode}) : 0644;
-		$css = length($opt->{literal})
-					? $opt->{literal}
-					: interpolate_html($Tag->var($name));
-		$css =~ s/^\s*<style.*?>\s*//si;
-		$css =~ s:\s*</style>\s*$:\n:i;
 		$success = $Tag->write_relative_file($fn, $css) && chmod($mode, $fn)
 			or logError("Error writing CSS file %s, returning in page", $fn);
 	}



More information about the interchange-users mailing list