diff --git a/backend/api/controllers/groupController.js b/backend/api/controllers/groupController.js index 3a8b1c9f..22dd93cb 100644 --- a/backend/api/controllers/groupController.js +++ b/backend/api/controllers/groupController.js @@ -23,8 +23,10 @@ exports.group_create = (req, res) => { }); }; +// lean option means only return name and id exports.group_all_groups = (req, res) => { - Group.find({}, (err, groups) => { + const projection = req.query.lean === "true" ? 'title' : ''; + Group.find({}, projection, {}, (err, groups) => { if (err) res.status(err.status).send(err.message); else res.status(200).send(groups); }); diff --git a/package-lock.json b/package-lock.json index 835de428..5e32fb47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,8 +39,8 @@ "graceful-fs": "^4.2.4", "javascript-time-ago": "^2.5.11", "jsonwebtoken": "^9.0.0", - "linkify-react": "^3.0.4", - "linkifyjs": "^3.0.5", + "linkify-react": "^4.1.3", + "linkifyjs": "^4.1.3", "locale": "^0.1.0", "lodash": "^4.17.21", "migrate-mongoose": "^4.0.0", @@ -75,6 +75,7 @@ "request": "^2.88.2", "request-promise": "^4.2.6", "rwlock": "^5.0.0", + "sanitize-html": "^2.13.0", "single-line-log": "^1.1.2", "socket.io": "^4.5.1", "socket.io-client": "^4.5.1", @@ -110,6 +111,7 @@ "@types/react-router-bootstrap": "^0.24.5", "@types/react-router-dom": "^5.1.7", "@types/react-tagcloud": "^1.1.7", + "@types/sanitize-html": "^2.13.0", "chai": "^3.3.0", "clarinet": "^0.12.4", "cross-env": "^7.0.3", @@ -4161,6 +4163,15 @@ "version": "0.12.1", "license": "MIT" }, + "node_modules/@types/sanitize-html": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/@types/sanitize-html/-/sanitize-html-2.13.0.tgz", + "integrity": "sha512-X31WxbvW9TjIhZZNyNBZ/p5ax4ti7qsNDBDEnH4zAgmEh35YnFD1UiS6z9Cd34kKm0LslFW0KPmTQzu/oGtsqQ==", + "dev": true, + "dependencies": { + "htmlparser2": "^8.0.0" + } + }, "node_modules/@types/scheduler": { "version": "0.16.2", "license": "MIT" @@ -8245,14 +8256,15 @@ } }, "node_modules/domelementtype": { - "version": "2.2.0", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/fb55" } - ], - "license": "BSD-2-Clause" + ] }, "node_modules/domexception": { "version": "2.0.1", @@ -11093,6 +11105,64 @@ "node": ">=0.10" } }, + "node_modules/htmlparser2": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", + "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1", + "entities": "^4.4.0" + } + }, + "node_modules/htmlparser2/node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/htmlparser2/node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/htmlparser2/node_modules/domutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", + "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, "node_modules/http-deceiver": { "version": "1.2.7", "license": "MIT" @@ -13568,16 +13638,18 @@ "license": "MIT" }, "node_modules/linkify-react": { - "version": "3.0.4", - "license": "MIT", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/linkify-react/-/linkify-react-4.1.3.tgz", + "integrity": "sha512-rhI3zM/fxn5BfRPHfi4r9N7zgac4vOIxub1wHIWXLA5ENTMs+BGaIaFO1D1PhmxgwhIKmJz3H7uCP0Dg5JwSlA==", "peerDependencies": { - "linkifyjs": "^3.0.0", + "linkifyjs": "^4.0.0", "react": ">= 15.0.0" } }, "node_modules/linkifyjs": { - "version": "3.0.5", - "license": "MIT" + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.1.3.tgz", + "integrity": "sha512-auMesunaJ8yfkHvK4gfg1K0SaKX/6Wn9g2Aac/NwX+l5VdmFZzo/hdPGxEOETj+ryRa4/fiOPjeeKURSAJx1sg==" }, "node_modules/load-json-file": { "version": "1.1.0", @@ -15795,6 +15867,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parse-srcset": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz", + "integrity": "sha512-/2qh0lav6CmI15FzA3i/2Bzk2zCgQhGMkvhOhKNcBVQ1ldgpbfiNTVslmooUmWJcADi1f1kIeynbDRVzNlfR6Q==" + }, "node_modules/parse5": { "version": "6.0.1", "license": "MIT" @@ -18961,6 +19038,38 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/sanitize-html": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.13.0.tgz", + "integrity": "sha512-Xff91Z+4Mz5QiNSLdLWwjgBDm5b1RU6xBT0+12rapjiaR7SwfRdjw8f+6Rir2MXKLrDicRFHdb51hGOAxmsUIA==", + "dependencies": { + "deepmerge": "^4.2.2", + "escape-string-regexp": "^4.0.0", + "htmlparser2": "^8.0.0", + "is-plain-object": "^5.0.0", + "parse-srcset": "^1.0.2", + "postcss": "^8.3.11" + } + }, + "node_modules/sanitize-html/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/sanitize-html/node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/sanitize.css": { "version": "13.0.0", "license": "CC0-1.0" diff --git a/package.json b/package.json index d04e400d..ed89c54d 100644 --- a/package.json +++ b/package.json @@ -68,8 +68,8 @@ "graceful-fs": "^4.2.4", "javascript-time-ago": "^2.5.11", "jsonwebtoken": "^9.0.0", - "linkify-react": "^3.0.4", - "linkifyjs": "^3.0.5", + "linkify-react": "^4.1.3", + "linkifyjs": "^4.1.3", "locale": "^0.1.0", "lodash": "^4.17.21", "migrate-mongoose": "^4.0.0", @@ -104,6 +104,7 @@ "request": "^2.88.2", "request-promise": "^4.2.6", "rwlock": "^5.0.0", + "sanitize-html": "^2.13.0", "single-line-log": "^1.1.2", "socket.io": "^4.5.1", "socket.io-client": "^4.5.1", @@ -139,6 +140,7 @@ "@types/react-router-bootstrap": "^0.24.5", "@types/react-router-dom": "^5.1.7", "@types/react-tagcloud": "^1.1.7", + "@types/sanitize-html": "^2.13.0", "chai": "^3.3.0", "clarinet": "^0.12.4", "cross-env": "^7.0.3", diff --git a/public/index.html b/public/index.html index 9827df99..0f9d018e 100644 --- a/public/index.html +++ b/public/index.html @@ -3,10 +3,12 @@
- - +