fl3pp / PicoMailForms

An extension for Pico which allows you to define forms in markdown and send mails
The Unlicense
4 stars 2 forks source link

Unable to get plugin to work with PicoCMS for NextCloud. #5

Closed MarkPartlett closed 3 years ago

MarkPartlett commented 3 years ago

I have setup two PicoCMS environments, both I setup via composer via command-line.

With the standalone version of PicoCMS, I was able to get the plugin to work and send email successfully.

The version installed into 'PicoCMS for Nextcloud' would create the labels for the form objects, but no input text or text area and no submit button would be displayed. This happened for both plain and bootstrap forms.

I found an Nextcloud Forum around 'HTML Forms' https://help.nextcloud.com/t/html-form-in-pico-cms-wont-show-autoescape-issue/73939 .. but I am unsure if this is the issue.

fl3pp commented 3 years ago

I think you hit the nail with this issue.

As you can see in the github.com/nexcloud/cms_pico readme file, HTML in markdown is not only not supported, but removed by design to prevent Cross-Site-Scripting: "Pico CMS for Nextcloud follows a "Better safe than sorry" mentality, thus we let HTMLPurifier remove any potentially active content from Markdown files.". As you can clearly see in the PlainBuilder.php of PicoMailForms, it sets up a HTML post form which is probably stripped because of security reasons.

In the next paragraph of nextcloud/cms_pico they state: "These limitations don't apply to themes, so if you know what you're doing, you can create a custom theme to include any advanced features you need". So what could work is that you generate the HTML on a local Pico installation and then adjust/copy the generated form into a twig template, which you then use on your desired site.

I know that would be a lot more complicated and I can still not guarantee it would work, but if the Pico distribution strips the HTML, I don't see another way.

MarkPartlett commented 3 years ago

I generated the HTML form code and inserted the block into the theme twig file. The form was displayed correctly with input boxes and submit button. On submitting form received a HTTP 405 error. Method Not Allowed.

fl3pp commented 3 years ago

It seems that Nextcloud doesn't allow different HTTP methods to GET. If that's the case, the plugin cannot possibly work in this Pico distribution. If you want to, you can fork the repo and figure out a way to do client-server communication in this environment.

I am sorry, but your use-case is probably just not supported by PicoCMS for Nextcloud. I am closing this issue and am wishing you luck for your project.