Skip to content
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

luci-app-lxc: fix configure lxc container POST request #7629

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ducloc464
Copy link

@ducloc464 ducloc464 commented Feb 15, 2025

  • This PR is not from my main or master branch πŸ’©, but a separate branch βœ…
  • Each commit has a valid βœ’οΈ Signed-off-by: <my@email.address> row (via git commit --signoff)
  • Each commit and PR title has a valid πŸ“ <package name>: title first line subject for packages
  • Incremented πŸ†™ any PKG_VERSION in the Makefile
  • Tested on: (x86_64, 23.0.5, Chrome) βœ…
  • ( Preferred ) Mention: @ the original code author for feedback
  • ( Preferred ) Screenshot or mp4 of changes:
  • ( Optional ) Closes: e.g. luci-app-lxc: "Action failed!" when configuring containerΒ #6098
  • ( Optional ) Depends on: e.g. openwrt/packages#pr-number in sister repo
  • Description: the code for sending POST request to Luci was in wrong format, It did not have key value for formvalue and the value has to decode from encodeURIComponent

The backend code is:
local lxc_configuration = luci.http.formvalue("lxc_conf")
but frontend do not send formvalue with key "lxc_conf":
new XHR().post('<%=luci.dispatcher.build_url("admin", "services")%>/lxc_configuration_set/' + lxc_name, "lxc_conf=" + encodeURIComponent(lxc_conf)

The fix is:

new XHR().post('<%=luci.dispatcher.build_url("admin", "services")%>/lxc_configuration_set/' + lxc_name, {"lxc_conf": encodeURIComponent(lxc_conf)}

and decoded string is required for LXC

lxc_configuration = luci.http.urldecode(lxc_configuration, true)

@ducloc464 ducloc464 changed the title fix: configure lxc container POST request luci-app-lxc: fix configure lxc container POST request Feb 15, 2025
Signed-off-by: ducloc464 <ducloc464@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant