Blob Blame History Raw
From f6e442534448ece862a288216efd259cc53b9596 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Sat, 17 Oct 2009 14:06:51 +0200
Subject: [PATCH] Display Google correctly

Do not display a TEXTAREA which has STYLE attribute that matches
"display:.*none" even when we don't do CSS, so that Google looks nice.
---
 html.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/html.c b/html.c
index b0f5918..26f6e99 100644
--- a/html.c
+++ b/html.c
@@ -2143,7 +2143,7 @@ void html_textarea(unsigned char *a)
 static void do_html_textarea(unsigned char *attr, unsigned char *html, unsigned char *eof, unsigned char **end)
 {
 	struct form_control *fc;
-	unsigned char *p, *t_name, *w;
+	unsigned char *p, *t_name, *w, *style;
 	int t_namelen;
 	int cols, rows;
 	int i;
@@ -2172,6 +2172,16 @@ void do_html_textarea(unsigned char *attr, unsigned char *html, unsigned char *e
 	fc->type = FC_TEXTAREA;;
 	fc->ro = has_attr(attr, "disabled") ? 2 : has_attr(attr, "readonly") ? 1 : 0;
 	fc->default_value = memacpy(html, p - html);
+
+	/* Half-assed way to hide textareas that have display CSS property set to none,
+         * even as we don't do CSS, so that we display Google nicely */
+	style = get_attr_val(attr, "style");
+	if (style) style = (unsigned char *)strcasestr(style, "display");
+	if (style) style += strlen("display");
+	while (style && *style && isblank(*style)) style++;
+	if (style && *style == ':') do { ++style; } while (style && *style && isblank(*style));
+	if (style && style == (unsigned char *)strcasestr(style, "none")) goto hid;
+	
 	if ((cols = get_num(attr, "cols")) < HTML_MINIMAL_TEXTAREA_WIDTH) cols = HTML_DEFAULT_TEXTAREA_WIDTH;
 	cols++;
 	set_max_textarea_width(&cols);
@@ -2212,6 +2222,8 @@ void do_html_textarea(unsigned char *attr, unsigned char *html, unsigned char *e
 	kill_html_stack_item(&html_top);
 	if (rows > 1) ln_break(1);
 	else put_chrs(" ", 1);
+	hid:
+
 	special_f(ff, SP_CONTROL, fc);
 }
 
-- 
1.6.5.rc2