1. qualyzer
  2. main

Commits

prmr  committed 992d504

refs #123 Fixed the bug.

  • Participants
  • Parent commits 3d616db
  • Branches default

Comments (0)

Files changed (1)

File ca.mcgill.cs.swevo.qualyzer/src/ca/mcgill/cs/swevo/qualyzer/editors/pages/CodeFragmentViewerPage.java

View file
  *
  * Contributors:
  *     Jonathan Faubert
- *     Martin Robillard
  *******************************************************************************/
 /**
  * 
 import java.util.ArrayList;
 import java.util.Collections;
 
-import org.apache.commons.lang.StringEscapeUtils;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
  */
 public class CodeFragmentViewerPage extends FormPage implements ProjectListener, CodeListener
 {
+	
+	private static final String GREATER_CODE = ">"; //$NON-NLS-1$
+	private static final String GREATER = ">"; //$NON-NLS-1$
+	private static final String LESS_CODE = "<"; //$NON-NLS-1$
+	private static final String LESS = "<"; //$NON-NLS-1$
+	private static final String AMP = "&";
+	private static final String AMP_CODE = "&amp;";
 	private static final String VIEW_FRAGMENTS = Messages.getString(
 			"editors.pages.CodeFragmentViewerPage.viewFragments"); //$NON-NLS-1$
 	private Code fCode;
 	}
 
 	/**
-	 * Creates the form text representing one fragment. 
-	 * Sets the fragment text itself as a hyperlink to the document.
+	 * Creates the form text representing one fragment. Sets the fragment text itself as a hyperlink to the document.
 	 * @param sectionClient
 	 * @param text
 	 * @param fragment
 		int fragStart = fragment.getOffset() - start;
 		int fragEnd = fragStart + fragment.getLength();
 		
-		builder.append(StringEscapeUtils.escapeHtml(fragText.substring(0, fragStart)));
+		/* 
+		 * Note that general escaping methods such as StringEscapeUtils.escapeHtml should
+		 * note be used here because the FormText widget does not support all HTML escaped
+		 * codes, only the ones used here. See the documentation for FormText.
+		 */
+		String temp = fragText.substring(0, fragStart).replace(LESS, LESS_CODE);
+		temp = temp.replace(AMP, AMP_CODE);
+		builder.append(temp.replace(GREATER, GREATER_CODE));
 		
 		builder.append(FormTextConstants.LINK_START_HEAD + FormTextConstants.LINK_START_TAIL);
-		builder.append(StringEscapeUtils.escapeHtml(fragText.substring(fragStart, fragEnd)));
+		temp = fragText.substring(fragStart, fragEnd).replace(LESS, LESS_CODE);
+		temp = temp.replace(AMP, AMP_CODE);
+		builder.append(temp.replace(GREATER, GREATER_CODE));
 		builder.append(FormTextConstants.LINK_END); 
 		
-		builder.append(StringEscapeUtils.escapeHtml(fragText.substring(fragEnd, fragText.length())));
+		temp = fragText.substring(fragEnd, fragText.length()).replace(LESS, LESS_CODE);
+		temp = temp.replace(AMP, AMP_CODE);
+		builder.append(temp.replace(GREATER, GREATER_CODE));
 		
 		builder.append(FormTextConstants.PARAGRAPH_END); 
 		builder.append(FormTextConstants.FORM_END);