Giter Club home page Giter Club logo

kirby-form's People

Contributors

adamkiss avatar ceesvanegmond avatar jevets avatar lukaskleinschmidt avatar lukasleitsch avatar marcus-at-localhost avatar mzur avatar nilshoerrmann avatar s3ththompson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kirby-form's Issues

CSRF validation always fails if form enctype is multipart/form-data

Hi there,

thanks for this awesome plugin. I implement an application form with file upload, but unfortunately the csrf validation fails.
This is due to the fact that the Kirby Request object does not parse multipart/form-data encoded form data and hence $token === null in Form.php#157.

Am I missing out on something or is this considered a bug?

Cheerio

Improve file upload validation

I noticed an issue with missing csrf tokens[1], when uploading larger files through a public facing form. [2]
After finally looking into the php error log I saw this warning: PHP Warning: POST Content-Length of 19119038 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 and with upping the allowed filesize/post size in php.ini

upload_max_filesize = 64M
post_max_size = 192M

I was good to go.

Unfortunately there is no indication of those limits outside of kirby in the plugin, so I would propose a check for these values, maybe behind the debug flag like kirby itself is doing: https://github.com/getkirby/kirby/blob/04127160ed1ab8dc277763cd8ba4ebc5a097bc18/src/Api/Api.php#L747-L756

if (empty($files) === true) {
    $postMaxSize       = Str::toBytes(ini_get('post_max_size'));
    $uploadMaxFileSize = Str::toBytes(ini_get('upload_max_filesize'));

    if ($postMaxSize < $uploadMaxFileSize) {
        throw new Exception(t('upload.error.iniPostSize'));
    } else {
        throw new Exception(t('upload.error.noFiles'));
    }
}

I would have sent a pull request, but I'm not sure where to place that check.

Maybe this is something to consider. Thanks!

[1] Just for the record, check for token happens here

if (empty($token) || csrf($token) !== true) {
- also csrf tokens dont make so much sense for public facing forms if no authentication is involved.
[2] With version 3.1.0 the token was present in the header though, but the whole form was empty :)

PHP 8.1 compatibility

When using the library with PHP 8.1, it triggers the following deprecation notice:

htmlspecialchars_decode(): Passing null to parameter #1 ($string) of type string is deprecated

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.