-
Notifications
You must be signed in to change notification settings - Fork 7
Issue 53498: reject string attachment values for query insert/update api #6928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| if (isAttachmentProperty(name)) | ||
| { | ||
| if (null != file.getFilename()) | ||
| if (value instanceof AttachmentFile file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Put more simply:
if (value instanceof AttachmentFile file)
{
if (null != file.getFilename())
{
rowStripped.put(name, file.getFilename());
attachments.put(name, value);
}
}
else if (value instanceof String strVal && !StringUtils.isEmpty(strVal))
{
// Issue 53498: string value for an attachment field is not allowed
throw new ValidationException("Can't upload '" + strVal + "' to field " + name + " with type Attachment.");
}
else
rowStripped.put(name, value); // if blank, remove the attachment| attachments.put(name, value); | ||
| } | ||
| } | ||
| else if (value instanceof String strVal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this leave it open to being another type of value besides a File or String (number, date, boolean, etc.)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed made to also check for non string types (excluding attachment type). Similar change is also made for FileLink fields. Tests added for both attachment and filelink.
Rationale
This PR is the follow up work for #6894 that went to 25.7, that made attachment columns rejecting string type values on import. This PR handles attachment value validation for insert/update api.
Related Pull Requests
Changes
Tasks 📍