HTMLSerializer does not correctly detect and add # + subscribeId to hrefs/actions

Description

In uPortal 3.1 urls are not correctly written with '#' + subscribeId
I found the problem in HTMLSerializer.appendAnchorIfNecessary()

The algorithm searches for ".render." but urls look like: /render.userLayoutRootNode.target.u34l1n9.uP in our instance. We're running under the ROOT context. I vaguely remember that it may have had uPortal.render.userLayoutRootNode before when under /uPortal context root.

I rewrote the method to look like this and verified that it works:

protected String appendAnchorIfNecessary(String elementName, String attributeName, String attributeValue) {
if (anchorId != null) {
// looking for an <a> or <form> tag element
if (elementName.equalsIgnoreCase("a") || elementName.equalsIgnoreCase("form")) {
// found an <a> or <form>, let's peek at the attributes it contains
// does it contain either an "href" or "action" attribute
if (attributeName.equalsIgnoreCase("href") || attributeName.equalsIgnoreCase("action")) {
// found the attribute, now lets make sure it points back to a channel
// check for an existing anchor ..
// check that it doesn't contain # or javascript:
/*

  • Arlo's Notes:

  • used to be ".render." but didn't work.

  • Changed to "render.userLayoutRootNode.target" to be more specific.
    */
    if (attributeValue.indexOf("render.userLayoutRootNode.target.") != -1
    && attributeValue.indexOf("#") == -1
    && attributeValue.indexOf("javascript:") == -1){
    // this link points back to a channel, so let's
    // rewrite it and place back into the Attribute Object
    attributeValue += "#" + anchorId;
    }
    }
    }
    }
    return attributeValue;
    }

Environment

Linux, Tomcat 6, uPortal 3.1

Activity

Show:
Arlo White
December 11, 2008, 12:51 AM

Patch to resolve bug.

I've tested this patch and verified it works correctly. Note: I removed the overridden function in HTMLSerializer as the functionality in BaseMarkupSerializer is the same and there's no reason to duplicate code.

Eric Dalquist
February 3, 2009, 9:07 PM

Resolved by fix of linked duplicate issue

Duplicate

Assignee

Unassigned

Reporter

Arlo White

Labels

None

Estimated End Date

None

Components

Fix versions

Affects versions

Priority

Major