Browse Source

title fix

master
RENOX 4 months ago
parent
commit
978e113c87
3 changed files with 11 additions and 11 deletions
  1. +2
    -4
      src/main/java/planetrenox/controller/FormController.java
  2. +7
    -5
      src/main/java/planetrenox/controller/RequestValidation.java
  3. +2
    -2
      src/main/resources/static/js/main.js

+ 2
- 4
src/main/java/planetrenox/controller/FormController.java View File

@@ -1,15 +1,13 @@
package planetrenox.controller;

import lombok.NonNull;
import org.springframework.aop.scope.ScopedProxyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import planetrenox.encryption.AES256_GCM;
import planetrenox.mongodb.Dungeon;
import planetrenox.mongodb.DungeonRepository;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import java.util.Map;

@RestController
@@ -63,7 +61,7 @@ public class FormController
*/
@PostMapping(path = "/", params = {"name", "password", "text", "tabs"})
public Map<String, Object> save
(@NonNull @RequestParam("name") final String name, @NonNull @RequestParam("password") final String password, @NonNull @RequestParam("text") final String text, @RequestParam("tabs") final int tabs) throws UnsupportedEncodingException
(@NonNull @RequestParam("name") final String name, @NonNull @RequestParam("password") final String password, @NonNull @RequestParam("text") final String text, @RequestParam("tabs") final int tabs)
{
Map<String, Object> saveDocument = RequestValidation.validateSave(name, password, text, tabs);
if ((boolean) saveDocument.get("INVALID")) return saveDocument; // Validation Failed


+ 7
- 5
src/main/java/planetrenox/controller/RequestValidation.java View File

@@ -1,6 +1,7 @@
package planetrenox.controller;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.safety.Whitelist;

import java.util.Map;
@@ -26,7 +27,7 @@ public class RequestValidation
"CLEAN_NAME", ""
));

loginDocument.put("CLEAN_NAME", Jsoup.clean(name, Whitelist.simpleText()));
loginDocument.put("CLEAN_NAME", Jsoup.clean(name, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)).replaceAll("&amp;", "&"));

if (name.length() > 60)
{
@@ -63,8 +64,8 @@ public class RequestValidation
"CLEAN_TEXT", ""
));

saveDocument.put("CLEAN_NAME", Jsoup.clean(name, Whitelist.simpleText()));
saveDocument.put("CLEAN_TEXT", Jsoup.clean(text, Whitelist.basic()).replaceAll("&amp;", "&"));
saveDocument.put("CLEAN_NAME", Jsoup.clean(name, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)).replaceAll("&amp;", "&"));
saveDocument.put("CLEAN_TEXT", Jsoup.clean(text, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)).replaceAll("&amp;", "&"));

if (name.length() > 60)
{
@@ -105,8 +106,9 @@ public class RequestValidation
"CLEAN_TEXT", ""
));

saveDocument.put("CLEAN_NAME", Jsoup.clean(name, Whitelist.simpleText()));
saveDocument.put("CLEAN_TEXT", Jsoup.clean(text, Whitelist.basic()).replaceAll("&amp;", "&"));
saveDocument.put("CLEAN_NAME", Jsoup.clean(name, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)).replaceAll("&amp;", "&"));
saveDocument.put("CLEAN_TEXT", Jsoup.clean(text, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)).replaceAll("&amp;", "&"));


if (name.length() > 60)
{


+ 2
- 2
src/main/resources/static/js/main.js View File

@@ -73,7 +73,7 @@ function initValidateSave() {
tabCount++;
empty = false;
text += values + "|textdungeon-tab|";
document.getElementById("tab" + tabTitleCount).textContent = values.substring(0, 10); // setting tab titles
document.getElementById("tab" + tabTitleCount).textContent = values.split('\n')[0].substring(0, 10); // setting tab titles
}
}
if (document.getElementById("password-form").value === "") // logged in user
@@ -278,7 +278,7 @@ function populateFormLocalEvent(responseJson) {
for (let i = 0; i < responseJson.DUNGEON.meta.TAB_COUNT; i++) {
if (i !== 0) initAddTab();
tabContent.set("tab" + (i + 1), entireTextArray[i]);
document.getElementById("tab" + (i + 1)).textContent = entireTextArray[i].substring(0, 10);
document.getElementById("tab" + (i + 1)).textContent = entireTextArray[i].split('\n')[0].substring(0, 10);
}
document.getElementById("textarea").value = entireTextArray[0];
}


Loading…
Cancel
Save