Bug 521493 - Escape ampersand characters in tagged text
Change-Id: I48a47f088445dbfbfb6f316a44d36d5acaf225db
Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java
index 7c49c94..b86096f 100644
--- a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java
+++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Ralf M Petter<ralf.petter@gmail.com> - Bug 259846
+ * Karsten Thoms<karsten.thoms@itemis.de> - Bug 521493
*******************************************************************************/
package org.eclipse.ui.internal.forms.widgets;
@@ -109,6 +110,7 @@
reset();
return;
}
+ taggedText = taggedText.replace("&", "&"); //$NON-NLS-1$//$NON-NLS-2$
InputStream stream = new ByteArrayInputStream(taggedText.getBytes(StandardCharsets.UTF_8));
parseInputStream(stream, expandURLs);
}
diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTextModelTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTextModelTest.java
index 2429a8d..98a35b8 100644
--- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTextModelTest.java
+++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/FormTextModelTest.java
@@ -37,4 +37,13 @@
assertEquals("FormTextModel does not preserve whitespace correctly according to the rules",
" line with whitespace Test " + System.lineSeparator(), formTextModel.getAccessibleText());
}
+
+ @Test
+ public void testTextWithAmpersand() {
+ FormTextModel formTextModel = new FormTextModel();
+ formTextModel.parseTaggedText("<form>Foo &Bar</form>", false);
+ assertEquals("Foo &Bar" + System.lineSeparator(),
+ formTextModel.getAccessibleText());
+ }
+
}