mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 09:03:44 +08:00
FIX: prevents errors on /tags when a tag constructor
exists (#10449)
This is due to js objects having a constructor property: ``` const obj = {}; obj['constructor'] // return [native code] and not undefined ```
This commit is contained in:
parent
ef9af004f7
commit
6d0eb7178d
|
@ -25,21 +25,21 @@ function storeMap(type, id, obj) {
|
||||||
|
|
||||||
function fromMap(type, id) {
|
function fromMap(type, id) {
|
||||||
const byType = _identityMap[type];
|
const byType = _identityMap[type];
|
||||||
if (byType) {
|
if (byType && byType.hasOwnProperty(id)) {
|
||||||
return byType[id];
|
return byType[id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeMap(type, id) {
|
function removeMap(type, id) {
|
||||||
const byType = _identityMap[type];
|
const byType = _identityMap[type];
|
||||||
if (byType) {
|
if (byType && byType.hasOwnProperty(id)) {
|
||||||
delete byType[id];
|
delete byType[id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function findAndRemoveMap(type, id) {
|
function findAndRemoveMap(type, id) {
|
||||||
const byType = _identityMap[type];
|
const byType = _identityMap[type];
|
||||||
if (byType) {
|
if (byType && byType.hasOwnProperty(id)) {
|
||||||
const result = byType[id];
|
const result = byType[id];
|
||||||
delete byType[id];
|
delete byType[id];
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -5,7 +5,8 @@ class Tag < ActiveRecord::Base
|
||||||
include HasDestroyedWebHook
|
include HasDestroyedWebHook
|
||||||
|
|
||||||
RESERVED_TAGS = [
|
RESERVED_TAGS = [
|
||||||
'none'
|
'none',
|
||||||
|
'constructor' # prevents issues with javascript's constructor of objects
|
||||||
]
|
]
|
||||||
|
|
||||||
validates :name,
|
validates :name,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user