Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) taking back changes for replaceHTML
low012c6d58d9b9a7a
diff --git a/source/de/anomic/data/wikiCode.java b/source/de/anomic/data/wikiCode.javaindex 300f3423a..bff167e23 100644--- a/source/de/anomic/data/wikiCode.java+++ b/source/de/anomic/data/wikiCode.java@@ -109,131 +109,22 @@ public class wikiCode {}}- //The following method has been submitted by Kane (added and a few changes by MN)- /** Replaces special characters from a string. Otherwise they might cause ugly output on some systems.- * This code is also important to avoid XSS attacks.- *- * @param text a string that possibly contains special characters- * @return the string with all special characters encoded so they will look right on every system- */- public static String replaceHTML(String text) {- if (text==null) { return null; }- for (int x=0;x<=htmlentities.length-1;x=x+2) {- int p=0;- while ((p=text.indexOf(htmlentities[x],p))>=0) {- text=text.substring(0,p)+htmlentities[x+1]+text.substring(p+htmlentities[x].length());- p+=htmlentities[x+1].length();- }- }- return text;+ public static String replaceHTML(String result) {+ if (result == null) return null;+ int p0;++ // Ampersands have to be replaced first. If they were replaced later,+ // other replaced characters containing ampersands would get messed up.+ p0 = 0; while ((p0 = result.indexOf("&", p0)) >= 0) {result = result.substring(0, p0) + "&" + result.substring(p0 + 1); p0++;}+ p0 = 0; while ((p0 = result.indexOf('"', p0)) >= 0) result = result.substring(0, p0) + """ + result.substring(p0 + 1);+ p0 = 0; while ((p0 = result.indexOf("<", p0)) >= 0) result = result.substring(0, p0) + "<" + result.substring(p0 + 1);+ p0 = 0; while ((p0 = result.indexOf(">", p0)) >= 0) result = result.substring(0, p0) + ">" + result.substring(p0 + 1);+ //p0 = 0; while ((p0 = result.indexOf("*", p0)) >= 0) result = result.substring(0, p0) + "•" + result.substring(p0 + 1);+ p0 = 0; while ((p0 = result.indexOf("(C)", p0)) >= 0) result = result.substring(0, p0) + "©" + result.substring(p0 + 3);++ return result;}- public static String[] htmlentities={- "&","&", // Ampersands _have_ to be replaced first. If they were replaced later,- // other replaced characters containing ampersands would get messed up.- //" "," ",- "�","¡",- "�","¢",- "�","£",- //"?","¤",- "�","¥",- //"?","¦",- "�","§",- //"?","¨",- "�","©",- "�","ª",- "�","«",- "�","¬",- //"","­",- "�","®",- "�","¯",- "�","°",- "�","±",- "�","²",- "�","³",- //"?","´",- "�","µ",- "�","¶",- "�","·",- //"?","¸",- "�","¹",- "�","º",- "�","»",- //"?","¼",- //"?","½",- //"?","¾",- "�","¿",- "�","À",- "�","Á",- "�","Â",- "�","Ã",- "�","Ä",- "�","Å",- "�","Æ",- "�","Ç",- "�","È",- "�","É",- "�","Ê",- "�","Ë",- "�","Ì",- "�","Í",- "�","Î",- "�","Ï",- "�","Ð",- "�","Ñ",- "�","Ò",- "�","Ó",- "�","Ô",- "�","Õ",- "�","Ö",- "�","×",- "�","Ø",- "�","Ù",- "�","Ú",- "�","Û",- "�","Ü",- "�","Ý",- "�","Þ",- "�","ß",- "�","à",- "�","á",- "�","â",- "�","ã",- "�","ä",- "�","å",- "�","æ",- "�","ç",- "�","è",- "�","é",- "�","ê",- "�","ë",- "�","ì",- "�","í",- "�","î",- "�","ï",- "�","ð",- "�","ñ",- "�","ò",- "�","ó",- "�","ô",- "�","õ",- "�","ö",- "�","÷",- "�","ø",- "�","ù",- "�","ú",- "�","û",- "�","ü",- "�","ý",- "�","þ",- "�","ÿ",- "\"",""",- "<","<",- ">",">",- "(C)","©"- };- //end of Kane's code-/** Replaces wiki tags with HTML tags.** @param result a line of text