static char *
s_jhtml_start_input_tag(void *pdoc, Node *node)
{
- jhtml_t *jhtml;
- Doc *doc;
- request_rec *r;
- char *max_length;
- char *type;
- char *name;
- char *value;
- char *istyle;
- char *size;
- char *checked;
- char *accesskey;
-
- jhtml = GET_JHTML(pdoc);
- doc = jhtml->doc;
- r = doc->r;
- max_length = NULL;
- type = NULL;
- name = NULL;
- value = NULL;
- istyle = NULL;
- size = NULL;
- checked = NULL;
- accesskey = NULL;
+ jhtml_t *jhtml;
+ Doc *doc;
+ request_rec *r;
+ Attr *attr;
+ char *attr_accesskey = NULL;
+ char *attr_max_length = NULL;
+ char *attr_type = NULL;
+ char *attr_name = NULL;
+ char *attr_value = NULL;
+ char *attr_istyle = NULL;
+ char *attr_size = NULL;
+ char *attr_checked = NULL;
+ char *attr_style = NULL;
+
+ jhtml = GET_JHTML(pdoc);
+ doc = jhtml->doc;
+ r = doc->r;
- W_L("<input");
/*--------------------------------------------------------------------------*/
/* Get Attributes */
/*--------------------------------------------------------------------------*/
- type = qs_get_type_attr(doc, node, doc->buf.pool);
- name = qs_get_name_attr(doc, node, doc->buf.pool);
- value = qs_get_value_attr(doc,node,doc->buf.pool);
- istyle = qs_get_istyle_attr(doc,node,doc->buf.pool);
- max_length = qs_get_maxlength_attr(doc,node,doc->buf.pool);
- checked = qs_get_checked_attr(doc,node,doc->buf.pool);
- accesskey = qs_get_accesskey_attr(doc, node, doc->buf.pool);
- size = qs_get_size_attr(doc, node, doc->buf.pool);
-
- if (type) {
- if (type && (STRCASEEQ('t','T',"text", type) ||
- STRCASEEQ('p','P',"password",type) ||
- STRCASEEQ('c','C',"checkbox",type) ||
- STRCASEEQ('r','R',"radio", type) ||
- STRCASEEQ('h','H',"hidden", type) ||
- STRCASEEQ('s','S',"submit", type) ||
- STRCASEEQ('r','R',"reset", type))) {
- W_L(" type=\"");
- W_V(type);
- W_L("\"");
+ for (attr = qs_get_attr(doc,node);
+ attr;
+ 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('t','T',"type",name) && value && *value) {
+ char *tmp_type = qs_trim_string(doc->buf.pool, value);
+ if (tmp_type && (STRCASEEQ('t','T',"text", tmp_type) ||
+ STRCASEEQ('p','P',"password",tmp_type) ||
+ STRCASEEQ('c','C',"checkbox",tmp_type) ||
+ STRCASEEQ('r','R',"radio", tmp_type) ||
+ STRCASEEQ('h','H',"hidden", tmp_type) ||
+ STRCASEEQ('s','S',"submit", tmp_type) ||
+ STRCASEEQ('r','R',"reset", tmp_type))) {
+ attr_type = tmp_type;
+ }
+ }
+ else if (STRCASEEQ('n','N',"name",name) && value && *value) {
+ attr_name = value;
+ }
+ else if (STRCASEEQ('v','V',"value",name) && value && *value) {
+ attr_value = value;
+ }
+ else if (STRCASEEQ('i','I',"istyle",name) && value && *value) {
+ attr_istyle = value;
+ }
+ else if (STRCASEEQ('m','M',"maxlength",name) && value && *value) {
+ attr_max_length = value;
+ }
+ else if (STRCASEEQ('c','C',"checked", name)) {
+ attr_checked = value;
+ }
+ else if (STRCASEEQ('a','A',"accesskey", name) && value && *value) {
+ attr_accesskey = value;
+ }
+ else if (STRCASEEQ('s','S',"size", name) && value && *value) {
+ attr_size = value;
+ }
+ else if (STRCASEEQ('s','S',"style", name) && value && *value) {
+ attr_style = value;
}
}
- if (size && *size) {
+
+ if (IS_CSS_ON(jhtml->entryp)) {
+ css_prop_list_t *style = s_jhtml_nopush_and_get_now_style(pdoc, node, attr_style);
+ if (style) {
+ css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
+ css_property_t *cur;
+ for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
+ if (strcasestr(cur->value, "<ja:n>")) {
+ attr_istyle = "4";
+ }
+ else if (strcasestr(cur->value, "<ja:en>")) {
+ attr_istyle = "3";
+ }
+ else if (strcasestr(cur->value, "<ja:hk>")) {
+ attr_istyle = "2";
+ }
+ else if (strcasestr(cur->value, "<ja:h>")) {
+ attr_istyle = "1";
+ }
+ }
+ }
+ }
+
+ W_L("<input");
+ if (attr_type) {
+ W_L(" type=\"");
+ W_V(attr_type);
+ W_L("\"");
+ }
+ if (attr_size) {
W_L(" size=\"");
- W_V(size);
+ W_V(attr_size);
W_L("\"");
}
- if (name && *name) {
+ if (attr_name) {
W_L(" name=\"");
- W_V(name);
+ W_V(attr_name);
W_L("\"");
}
- if (value && *value) {
+ if (attr_value) {
W_L(" value=\"");
- W_V(chxj_add_slash_to_doublequote(doc->pool, value));
+ W_V(chxj_add_slash_to_doublequote(doc->pool, attr_value));
W_L("\"");
}
- if (accesskey && *accesskey) {
+ if (attr_accesskey) {
W_L(" accesskey=\"");
- W_V(accesskey);
+ W_V(attr_accesskey);
W_L("\"");
}
- if (istyle && (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4')) {
+ if (attr_istyle && (*attr_istyle == '1' || *attr_istyle == '2' || *attr_istyle == '3' || *attr_istyle == '4')) {
/*------------------------------------------------------------------------*/
/* CHTML 2.0 */
/*------------------------------------------------------------------------*/
- if (type && STRCASEEQ('p','P',"password", type) && ! jhtml->entryp->pc_flag ) {
+ if (attr_type && STRCASEEQ('p','P',"password", attr_type) && ! jhtml->entryp->pc_flag ) {
W_L(" mode=\"");
W_L("numeric");
W_L("\"");
}
else {
- char *vv = chxj_istyle_to_mode(doc->buf.pool,istyle);
+ char *vv = chxj_istyle_to_mode(doc->buf.pool,attr_istyle);
W_L(" mode=\"");
W_V(vv);
W_L("\"");
}
}
- else if (type && STRCASEEQ('p','P',"password",type)) {
+ else if (attr_type && STRCASEEQ('p','P',"password",attr_type)) {
W_L(" mode=\"");
W_L("numeric");
W_L("\"");
/*--------------------------------------------------------------------------*/
/* The figure is default for the password. */
/*--------------------------------------------------------------------------*/
- if (max_length && *max_length) {
- if (chxj_chk_numeric(max_length) == 0) {
+ if (attr_max_length && *attr_max_length) {
+ if (chxj_chk_numeric(attr_max_length) == 0) {
W_L(" maxlength=\"");
- W_V(max_length);
+ W_V(attr_max_length);
W_L("\"");
}
}
-
- if (checked) {
+ if (attr_checked) {
W_L(" checked");
}
W_L(">");
+
return jhtml->out;
}
void test_jhtml_form_tag_with_css_006();
void test_jhtml_form_tag_with_css_007();
void test_jhtml_form_tag_with_css_008();
+
+void test_jhtml_input_tag_with_css_001();
+void test_jhtml_input_tag_with_css_002();
+void test_jhtml_input_tag_with_css_003();
+void test_jhtml_input_tag_with_css_004();
+void test_jhtml_input_tag_with_css_005();
+void test_jhtml_input_tag_with_css_006();
+void test_jhtml_input_tag_with_css_007();
+void test_jhtml_input_tag_with_css_008();
/* pend */
int
CU_add_test(jhtml_suite, "test form with css 006", test_jhtml_form_tag_with_css_006);
CU_add_test(jhtml_suite, "test form with css 007", test_jhtml_form_tag_with_css_007);
CU_add_test(jhtml_suite, "test form with css 008", test_jhtml_form_tag_with_css_008);
+
+ CU_add_test(jhtml_suite, "test input with css 001", test_jhtml_input_tag_with_css_001);
+ CU_add_test(jhtml_suite, "test input with css 002", test_jhtml_input_tag_with_css_002);
+ CU_add_test(jhtml_suite, "test input with css 003", test_jhtml_input_tag_with_css_003);
+ CU_add_test(jhtml_suite, "test input with css 004", test_jhtml_input_tag_with_css_004);
+ CU_add_test(jhtml_suite, "test input with css 005", test_jhtml_input_tag_with_css_005);
+ CU_add_test(jhtml_suite, "test input with css 006", test_jhtml_input_tag_with_css_006);
+ CU_add_test(jhtml_suite, "test input with css 007", test_jhtml_input_tag_with_css_007);
+ CU_add_test(jhtml_suite, "test input with css 008", test_jhtml_input_tag_with_css_008);
/* aend */
CU_basic_run_tests();
#undef TEST_STRING
#undef RESULT_STRING
}
+
+
+
+/*===========================================================================*/
+/* input tag with CSS */
+/*===========================================================================*/
+char *test_chxj_serf_get080(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"
+ "input { -wap-input-format: "*<ja:h>" }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_jhtml_input_tag_with_css_001()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><form><input type=\"text\"></form></html>"
+#define RESULT_STRING "<html><head></head><form><input type='hidden' name='_chxj_cc' value='test_cookie_id'><input type=\"text\" mode=\"hiragana\"></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_get080;
+ 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_jhtml(&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_jhtml_input_tag_with_css_002()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><form><input type=\"text\" style=\"-wap-input-format: "*<ja:h>"\"></form></html>"
+#define RESULT_STRING "<html><head></head><form><input type='hidden' name='_chxj_cc' value='test_cookie_id'><input type=\"text\" mode=\"hiragana\"></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_get080;
+ 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_jhtml(&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_get081(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"
+ "input { -wap-input-format: "*<ja:hk>" }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_jhtml_input_tag_with_css_003()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><form><input type=\"text\"></form></html>"
+#define RESULT_STRING "<html><head></head><form><input type='hidden' name='_chxj_cc' value='test_cookie_id'><input type=\"text\" mode=\"hankakukana\"></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_get081;
+ 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_jhtml(&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_jhtml_input_tag_with_css_004()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><form><input type=\"text\" style=\"-wap-input-format: "*<ja:hk>"\"></form></html>"
+#define RESULT_STRING "<html><head></head><form><input type='hidden' name='_chxj_cc' value='test_cookie_id'><input type=\"text\" mode=\"hankakukana\"></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_get081;
+ 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_jhtml(&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_get082(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"
+ "input { -wap-input-format: "*<ja:en>" }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_jhtml_input_tag_with_css_005()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><form><input type=\"text\"></form></html>"
+#define RESULT_STRING "<html><head></head><form><input type='hidden' name='_chxj_cc' value='test_cookie_id'><input type=\"text\" mode=\"alphabet\"></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_get082;
+ 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_jhtml(&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_jhtml_input_tag_with_css_006()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><form><input type=\"text\" style=\"-wap-input-format: "*<ja:en>"\"></form></html>"
+#define RESULT_STRING "<html><head></head><form><input type='hidden' name='_chxj_cc' value='test_cookie_id'><input type=\"text\" mode=\"alphabet\"></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_get082;
+ 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_jhtml(&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_get083(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"
+ "input { -wap-input-format: "*<ja:n>"; }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_jhtml_input_tag_with_css_007()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><form><input type=\"text\"></form></html>"
+#define RESULT_STRING "<html><head></head><form><input type='hidden' name='_chxj_cc' value='test_cookie_id'><input type=\"text\" mode=\"numeric\"></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_get083;
+ 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_jhtml(&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_jhtml_input_tag_with_css_008()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><form><input type=\"text\" style=\"-wap-input-format: "*<ja:n>";\"></form></html>"
+#define RESULT_STRING "<html><head></head><form><input type='hidden' name='_chxj_cc' value='test_cookie_id'><input type=\"text\" mode=\"numeric\"></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_get083;
+ 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_jhtml(&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
*/