Store enclosure metadata without fetching remote URLs - #175
Conversation
| getBean().getEnclosureType(), | ||
| getBean().getEnclosureLength()); | ||
| } catch (IllegalArgumentException e) { | ||
| addError("weblogEdit.enclosureMetadataInvalid"); |
There was a problem hiding this comment.
This is fatal where the old flow was advisory (addMessage and continue), and existing entries can't pass it: the removed MediacastUtil stored con.getContentType() verbatim, so att_mediacast_type may be audio/mpeg; charset=utf-8 or video/mp4;codecs=avc1, which MEDIA_TYPE rejects. The author then can't save any change to that entry until they notice and hand-edit the type. Either accept parameters in the regex (and strip them), or treat an invalid legacy value as "clear the enclosure and warn" instead of refusing the save. Also, one generic message for three fields: a blank Length (new field, previously auto-filled) produces the same text as a bad URL.
| getBean().getEnclosureLength()); | ||
| } catch (IllegalArgumentException e) { | ||
| addError("weblogEdit.enclosureMetadataInvalid"); | ||
| return INPUT; |
There was a problem hiding this comment.
This returns before the if ("entryAdd".equals(actionName)) getBean().setStatus(null) reset at the end of the method (line 309), which every other failed save on a new entry goes through. publish() has already stamped PUBLISHED on the bean, so the form re-renders with the green "Published (Last updated: )" badge and an empty date for an entry that was never written, and the hidden bean.status carries PUBLISHED into the next submit.
| } | ||
| if (!MEDIA_TYPE.matcher(normalizedType).matches()) { | ||
| throw new IllegalArgumentException("Enclosure type must be a valid media type"); | ||
| } |
There was a problem hiding this comment.
Nit: no upper bound; Long.MAX_VALUE is accepted and the feed advertises an 8 EiB enclosure. The form caps the field at 20 characters, so a sanity ceiling here would match.
| weblogEdit.mediaCastUrlMalformed=The enclosure URL was malformed. | ||
| weblogEdit.mediaCastResponseError=The enclosure server returned an error. Do you have the right URL? | ||
| weblogEdit.mediaCastLacksContentTypeOrLength=Unable to use enclosure URL. Server provided no content type or no length. | ||
| weblogEdit.enclosureURL.tooltip=Absolute HTTP or HTTPS URL to embed within the RSS & Atom feeds for this blog entry. |
There was a problem hiding this comment.
Nit: the four removed weblogEdit.mediaCast* keys are still in the _de / _es / _fr / _ja / _ko / _ru / _zh_CN bundles, and the ja / zh_CN tooltips still describe the old "podcast URL" semantics rather than the HTTP(S)-only requirement that now produces the error.
Three conflicts. ApplicationResources_zh_CN.properties: both sides trimmed a different number of trailing blank lines. Resolved to master's ending. EntryEdit: each side dropped a different set of imports, so the union of the two conflict sides was misleading. Master removed the outbound trackback code and this branch removed the remote-fetch code; the merged body references neither, so only the cache import remains. save() keeps the guard that arrived from master and stays package-private, which this branch had widened it to so its test can drive it. MediaFileAddSuccess.jsp: both sides had independently moved the inline handler onto data attributes, master via a delegated listener and this branch via a direct binding. Keeping both would have left two handlers and two definitions of setEnclosure, and the later one wins, which would have silently dropped the type and length this branch adds. Resolved to the delegated listener carrying all three values. One test needed adjusting for the merged code: the new-entry case in EntryEditEnclosureTest drives save() directly and never runs myPrepare, so it now stands up the entry myPrepare creates for a new post. Claude-Session: https://claude.ai/code/session_019R1jdtwkaYEeA6L9DXEtEi
Summary:
Testing: