Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 77526 Details for
Bug 200389
Link widget allows every html tag
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
escape html tags other than <a>, </a> and <a *
patch-escape.txt (text/plain), 3.71 KB, created by
Mariot Chauvin
on 2007-08-31 23:35:14 EDT
(
hide
)
Description:
escape html tags other than <a>, </a> and <a *
Filename:
MIME Type:
Creator:
Mariot Chauvin
Created:
2007-08-31 23:35:14 EDT
Size:
3.71 KB
patch
obsolete
>Index: Link.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Link.java,v >retrieving revision 1.8 >diff -u -r1.8 Link.java >--- Link.java 16 Aug 2007 18:54:31 -0000 1.8 >+++ Link.java 1 Sep 2007 03:24:48 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2002-2006 Innoopract Informationssysteme GmbH. >+ * Copyright (c) 2002-2007 Innoopract Informationssysteme GmbH and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * Innoopract Informationssysteme GmbH - initial API and implementation >+ * Mariot Chauvin <mariot.chauvin@gmail.com> - bug 200389 > ******************************************************************************/ > > package org.eclipse.swt.widgets; >@@ -104,12 +105,122 @@ > if( string == null ) { > SWT.error( SWT.ERROR_NULL_ARGUMENT ); > } >- if( !string.equals( text ) ) { >- displayText = parse( string ); >- text = string; >+ >+ String escaped_input =escape_html(string); >+ >+ if( !escaped_input.equals( text ) ) { >+ displayText = parse( escaped_input ); >+ text = escaped_input; > } > } > >+ >+ private String escape_html(String input) { >+ >+ StringBuffer escaped_input = new StringBuffer(input.length()); >+ >+ int state = 0; >+ >+ //copy inpout String into a tab of chars >+ char input_chars[] = new char[input.length()]; >+ input.getChars(0, input.length(), input_chars, 0); >+ >+ for (int i=0; i<input_chars.length ; i++) { >+ >+ switch(state) >+ { >+ >+ case 0 : >+ if (input_chars[i]=='<') { >+ state = 1; >+ } else { >+ escaped_input.append(input_chars[i]); >+ } >+ break; >+ >+ case 1 : >+ if (input_chars[i]=='a') { >+ state = 2; >+ } else if (input_chars[i]=='/'){ >+ state = 3; >+ } else { >+ escaped_input.append("<"); >+ escaped_input.append(input_chars[i]); >+ state = 5; >+ } >+ break; >+ >+ case 2 : >+ if (input_chars[i]=='>' || input_chars[i]=='>') { >+ escaped_input.append('<'); >+ state = 0; >+ } else { >+ escaped_input.append("<"); >+ state = 5; >+ } >+ escaped_input.append('a'); >+ escaped_input.append(input_chars[i]); >+ break; >+ >+ >+ case 3 : >+ if (input_chars[i]=='a') { >+ state = 4; >+ } else { >+ escaped_input.append("</"); >+ escaped_input.append(input_chars[i]); >+ state = 5; >+ } >+ break; >+ >+ case 4 : >+ if (input_chars[i]=='>') { >+ escaped_input.append('<'); >+ state = 0; >+ } else { >+ escaped_input.append("<"); >+ state = 5; >+ } >+ escaped_input.append("/a"); >+ escaped_input.append(input_chars[i]); >+ break; >+ >+ case 5 : >+ if (input_chars[i]=='<') { >+ escaped_input.append("<"); >+ } else if (input_chars[i]=='>') { >+ escaped_input.append(">"); >+ state = 0; >+ } else { >+ escaped_input.append(input_chars[i]); >+ } >+ break; >+ } >+ } >+ >+ switch(state) { >+ case 0: >+ break; >+ case 1: >+ escaped_input.append("<"); >+ break; >+ case 2: >+ escaped_input.append("<a"); >+ break; >+ case 3: >+ escaped_input.append("</"); >+ break; >+ case 4: >+ escaped_input.append("</a"); >+ break; >+ case 5: >+ break; >+ } >+ >+ return escaped_input.toString(); >+ } >+ >+ > /** > * Returns the receiver's text, which will be an empty > * string if it has never been set.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 200389
:
77526
|
77755
|
78497