static char *
s_chtml50_start_form_tag(void *pdoc, Node *node)
{
- chtml50_t *chtml50;
- Doc *doc;
- request_rec *r;
- Attr *attr;
+ chtml50_t *chtml50;
+ Doc *doc;
+ request_rec *r;
+ Attr *attr;
+ char *attr_action = NULL;
+ char *attr_method = NULL;
+ char *attr_style = NULL;
+ char *attr_color = NULL;
+ char *attr_align = NULL;
+ char *attr_utn = NULL;
chtml50 = GET_CHTML50(pdoc);
doc = chtml50->doc;
r = doc->r;
- W_L("<form");
/*--------------------------------------------------------------------------*/
/* Get Attributes */
/*--------------------------------------------------------------------------*/
attr = qs_get_next_attr(doc,attr)) {
char *name = qs_get_attr_name(doc,attr);
char *value = qs_get_attr_value(doc,attr);
- if (STRCASEEQ('a','A',"action", name)) {
- /*----------------------------------------------------------------------*/
- /* CHTML 1.0 */
- /*----------------------------------------------------------------------*/
- value = chxj_encoding_parameter(r, value);
- value = chxj_add_cookie_parameter(r, value, chtml50->cookie);
- W_L(" action=\"");
- W_V(value);
- W_L("\"");
- }
- else if (STRCASEEQ('m','M',"method", name)) {
- /*----------------------------------------------------------------------*/
- /* CHTML 1.0 */
- /*----------------------------------------------------------------------*/
- W_L(" method=\"");
- W_V(value);
- W_L("\"");
+ switch(*name) {
+ case 'a':
+ case 'A':
+ if (strcasecmp(name, "action") == 0) {
+ /*--------------------------------------------------------------------*/
+ /* CHTML 1.0 */
+ /*--------------------------------------------------------------------*/
+ attr_action = value;
+ }
+ break;
+
+ case 'm':
+ case 'M':
+ if (strcasecmp(name, "method") == 0) {
+ /*--------------------------------------------------------------------*/
+ /* CHTML 1.0 */
+ /*--------------------------------------------------------------------*/
+ attr_method = value;
+ }
+ break;
+
+ case 'u':
+ case 'U':
+ if (strcasecmp(name, "utn") == 0) {
+ /*--------------------------------------------------------------------*/
+ /* CHTML 3.0 */
+ /*--------------------------------------------------------------------*/
+ attr_utn = value;
+ }
+ break;
+
+ case 's':
+ case 'S':
+ if (strcasecmp(name, "style") == 0) {
+ attr_style = value;
+ }
+ break;
+
+ default:
+ break;
}
- else if (STRCASEEQ('u','U',"utn", name)) {
- /*----------------------------------------------------------------------*/
- /* CHTML 3.0 */
- /* It is special only for CHTML. */
- /*----------------------------------------------------------------------*/
- W_L(" utn");
+ }
+ if (IS_CSS_ON(chtml50->entryp)) {
+ css_prop_list_t *style = s_chtml50_push_and_get_now_style(pdoc, node, attr_style);
+ if (style) {
+ css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
+ css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
+ css_property_t *cur;
+ for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
+ if (STRCASEEQ('l','L',"left", cur->value)) {
+ attr_align = apr_pstrdup(doc->pool, "left");
+ }
+ else if (STRCASEEQ('c','C',"center",cur->value)) {
+ attr_align = apr_pstrdup(doc->pool, "center");
+ }
+ else if (STRCASEEQ('r','R',"right",cur->value)) {
+ attr_align = apr_pstrdup(doc->pool, "right");
+ }
+ }
+ for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
+ attr_color = apr_pstrdup(doc->pool, cur->value);
+ }
}
}
+ W_L("<form");
+ if (attr_action) {
+ attr_action = chxj_encoding_parameter(r, attr_action);
+ attr_action = chxj_add_cookie_parameter(r, attr_action, chtml50->cookie);
+ W_L(" action=\"");
+ W_V(attr_action);
+ W_L("\"");
+ }
+ if (attr_method) {
+ W_L(" method=\"");
+ W_V(attr_method);
+ W_L("\"");
+ }
+ if (attr_utn) {
+ W_L(" utn");
+ }
W_L(">");
+
+ chtml50_flags_t *flg = (chtml50_flags_t *)apr_palloc(doc->pool, sizeof(chtml50_flags_t));
+ memset(flg, 0, sizeof(*flg));
+ if (attr_color) {
+ attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
+ W_L("<font color=\"");
+ W_V(attr_color);
+ W_L("\">");
+ flg->with_font_flag = 1;
+ }
+ if (attr_align) {
+ W_L("<div align=\"");
+ W_V(attr_align);
+ W_L("\">");
+ flg->with_div_flag = 1;
+ }
+ node->userData = flg;
+
return chtml50->out;
}
* @return The conversion result is returned.
*/
static char *
-s_chtml50_end_form_tag(void *pdoc, Node *UNUSED(child))
+s_chtml50_end_form_tag(void *pdoc, Node *node)
{
chtml50_t *chtml50;
Doc *doc;
chtml50 = GET_CHTML50(pdoc);
doc = chtml50->doc;
+ chtml50_flags_t *flg = (chtml50_flags_t *)node->userData;
+ if (flg && flg->with_div_flag) {
+ W_L("</div>");
+ }
+ if (flg && flg->with_font_flag) {
+ W_L("</font>");
+ }
W_L("</form>");
+ if (IS_CSS_ON(chtml50->entryp)) {
+ chxj_css_pop_prop_list(chtml50->css_prop_stack);
+ }
return chtml50->out;
}
void test_chtml50_font_tag_with_css_014();
void test_chtml50_font_tag_with_css_015();
void test_chtml50_font_tag_with_css_016();
+
+void test_chtml50_form_tag_with_css_001();
+void test_chtml50_form_tag_with_css_002();
+void test_chtml50_form_tag_with_css_003();
+void test_chtml50_form_tag_with_css_004();
+void test_chtml50_form_tag_with_css_005();
+void test_chtml50_form_tag_with_css_006();
+void test_chtml50_form_tag_with_css_007();
+void test_chtml50_form_tag_with_css_008();
/* pend */
int
CU_add_test(chtml50_suite, "test font with css 014", test_chtml50_font_tag_with_css_014);
CU_add_test(chtml50_suite, "test font with css 015", test_chtml50_font_tag_with_css_015);
CU_add_test(chtml50_suite, "test font with css 016", test_chtml50_font_tag_with_css_016);
+
+ CU_add_test(chtml50_suite, "test form with css 001", test_chtml50_form_tag_with_css_001);
+ CU_add_test(chtml50_suite, "test form with css 002", test_chtml50_form_tag_with_css_002);
+ CU_add_test(chtml50_suite, "test form with css 003", test_chtml50_form_tag_with_css_003);
+ CU_add_test(chtml50_suite, "test form with css 004", test_chtml50_form_tag_with_css_004);
+ CU_add_test(chtml50_suite, "test form with css 005", test_chtml50_form_tag_with_css_005);
+ CU_add_test(chtml50_suite, "test form with css 006", test_chtml50_form_tag_with_css_006);
+ CU_add_test(chtml50_suite, "test form with css 007", test_chtml50_form_tag_with_css_007);
+ CU_add_test(chtml50_suite, "test form with css 008", test_chtml50_form_tag_with_css_008);
/* aend */
CU_basic_run_tests();
void test_chtml50_form_tag_009()
{
#define TEST_STRING "<html><head></head><body><form method=\"post\" action=\"hogehoge\"></form></body></html>"
-#define RESULT_STRING "<html><head></head><body><form method=\"post\" action=\"hogehoge?_chxj_cc=test_cookie_id\"></form></body></html>"
+#define RESULT_STRING "<html><head></head><body><form action=\"hogehoge?_chxj_cc=test_cookie_id\" method=\"post\"></form></body></html>"
char *ret;
char *tmp;
device_table spec;
#undef TEST_STRING
#undef RESULT_STRING
}
+
+
+
+/*===========================================================================*/
+/* form tag with CSS */
+/*===========================================================================*/
+char *test_chxj_serf_get073(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len)
+{
+ static char *css = "a:focus { display: none }\n"
+ "a:link { display: none }\n"
+ "a { display: none }\n"
+ "hr { display: none }\n"
+ "form { color:#ff0000 }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_chtml50_form_tag_with_css_001()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><form>あいう</form></html>"
+#define RESULT_STRING "<html><head></head><form><font color=\"#ff0000\">あいう</font></form></html>"
+ char *ret;
+ char *tmp;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get073;
+ call_check = 0;
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ destlen = sizeof(TEST_STRING)-1;
+ entry.action |= CONVRULE_CSS_ON_BIT;
+
+ tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+ ret = chxj_rencoding(&r, ret, &destlen);
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+ CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+ CU_ASSERT(call_check == 1);
+
+ APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml50_form_tag_with_css_002()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><form style=\"color:#ff0000\">あいう</form></html>"
+#define RESULT_STRING "<html><head></head><form><font color=\"#ff0000\">あいう</font></form></html>"
+ char *ret;
+ char *tmp;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get073;
+ call_check = 0;
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ destlen = sizeof(TEST_STRING)-1;
+ entry.action |= CONVRULE_CSS_ON_BIT;
+
+ tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+ ret = chxj_rencoding(&r, ret, &destlen);
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+ CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+ CU_ASSERT(call_check == 0);
+
+ APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+
+char *test_chxj_serf_get074(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len)
+{
+ static char *css = "a:focus { display: none }\n"
+ "a:link { display: none }\n"
+ "a { display: none }\n"
+ "hr { display: none }\n"
+ "form { text-align:left }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_chtml50_form_tag_with_css_003()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><form>あいう</form></html>"
+#define RESULT_STRING "<html><head></head><form><div align=\"left\">あいう</div></form></html>"
+ char *ret;
+ char *tmp;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get074;
+ call_check = 0;
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ destlen = sizeof(TEST_STRING)-1;
+ entry.action |= CONVRULE_CSS_ON_BIT;
+
+ tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+ ret = chxj_rencoding(&r, ret, &destlen);
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+ CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+ CU_ASSERT(call_check == 1);
+
+ APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml50_form_tag_with_css_004()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><form style=\"text-align:left\">あいう</form></html>"
+#define RESULT_STRING "<html><head></head><form><div align=\"left\">あいう</div></form></html>"
+ char *ret;
+ char *tmp;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get074;
+ call_check = 0;
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ destlen = sizeof(TEST_STRING)-1;
+ entry.action |= CONVRULE_CSS_ON_BIT;
+
+ tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+ ret = chxj_rencoding(&r, ret, &destlen);
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+ CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+ CU_ASSERT(call_check == 0);
+
+ APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+
+char *test_chxj_serf_get075(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len)
+{
+ static char *css = "a:focus { display: none }\n"
+ "a:link { display: none }\n"
+ "a { display: none }\n"
+ "hr { display: none }\n"
+ "form { text-align:center }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_chtml50_form_tag_with_css_005()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><form>あいう</form></html>"
+#define RESULT_STRING "<html><head></head><form><div align=\"center\">あいう</div></form></html>"
+ char *ret;
+ char *tmp;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get075;
+ call_check = 0;
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ destlen = sizeof(TEST_STRING)-1;
+ entry.action |= CONVRULE_CSS_ON_BIT;
+
+ tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+ ret = chxj_rencoding(&r, ret, &destlen);
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+ CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+ CU_ASSERT(call_check == 1);
+
+ APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml50_form_tag_with_css_006()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><form style=\"text-align:center\">あいう</form></html>"
+#define RESULT_STRING "<html><head></head><form><div align=\"center\">あいう</div></form></html>"
+ char *ret;
+ char *tmp;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get075;
+ call_check = 0;
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ destlen = sizeof(TEST_STRING)-1;
+ entry.action |= CONVRULE_CSS_ON_BIT;
+
+ tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+ ret = chxj_rencoding(&r, ret, &destlen);
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+ CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+ CU_ASSERT(call_check == 0);
+
+ APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+
+char *test_chxj_serf_get076(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len)
+{
+ static char *css = "a:focus { display: none }\n"
+ "a:link { display: none }\n"
+ "a { display: none }\n"
+ "hr { display: none }\n"
+ "form { text-align:right }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_chtml50_form_tag_with_css_007()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><form>あいう</form></html>"
+#define RESULT_STRING "<html><head></head><form><div align=\"right\">あいう</div></form></html>"
+ char *ret;
+ char *tmp;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get076;
+ call_check = 0;
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ destlen = sizeof(TEST_STRING)-1;
+ entry.action |= CONVRULE_CSS_ON_BIT;
+
+ tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+ ret = chxj_rencoding(&r, ret, &destlen);
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+ CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+ CU_ASSERT(call_check == 1);
+
+ APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml50_form_tag_with_css_008()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><form style=\"text-align:right\">あいう</form></html>"
+#define RESULT_STRING "<html><head></head><form><div align=\"right\">あいう</div></form></html>"
+ char *ret;
+ char *tmp;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get076;
+ call_check = 0;
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ destlen = sizeof(TEST_STRING)-1;
+ entry.action |= CONVRULE_CSS_ON_BIT;
+
+ tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+ ret = chxj_rencoding(&r, ret, &destlen);
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+ CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+ CU_ASSERT(call_check == 0);
+
+ APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+
+
/*
* vim:ts=2 et
*/