657 icalproperty_kind prop_kind;
659 icalvalue_kind value_kind = ICAL_NO_VALUE;
661 icalerror_check_arg_rz((parser != 0),
"parser");
668 if (line_is_blank(line) == 1) {
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",
703 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
718 str = parser_get_prop_name(line, &end);
720 if (str == 0 || *str ==
'\0') {
722 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
727 "Got a data line, but could not find a property name or component begin tag",
728 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
742 if (strcasecmp(str,
"BEGIN") == 0) {
743 icalcomponent *c = NULL;
748 str = parser_get_next_value(end, &end, value_kind);
767 insert_error(parser, c, str,
"Parse error in component name",
768 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
771 icalpvl_push(parser->components, c);
779 }
else if (strcasecmp(str,
"END") == 0) {
784 str = parser_get_next_value(end, &end, value_kind);
787 parser->root_component = icalpvl_pop(parser->components);
789 tail = icalpvl_data(icalpvl_tail(parser->components));
798 if (parser->level < 0) {
800 icalerror_warn(
"Encountered END before BEGIN");
804 }
else if (parser->level == 0) {
808 if (icalpvl_count(parser->components) != 0) {
811 icalpvl_push(parser->components, parser->root_component);
815 icalassert(icalpvl_count(parser->components) == 0);
818 rtrn = parser->root_component;
819 parser->root_component = 0;
831 if (icalpvl_data(icalpvl_tail(parser->components)) == 0) {
848 if (prop_kind == ICAL_IANA_PROPERTY &&
850 prop_kind = ICAL_NO_PROPERTY;
856 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
858 if (prop_kind == ICAL_X_PROPERTY) {
860 }
else if (prop_kind == ICAL_IANA_PROPERTY) {
871 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
873 insert_error(parser, tail, str,
"Parse error in property name",
874 ICAL_XLICERRORTYPE_PROPERTYPARSEERROR);
891 while (pcount < maximum_allowed_parameters) {
892 if (*(end - 1) ==
':') {
900 str = parser_get_next_parameter(end, &end);
904 char *pvalue_heap = 0;
905 char name_stack[TMP_BUF_SIZE];
906 char pvalue_stack[TMP_BUF_SIZE];
907 char *name = name_stack;
908 char *pvalue = pvalue_stack;
910 icalparameter *param = 0;
911 icalparameter_kind kind;
912 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
914 if (!parser_get_param_name_stack(str, name_stack,
sizeof(name_stack),
915 pvalue_stack,
sizeof(pvalue_stack))) {
916 name_heap = parser_get_param_name_heap(str, &pvalue_heap);
919 pvalue = pvalue_heap;
921 if (name_heap == 0) {
923 insert_error(parser, tail, str,
"Can't parse parameter name",
924 ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR);
931 if (kind == ICAL_X_PARAMETER) {
937 }
else if (kind == ICAL_IANA_PARAMETER) {
956 }
else if (kind == ICAL_TZID_PARAMETER && *(end - 1) !=
';') {
970 char *nextColon = end;
971 char *nextSemicolon = parser_get_next_char(
';', end, 1);
975 nextColon = parser_get_next_char(
':', nextColon, 1);
978 lastColon = nextColon;
982 if (lastColon && nextSemicolon && nextSemicolon < lastColon) {
989 lastColon = nextSemicolon;
997 if (lastColon && *(lastColon + 1) != 0) {
998 const char *strStart = line + strlen(name) + 2;
1000 end = lastColon + 1;
1003 str = make_segment(strStart, end - 1);
1007 if (!parser_get_param_name_stack(str, name_stack,
sizeof(name_stack),
1008 pvalue_stack,
sizeof(pvalue_stack))) {
1014 name_heap = parser_get_param_name_heap(str, &pvalue_heap);
1015 pvalue = pvalue_heap;
1018 }
else if (kind != ICAL_NO_PARAMETER) {
1027 insert_error(parser, tail, str,
"Can't parse parameter name",
1028 ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR);
1055 insert_error(parser, tail, str,
"Can't parse parameter value",
1056 ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR);
1071 icalparameter_get_value(param));
1073 if (!icalproperty_value_kind_is_valid(prop_kind, value_kind)) {
1076 const char *err_str =
"Invalid VALUE type for property";
1078 size_t tmp_buf_len = strlen(err_str) + strlen(prop_str) + 2;
1080 snprintf(tmp_buf, tmp_buf_len,
"%s %s", err_str, prop_str);
1082 insert_error(parser, tail, str, tmp_buf,
1083 ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR);
1121 while (vcount < maximum_property_values) {
1130 if (icalproperty_value_kind_is_multivalued(prop_kind, &value_kind)) {
1131 str = parser_get_next_value(end, &end, value_kind);
1133 str = icalparser_get_value(end, &end, value_kind);
1141 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
1154 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
1156 snprintf(temp,
sizeof(temp),
1157 "Can't parse as %s value in %s property. Removing entire property",
1161 insert_error(parser, tail, str, temp, ICAL_XLICERRORTYPE_VALUEPARSEERROR);
1192 icalcomponent *tail = icalpvl_data(icalpvl_tail(parser->components));
1194 snprintf(temp,
sizeof(temp),
"No value for %s property. Removing entire property",
1197 insert_error(parser, tail, str, temp, ICAL_XLICERRORTYPE_VALUEPARSEERROR);
1215 if (icalpvl_data(icalpvl_tail(parser->components)) == 0 && parser->level == 0) {
1219 return parser->root_component;