moin icon indicating copy to clipboard operation
moin copied to clipboard

Content modification: validation logic somehow flawed

Open roland-ruedenauer opened this issue 8 months ago • 3 comments

Main problem: the validation of meta data depends on content extracted from previous page revision

To reproduce the problem

  • enter an invalid external reference like e.g. [[1838 https://github.com/moinwiki/moin/issues/1838|Issue #1838]] into a moin wiki page
  • when previewing everything looks good
  • saving the page will make moin store an itemlink(!) into the metadata of the page
  • when reloading the page after saving everything looks still good
  • modify the same page again by e.g. appending some text
  • save the modifications
  • boom ... Internal Server Error

Here, moin will detect the invaid meta data caused by a bad itemlink found in meta[ITEMLINKS]:

https://github.com/moinwiki/moin/blob/1dfd0af5423744dc983bc20b35a1ff84d518a76a/src/moin/storage/middleware/indexing.py#L1251

The invalid itemlink was created when saving the page before the current editing happened.

When the error happens, the new content of the wiki page hasn't been validated at all.

Note: testing this should be done with the fixes in #1882 applied

roland-ruedenauer avatar Mar 28 '25 15:03 roland-ruedenauer

Testing on Windows 10 with #1882 and #1873 applied, I get a flash message when saving the item after the 2nd update - no internal server error.

Error: metadata validation failed, invalid field value(s) = "1838 https://github.com/moinwiki/moin/issues/1838".

The item is not updated with the 2nd revision's changes, clicking Modify results in a flash message "You may recover your draft saved..." and a Load Draft button. Clicking the load draft button loads the unsaved changes.

The first flash message should be changed to "Error: Nothing saved, metadata validation failed..."

Agree, the metadata validation should result in an error message on the item's first save.

RogerHaase avatar Mar 30 '25 17:03 RogerHaase

You're right, I mixed things up. The Internal Server Error was in fact triggered by the markdown issue #1838 (corrected with the latest commits).

Is it expected to only being offered a recovery (Load Draft), if I did preview before saving the modified page content?

roland-ruedenauer avatar Mar 30 '25 22:03 roland-ruedenauer

Right, you will only get a Load Draft button after a Preview.

RogerHaase avatar Mar 31 '25 15:03 RogerHaase

@roland-ruedenauer: Can this be closed?

RogerHaase avatar Nov 09 '25 20:11 RogerHaase

No, this issue requires work to be done. I've prepared a fix a while ago, but it still needs some polish. Please assign this issue to me.

roland-ruedenauer avatar Nov 09 '25 20:11 roland-ruedenauer