Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG12TextElementBridge performs cast without instanceof #3

Closed
ghost opened this issue Mar 25, 2021 · 1 comment
Closed

SVG12TextElementBridge performs cast without instanceof #3

ghost opened this issue Mar 25, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Mar 25, 2021

Re: https://issues.apache.org/jira/browse/BATIK-1302

@carlosame notes:

The proper fix would be a major refactor: the code is asking for it, especially the CSSOM part (already did a small one there, but far from enough). Meanwhile a smaller fix would be of help.

The smaller, simple fix in the interim is to add an instanceof check to In SVG12TextElementBridge, around line 67, like:

if( ctx instanceof SVG12BridgeContext ) {
   ctx12 = (SVG12BridgeContext) ctx;
}
@carlosame
Copy link
Member

I'm thinking of something like this:

@@ -54,10 +54,16 @@ public class SVG12TextElementBridge extends SVGTextElementBridge implements SVG1
 	/**
 	 * Adds the DOM listeners for this text bridge.
 	 */
 	@Override
 	protected void addTextEventListeners(BridgeContext ctx, NodeEventTarget e) {
+		if (!(ctx instanceof SVG12BridgeContext)) {
+			// SVG 1.2 text element inside 1.1 document
+			super.addTextEventListeners(ctx, e);
+			return;
+		}
+
 		if (childNodeRemovedEventListener == null) {
 			childNodeRemovedEventListener = new DOMChildNodeRemovedEventListener();
 		}
 		if (subtreeModifiedEventListener == null) {
 			subtreeModifiedEventListener = new DOMSubtreeModifiedEventListener();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant