660 icalerror_check_arg_rz((parser != 0),
"parser");
663 parser->parse_errors++;
668 if (line_is_blank(line)) {
673 static const unsigned char is_icalctrl[256] = {
674 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1,
675 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
676 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
677 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
678 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
679 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
680 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
681 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
682 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
683 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
684 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
685 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
686 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
687 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
688 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
689 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
692 for (c = d = line; *c; c++) {
693 if (!is_icalctrl[(
unsigned char)*c]) {
698 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
702 "Content line contains invalid CONTROL characters",
705 parser->parse_errors++;
719 str = parser_get_prop_name(line, &end);
721 if (str == 0 || *str ==
'\0') {
723 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
728 "Got a data line, but could not find a property name or component begin tag",
731 parser->parse_errors++;
744 if (strcasecmp(str,
"BEGIN") == 0) {
745 icalcomponent *c = NULL;
750 if (parser->level > 100) {
751 icalerror_warn(
"Too many nesting levels");
755 str = parser_get_next_value(end, &end, value_kind);
774 insert_error(parser, c, str,
"Parse error in component name",
776 parser->parse_errors++;
779 icalpvl_push(parser->components, c);
787 }
else if (strcasecmp(str,
"END") == 0) {
792 str = parser_get_next_value(end, &end, value_kind);
795 parser->root_component = icalpvl_pop(parser->components);
797 tail = icalpvl_data(icalpvl_tail(parser->components));
806 if (parser->level < 0) {
808 icalerror_warn(
"Encountered END before BEGIN");
809 parser->parse_errors++;
813 }
else if (parser->level == 0) {
817 if (icalpvl_count(parser->components) != 0) {
820 icalpvl_push(parser->components, parser->root_component);
824 icalassert(icalpvl_count(parser->components) == 0);
827 rtrn = parser->root_component;
828 parser->root_component = 0;
840 if (icalpvl_data(icalpvl_tail(parser->components)) == 0) {
841 parser->parse_errors++;
866 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
881 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
883 insert_error(parser, tail, str,
"Parse error in property name",
886 parser->parse_errors++;
903 while ((pcount < maximum_allowed_parameters) && (parser->parse_errors < max_parse_failures)) {
904 if (*(end - 1) ==
':') {
912 str = parser_get_next_parameter(end, &end);
916 char *pvalue_heap = 0;
919 const char *name = name_stack;
920 const char *pvalue = pvalue_stack;
924 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
926 if (!parser_get_param_name_stack(str, name_stack,
sizeof(name_stack),
927 pvalue_stack,
sizeof(pvalue_stack))) {
928 name_heap = parser_get_param_name_heap(str, &pvalue_heap);
931 pvalue = pvalue_heap;
933 if (name_heap == 0) {
935 insert_error(parser, tail, str,
"Can't parse parameter name",
937 parser->parse_errors++;
980 insert_error(parser, tail, str,
"Can't parse parameter name",
982 parser->parse_errors++;
1009 insert_error(parser, tail, str,
"Can't parse parameter value",
1013 parser->parse_errors++;
1028 if (!icalproperty_value_kind_is_valid(prop_kind, value_kind)) {
1031 const char *err_str =
"Invalid VALUE type for property";
1033 size_t tmp_buf_len = strlen(err_str) + strlen(prop_str) + 2;
1035 snprintf(tmp_buf, tmp_buf_len,
"%s %s", err_str, prop_str);
1037 insert_error(parser, tail, str, tmp_buf,
1044 parser->parse_errors++;
1076 while ((vcount < maximum_property_values) && (parser->parse_errors < max_parse_failures)) {
1085 if (icalproperty_value_kind_is_multivalued(prop_kind, &value_kind)) {
1086 str = parser_get_next_value(end, &end, value_kind);
1088 str = icalparser_get_value(end, &end, value_kind);
1096 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
1109 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
1111 snprintf(temp,
sizeof(temp),
1112 "Can't parse as %s value in %s property. Removing entire property",
1121 parser->parse_errors++;
1148 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
1150 snprintf(temp,
sizeof(temp),
"No value for %s property. Removing entire property",
1158 parser->parse_errors++;
1167 if (parser->parse_errors == max_parse_failures) {
1176 if (icalpvl_data(icalpvl_tail(parser->components)) == 0 && parser->level == 0) {
1180 return parser->root_component;