Skip to content

opts.expires not tested for proper type in cookies plugin #2793

Closed
@tomers

Description

Software version

$ quasar info

Operating System Darwin(17.7.0) - darwin/x64
NodeJs 11.2.0

Global packages
NPM 6.4.1
yarn 1.12.3
quasar-cli 0.17.22
vue-cli 2.9.6
cordova Not installed

Important local packages
quasar-cli 0.17.22 (Quasar Framework CLI)
quasar-framework 0.17.18 (Build responsive SPA, SSR, PWA, Hybrid Mobile Apps and Electron apps, all simultaneously using the same codebase)
quasar-extras 2.0.9 (Quasar Framework fonts, icons and animations)
vue 2.5.17 (Reactive, component-oriented view layer for modern web interfaces.)
vue-router 3.0.1 (Official router for Vue.js 2)
vuex 3.0.1 (state management for Vue.js)
electron Not installed
electron-packager Not installed
electron-builder Not installed
@babel/core 7.0.0-beta.54 (Babel compiler core.)
webpack 4.25.1 (Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.)
webpack-dev-server 3.1.10 (Serves a webpack app. Updates the browser on changes.)
workbox-webpack-plugin 3.6.3 (A plugin for your Webpack build process, helping you generate a manifest of local files that workbox-sw should precache.)
register-service-worker 1.5.2 (Script for registering service worker, with hooks)

Networking
Host toshalev-mbp
en0 172.22.222.132
en4 172.22.218.96

JsFiddle (for Quasar v0.15+ only)

https://jsfiddle.net/tomers/waugrryy/7482/

What did you get as the error?

I got:

TypeError: n.toUTCString is not a function

What were you expecting?

Since it happens that the expiration field expects integer, I would expect it to fail gracefully, instead of trying to run toUTCString() on the string object.

The issue is in node_modules/quasar-framework/src/plugins/cookies.js.
The opts.expires parameter is checked for type 'number' and if it is not, then it is assumed to be of type 'time'. I suggest adding console.assert to test for proper type.

What steps did you take, to get the error?

I just had to change the opts.expires from integer to string

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions