Skip to content

Commit

Permalink
*) prevents problems due to HTML code in profiles (my posting from 05…
Browse files Browse the repository at this point in the history
….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
  • Loading branch information
low012 committed Sep 5, 2005
1 parent 4e07828 commit e19eded
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 3 additions & 2 deletions htroot/ViewProfile.java
Expand Up @@ -122,9 +122,10 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
//this prevents broken links ending in <br>
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
Expand Down
19 changes: 13 additions & 6 deletions source/de/anomic/data/wikiCode.java
Expand Up @@ -99,12 +99,10 @@ public String transform(byte[] content, plasmaSwitchboard switchboard) {
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) + "&amp;" + result.substring(p0 + 1);
p0 = 0; while ((p0 = result.indexOf('"', p0)) >= 0) result = result.substring(0, p0) + "&quot;" + result.substring(p0 + 1);
Expand All @@ -113,6 +111,15 @@ public String transformLine(String result, plasmaSwitchboard switchboard) {
//p0 = 0; while ((p0 = result.indexOf("*", p0)) >= 0) result = result.substring(0, p0) + "&#149;" + result.substring(p0 + 1);
p0 = 0; while ((p0 = result.indexOf("(C)", p0)) >= 0) result = result.substring(0, p0) + "&copy;" + 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]
Expand Down

0 comments on commit e19eded

Please sign in to comment.