chtml50_t *chtml50;
Doc *doc;
request_rec *r;
+ char *attr_align = NULL;
+ char *attr_size = NULL;
+ char *attr_width = NULL;
+ char *attr_noshade = NULL;
+ char *attr_style = NULL;
+ char *attr_color = NULL;
+
+ chtml50 = GET_CHTML50(pdoc);
+ doc = chtml50->doc;
+ r = doc->r;
+
+ 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);
+ switch(*name) {
+ case 'a':
+ case 'A':
+ if (strcasecmp(name, "align") == 0) {
+ /*--------------------------------------------------------------------*/
+ /* CHTML 1.0 */
+ /*--------------------------------------------------------------------*/
+ if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+ attr_align = value;
+ }
+ }
+ break;
+
+ case 's':
+ case 'S':
+ if (strcasecmp(name, "size") == 0) {
+ /*--------------------------------------------------------------------*/
+ /* CHTML 1.0 */
+ /*--------------------------------------------------------------------*/
+ if (value && *value) {
+ attr_size = value;
+ }
+ }
+ else if (strcasecmp(name, "style") == 0) {
+ if (value && *value) {
+ attr_style = value;
+ }
+ }
+ break;
+
+ case 'w':
+ case 'W':
+ if (strcasecmp(name, "width") == 0) {
+ /*--------------------------------------------------------------------*/
+ /* CHTML 1.0 */
+ /*--------------------------------------------------------------------*/
+ if (value && *value) {
+ attr_width = value;
+ }
+ }
+ break;
+
+ case 'n':
+ case 'N':
+ if (strcasecmp(name, "noshade") == 0) {
+ /*--------------------------------------------------------------------*/
+ /* CHTML 1.0 */
+ /*--------------------------------------------------------------------*/
+ attr_noshade = apr_pstrdup(doc->pool, "noshade");
+ }
+ break;
+
+ case 'c':
+ case 'C':
+ if (strcasecmp(name, "color") == 0 && value && *value) {
+ /*--------------------------------------------------------------------*/
+ /* CHTML 4.0 */
+ /*--------------------------------------------------------------------*/
+ attr_color = value;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ if (IS_CSS_ON(chtml50->entryp)) {
+ css_prop_list_t *style = s_chtml50_nopush_and_get_now_style(pdoc, node, attr_style);
+ if (style) {
+ css_property_t *border_style_prop = chxj_css_get_property_value(doc, style, "border-style");
+ css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
+ css_property_t *width_prop = chxj_css_get_property_value(doc, style, "width");
+ css_property_t *cur;
+ for (cur = border_style_prop->next; cur != border_style_prop; cur = cur->next) {
+ if (STRCASEEQ('s','S',"solid",cur->value)) {
+ attr_noshade = "noshade";
+ }
+ }
+ for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
+ char *tmp = apr_pstrdup(doc->pool, cur->value);
+ char *tmpp = strstr(tmp, "px");
+ if (tmpp) {
+ *tmpp = 0;
+ attr_size = apr_pstrdup(doc->pool, tmp);
+ }
+ }
+ for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
+ char *tmp = apr_pstrdup(doc->pool, cur->value);
+ char *tmpp = strstr(tmp, "px");
+ if (tmpp) {
+ *tmpp = 0;
+ attr_width = apr_pstrdup(doc->pool, tmp);
+ }
+ else {
+ tmpp = strstr(tmp, "%");
+ if (tmpp) {
+ attr_width = apr_pstrdup(doc->pool, tmp);
+ }
+ }
+ }
+ }
+ }
+ W_L("<hr");
+ if (attr_align) {
+ W_L(" align=\"");
+ W_V(attr_align);
+ W_L("\"");
+ }
+ if (attr_size) {
+ W_L(" size=\"");
+ W_V(attr_size);
+ W_L("\"");
+ }
+ if (attr_width) {
+ W_L(" width=\"");
+ W_V(attr_width);
+ W_L("\"");
+ }
+ if (attr_color) {
+ W_L(" color=\"");
+ W_V(attr_color);
+ W_L("\"");
+ }
+ if (attr_noshade) {
+ W_L(" noshade");
+ }
+ W_L(">");
+ return chtml50->out;
+
+#if 0
+ Attr *attr;
+ chtml50_t *chtml50;
+ Doc *doc;
+ request_rec *r;
chtml50 = GET_CHTML50(pdoc);
doc = chtml50->doc;
}
}
W_L(">");
+#endif
return chtml50->out;
}
void test_chtml50_center_tag_with_css_014();
void test_chtml50_center_tag_with_css_015();
void test_chtml50_center_tag_with_css_016();
+
+void test_chtml50_hr_tag_with_css_001();
+void test_chtml50_hr_tag_with_css_002();
+void test_chtml50_hr_tag_with_css_003();
+void test_chtml50_hr_tag_with_css_004();
+void test_chtml50_hr_tag_with_css_005();
+void test_chtml50_hr_tag_with_css_006();
+void test_chtml50_hr_tag_with_css_007();
+void test_chtml50_hr_tag_with_css_008();
/* pend */
int
CU_add_test(chtml50_suite, "test center with css 014", test_chtml50_center_tag_with_css_014);
CU_add_test(chtml50_suite, "test center with css 015", test_chtml50_center_tag_with_css_015);
CU_add_test(chtml50_suite, "test center with css 016", test_chtml50_center_tag_with_css_016);
+
+ CU_add_test(chtml50_suite, "test hr with css 001", test_chtml50_hr_tag_with_css_001);
+ CU_add_test(chtml50_suite, "test hr with css 002", test_chtml50_hr_tag_with_css_002);
+ CU_add_test(chtml50_suite, "test hr with css 003", test_chtml50_hr_tag_with_css_003);
+ CU_add_test(chtml50_suite, "test hr with css 004", test_chtml50_hr_tag_with_css_004);
+ CU_add_test(chtml50_suite, "test hr with css 005", test_chtml50_hr_tag_with_css_005);
+ CU_add_test(chtml50_suite, "test hr with css 006", test_chtml50_hr_tag_with_css_006);
+ CU_add_test(chtml50_suite, "test hr with css 007", test_chtml50_hr_tag_with_css_007);
+ CU_add_test(chtml50_suite, "test hr with css 008", test_chtml50_hr_tag_with_css_008);
/* aend */
CU_basic_run_tests();
#undef TEST_STRING
#undef RESULT_STRING
}
+
+
+/*===========================================================================*/
+/* hr tag with CSS */
+/*===========================================================================*/
+char *test_chxj_serf_get100(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"
+ "a:visited { display:none }\n"
+ "hr { border-style:solid }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_chtml50_hr_tag_with_css_001()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><body><hr>あいう</body></html>"
+#define RESULT_STRING "<html><head></head><body><hr noshade>あいう</body></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_get100;
+ 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);
+ 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_hr_tag_with_css_002()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><body><hr style=\"border-style:solid\">あいう</body></html>"
+#define RESULT_STRING "<html><head></head><body><hr noshade>あいう</body></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_get100;
+ 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);
+ 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_get101(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"
+ "a:visited { display:none }\n"
+ "hr { height:10px }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_chtml50_hr_tag_with_css_003()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><body><hr>あいう</body></html>"
+#define RESULT_STRING "<html><head></head><body><hr size=\"10\">あいう</body></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_get101;
+ 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);
+ 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_hr_tag_with_css_004()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><body><hr style=\"height:10px\">あいう</body></html>"
+#define RESULT_STRING "<html><head></head><body><hr size=\"10\">あいう</body></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_get101;
+ 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);
+ 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_get102(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"
+ "a:visited { display:none }\n"
+ "hr { width:10px }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_chtml50_hr_tag_with_css_005()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><body><hr>あいう</body></html>"
+#define RESULT_STRING "<html><head></head><body><hr width=\"10\">あいう</body></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_get102;
+ 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);
+ 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_hr_tag_with_css_006()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><body><hr style=\"width:10px\">あいう</body></html>"
+#define RESULT_STRING "<html><head></head><body><hr width=\"10\">あいう</body></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_get102;
+ 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);
+ 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_get103(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"
+ "a:visited { display:none }\n"
+ "hr { width:80% }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_chtml50_hr_tag_with_css_007()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><body><hr>あいう</body></html>"
+#define RESULT_STRING "<html><head></head><body><hr width=\"80%\">あいう</body></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_get103;
+ 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);
+ 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_hr_tag_with_css_008()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><body><hr style=\"width:10%\">あいう</body></html>"
+#define RESULT_STRING "<html><head></head><body><hr width=\"10%\">あいう</body></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_get103;
+ 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);
+ 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
*/