in source/aws_profile.c [971:1066]
static bool s_parse_property_continuation(
const struct aws_byte_cursor *line_cursor,
struct profile_file_parse_context *context) {
/*
* Strip right-side whitespace only. Comments cannot be made on continuation lines. They
* get folded into the value.
*/
struct aws_byte_cursor continuation_cursor = aws_byte_cursor_right_trim_pred(line_cursor, s_is_whitespace);
/*
* Can't be a continuation without at least one whitespace on the left
*/
if (!s_parse_by_character_predicate(&continuation_cursor, s_is_whitespace, NULL, 0)) {
return false;
}
/*
* This should never happen since it should have been caught as a whitespace line
*/
if (continuation_cursor.len == 0) {
AWS_LOGF_ERROR(AWS_LS_SDKUTILS_PROFILE, "Property continuation internal parsing error");
s_log_parse_context(AWS_LL_ERROR, context);
context->parse_error = AWS_ERROR_SDKUTILS_PARSE_RECOVERABLE;
return true;
}
/*
* A continuation without a current property is bad
*/
if (context->current_profile == NULL || context->current_property == NULL) {
AWS_LOGF_WARN(AWS_LS_SDKUTILS_PROFILE, "Property continuation seen outside of a current property");
s_log_parse_context(AWS_LL_WARN, context);
context->parse_error = AWS_ERROR_SDKUTILS_PARSE_FATAL;
return true;
}
if (s_profile_property_add_continuation(context->current_property, &continuation_cursor)) {
AWS_LOGF_WARN(AWS_LS_SDKUTILS_PROFILE, "Property continuation could not be applied to the current property");
s_log_parse_context(AWS_LL_WARN, context);
context->parse_error = AWS_ERROR_SDKUTILS_PARSE_RECOVERABLE;
return true;
}
if (context->current_property->is_empty_valued) {
struct aws_byte_cursor key_cursor;
if (!s_parse_by_character_predicate(&continuation_cursor, s_is_not_assignment_operator, &key_cursor, 0)) {
AWS_LOGF_WARN(
AWS_LS_SDKUTILS_PROFILE, "Empty-valued property continuation must contain the assignment operator");
s_log_parse_context(AWS_LL_WARN, context);
context->parse_error = AWS_ERROR_SDKUTILS_PARSE_FATAL;
return true;
}
if (!s_parse_by_character_predicate(&continuation_cursor, s_is_assignment_operator, NULL, 1)) {
AWS_LOGF_WARN(
AWS_LS_SDKUTILS_PROFILE, "Empty-valued property continuation must contain the assignment operator");
s_log_parse_context(AWS_LL_WARN, context);
context->parse_error = AWS_ERROR_SDKUTILS_PARSE_FATAL;
return true;
}
struct aws_byte_cursor trimmed_key_cursor = aws_byte_cursor_right_trim_pred(&key_cursor, s_is_whitespace);
struct aws_byte_cursor id_check_cursor = aws_byte_cursor_trim_pred(&trimmed_key_cursor, s_is_identifier);
if (id_check_cursor.len > 0) {
AWS_LOGF_WARN(
AWS_LS_SDKUTILS_PROFILE,
"Empty-valued property continuation must have a valid identifier to the left of the assignment");
s_log_parse_context(AWS_LL_WARN, context);
context->parse_error = AWS_ERROR_SDKUTILS_PARSE_RECOVERABLE;
return true;
}
s_parse_by_character_predicate(&continuation_cursor, s_is_whitespace, NULL, 0);
/*
* everything left in the continuation_cursor is the sub property value
*/
if (s_profile_property_add_sub_property(
context->current_property, &trimmed_key_cursor, &continuation_cursor, context)) {
AWS_LOGF_ERROR(AWS_LS_SDKUTILS_PROFILE, "Internal error adding sub property to current property");
s_log_parse_context(AWS_LL_ERROR, context);
context->parse_error = AWS_ERROR_SDKUTILS_PARSE_FATAL;
}
}
return true;
}