URL encoding improvements
authorAdam Dullage <redacted>
Thu, 25 Aug 2022 06:54:40 +0000 (07:54 +0100)
committerAdam Dullage <redacted>
Thu, 25 Aug 2022 06:54:40 +0000 (07:54 +0100)
flatnotes/src/classes.js
flatnotes/src/components/App.js
flatnotes/src/components/Login.vue
flatnotes/src/components/NoteViewerEditor.vue
flatnotes/src/components/SearchInput.vue

index 4349e29bd0b5a03f703751b9d7d640b75be5bb6c..14ce77c94347ba2cd24b972714af88bd7de4288a 100644 (file)
@@ -8,7 +8,7 @@ class Note {
   }
 
   get href() {
-    return `${constants.basePaths.note}/${this.title}`;
+    return `${constants.basePaths.note}/${encodeURIComponent(this.title)}`;
   }
 
   get lastModifiedAsDate() {
index f9f8314965be000907ce7abead2c2765edec9d82..38e0831752271e7759cfe38dbc64042a7b00d5a8 100644 (file)
@@ -74,7 +74,7 @@ export default {
       // Note
       else if (basePath == constants.basePaths.note) {
         this.updateDocumentTitle();
-        this.noteTitle = path[2];
+        this.noteTitle = decodeURIComponent(path[2]);
         this.currentView = this.views.note;
       }
 
index 5d89c799ada08e3b89076e0a5e5036dcf226ed19..b7f4f1f15923658f11aaa3683120336f76cb37eb 100644 (file)
@@ -1,12 +1,5 @@
 <template>
-  <div
-    class="
-      d-flex
-      flex-column
-      justify-content-center
-      align-items-center
-    "
-  >
+  <div class="d-flex flex-column justify-content-center align-items-center">
     <!-- Logo -->
     <Logo class="mb-3"></Logo>
 
@@ -95,7 +88,7 @@ export default {
             localStorage.setItem("token", response.data.access_token);
           }
           let redirectPath = helpers.getSearchParam(constants.params.redirect);
-          EventBus.$emit("navigate", redirectPath || "/");
+          EventBus.$emit("navigate", redirectPath || constants.basePaths.home);
         })
         .catch(function (error) {
           if (error.handled) {
index 00d027f6145cd3fb52ae978af35cb008b0a3d4e7..6603fdc1e7fcc15061b32e39a00eca5d24f0a6f1 100644 (file)
@@ -16,7 +16,9 @@
     <!-- Loaded -->
     <div v-else class="d-flex flex-column h-100">
       <!-- Buttons -->
-      <div class="d-flex justify-content-between flex-wrap align-items-end mb-3">
+      <div
+        class="d-flex justify-content-between flex-wrap align-items-end mb-3"
+      >
         <!-- Title -->
         <h2 v-if="editMode == false" class="title" :title="currentNote.title">
           {{ currentNote.title }}
 </style>
 
 <script>
+import * as constants from "../constants";
+
 import { Editor } from "@toast-ui/vue-editor";
 import EventBus from "../eventBus";
 import LoadingIndicator from "./LoadingIndicator";
@@ -212,7 +216,7 @@ export default {
       let parent = this;
       this.noteLoadFailed = false;
       api
-        .get(`/api/notes/${title}`)
+        .get(`/api/notes/${encodeURIComponent(title)}`)
         .then(function (response) {
           parent.currentNote = new Note(
             response.data.title,
@@ -375,7 +379,7 @@ export default {
         this.titleInput != this.currentNote.title
       ) {
         api
-          .patch(`/api/notes/${this.currentNote.title}`, {
+          .patch(`/api/notes/${encodeURIComponent(this.currentNote.title)}`, {
             newTitle: this.titleInput,
             newContent: newContent,
           })
@@ -426,7 +430,7 @@ export default {
       localStorage.removeItem(this.currentNote.title);
       if (this.currentNote.lastModified == null) {
         // Cancelling a new note
-        EventBus.$emit("navigate", "/");
+        EventBus.$emit("navigate", constants.basePaths.home);
       } else {
         this.setEditMode(false);
       }
@@ -447,10 +451,12 @@ export default {
         .then(function (response) {
           if (response == true) {
             api
-              .delete(`/api/notes/${parent.currentNote.title}`)
+              .delete(
+                `/api/notes/${encodeURIComponent(parent.currentNote.title)}`
+              )
               .then(function () {
                 parent.$emit("note-deleted");
-                EventBus.$emit("navigate", "/");
+                EventBus.$emit("navigate", constants.basePaths.home);
               })
               .catch(function (error) {
                 if (!error.handled) {
index 561f042b90498f96a4df29651e54ff145e98a3a0..dec533a915bf313df7c1900fdb02ab39b91ae39a 100644 (file)
@@ -74,7 +74,7 @@ export default {
           "navigate",
           `${constants.basePaths.search}?${
             constants.params.searchTerm
-          }=${encodeURI(this.searchTermInput)}`
+          }=${encodeURIComponent(this.searchTermInput)}`
         );
       } else {
         this.$bvToast.toast("Please enter a search term ✘", {
git clone https://git.99rst.org/PROJECT