From e19ededd66a1ccfb9ead4b3c7f6f40c355157c0d Mon Sep 17 00:00:00 2001 From: low012 Date: Mon, 5 Sep 2005 10:15:59 +0000 Subject: [PATCH] *) prevents problems due to HTML code in profiles (my posting from 05.Sep.2005 http://www.yacy-forum.de/viewtopic.php?t=964) git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@657 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ViewProfile.java | 5 +++-- source/de/anomic/data/wikiCode.java | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/htroot/ViewProfile.java b/htroot/ViewProfile.java index a0f51a32c..b9f7dd369 100644 --- a/htroot/ViewProfile.java +++ b/htroot/ViewProfile.java @@ -122,9 +122,10 @@ public class ViewProfile { //this prevents broken links ending in
if(key.equals("comment")){ value=wikiTransformer.transform( ((String)entry.getValue()).replaceAll("\r","").replaceAll("\\\\n","\n") ); - } + } + //else only HTML tags get transformed to regular text else{ - value=((String)entry.getValue()).replaceAll("\r","").replaceAll("\\\\n","\n"); + value=wikiTransformer.replaceHTML( ((String)entry.getValue()).replaceAll("\r","").replaceAll("\\\\n","\n") ); } //all known Keys which should be set as they are diff --git a/source/de/anomic/data/wikiCode.java b/source/de/anomic/data/wikiCode.java index ef4086259..899ff8fdf 100644 --- a/source/de/anomic/data/wikiCode.java +++ b/source/de/anomic/data/wikiCode.java @@ -99,12 +99,10 @@ public class wikiCode { return "internal error: " + e.getMessage(); } } - - public String transformLine(String result, plasmaSwitchboard switchboard) { - // transform page - int p0, p1; - boolean defList = false; //needed for definition lists - + + public String replaceHTML(String result) { + int p0; + // avoide html inside //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); @@ -113,6 +111,15 @@ public class wikiCode { //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 String transformLine(String result, plasmaSwitchboard switchboard) { + // transform page + int p0, p1; + boolean defList = false; //needed for definition lists + + result = replaceHTML(result); //check if line contains any escape symbol of if we are in an esacpe sequence already //if that's the case the program will continue further below [MN]