diff --git a/deps/graph-parser/src/logseq/graph_parser/property.cljs b/deps/graph-parser/src/logseq/graph_parser/property.cljs index c33ab6f2e..0cf07e48f 100644 --- a/deps/graph-parser/src/logseq/graph_parser/property.cljs +++ b/deps/graph-parser/src/logseq/graph_parser/property.cljs @@ -21,14 +21,6 @@ (map #(str (name (key %)) (str colons " ") (val %))) (string/join "\n"))) -(defn valid-property-name? - [s] - {:pre [(string? s)]} - (and (gp-util/valid-edn-keyword? s) - (not (re-find #"[\"|^|(|)|{|}]+" s)) - ;; Disallow tags as property names - (not (re-find #"^:#" s)))) - (defn properties-ast? [block] (and @@ -39,6 +31,14 @@ ;; Configuration and fns for older, file graph properties ;; ============= +(defn valid-property-name? + [s] + {:pre [(string? s)]} + (and (gp-util/valid-edn-keyword? s) + (not (re-find #"[\"|^|(|)|{|}]+" s)) + ;; Disallow tags as property names + (not (re-find #"^:#" s)))) + ;; Built-in properties are properties that logseq uses for its features. Most of ;; these properties are hidden from the user but a few like the editable ones ;; are visible for the user to edit. @@ -207,3 +207,9 @@ (defonce db-built-in-properties-keys-str (set (map name (keys db-built-in-properties)))) + +(defn db-valid-property-name? + [s] + {:pre [(string? s)]} + ;; Disallow tags or page refs as they would create unreferenceable page names + (not (re-find #"^(#|\[\[)" s))) \ No newline at end of file diff --git a/src/main/frontend/components/property.cljs b/src/main/frontend/components/property.cljs index 1a0386ed6..f1b37dfda 100644 --- a/src/main/frontend/components/property.cljs +++ b/src/main/frontend/components/property.cljs @@ -338,7 +338,7 @@ (let [editor-id (str "ls-property-" blocks-container-id (:db/id entity) "-" (:db/id property))] (set-editing! property editor-id "" "")))) ;; new property - (if (gp-property/valid-property-name? (str ":" property-name)) + (if (gp-property/db-valid-property-name? property-name) (if (= "class" (:block/type entity)) (add-property! entity property-name "" {:class-schema? class-schema?}) (do @@ -346,7 +346,7 @@ ;; configure new property (when-let [property (get-property-from-db property-name)] (state/set-sub-modal! #(property-config repo property))))) - (do (notification/show! "This is an invalid property name. A property name cannot start with non-alphanumeric characters e.g. '#' or '[['." :error) + (do (notification/show! "This is an invalid property name. A property name cannot start with page reference characters '#' or '[['." :error) (exit-edit-property)))))) (rum/defcs property-input < rum/reactive