hledger icon indicating copy to clipboard operation
hledger copied to clipboard

hledger-web: adding a transaction always add it to the default journal file

Open legrostdg opened this issue 5 years ago • 2 comments

Given this ferme.journal:

include 2019.journal
include 2020.journal

I tried to add a transaction to 2020.journal with hledger-web. I selected 2020.journal in the to: field, but the transaction got added to ferme.journal

legrostdg avatar Apr 20 '20 15:04 legrostdg

Thanks for the report, it sounds like a regression.

simonmichael avatar Apr 20 '20 17:04 simonmichael

Just stumbled over this issue, I proposed a fix in https://github.com/simonmichael/hledger/pull/1873.

erictapen avatar Jul 29 '22 11:07 erictapen

It looks like this regressed with cc1241fa2 in 2018.

I'd like to restore the old behaviour where the file field is part of normal form processing (and add your extra validation, which I think we never had). Yesod form code is tricky so it'll take a bit longer, or if you'd like to have a go let me know and I'll post my diff.

simonmichael avatar Aug 24 '22 06:08 simonmichael

I understand but I think I won't put more effort into it, as indeed the form code deterred me a bit.

erictapen avatar Aug 24 '22 20:08 erictapen

Understandable. Thanks for pushing it forward!

simonmichael avatar Aug 24 '22 21:08 simonmichael

This is currently blocked on figuring out Yesod types; it's not clear how to use selectFieldList here: https://github.com/simonmichael/hledger/commit/cfc05540daad75a358a47741c16e7611fe42f54f#diff-4f785631673350333a037eca53769f9320f8b8a2856371597ef0687f52f86849R72-R124.

simonmichael avatar Aug 25 '22 07:08 simonmichael

Fixed in master, at last. Thanks again @erictapen for moving this forward.

And also for pointing out the lack of server-side validation of the journal file path. This might deserve further action, eg test if existing hledger-web versions can be tricked into appending transactions to arbitrary files the hledger-web process has write permission on; and if so, do some announcing and deprecating. Help on this is welcome from anyone. I'll leave this open for now.

simonmichael avatar Aug 26 '22 11:08 simonmichael

Thats awesome news! I'm glad there is now a fix in master.

erictapen avatar Aug 26 '22 11:08 erictapen

Happily, we did always validate the file path when adding to a different file (last seen in hledger-web 1.9). So, no security issue after all.

simonmichael avatar Aug 27 '22 17:08 simonmichael