Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-61068

If a plugin implements AssetRendererFactory.getClassTypes the Asset Publisher configuration breaks

    Details

    • Fix Priority:
      3

      Description

      If a portlet in a plugin specifies an AssetRendererFactory implementation that implements getClassTypes(long[], Locale) the Asset Publisher configuration doesn't work anymore.

      This happens because in AssetPublisherImpl.getClassName(AssetRendererFactory) we retrieve the "human class name" of a factory by doing .getClass().getName() and splitting for "." and using the last part. When called on elements that come from other contexts returns something in the form "it.smc.SomeAssetRendererFactory.$Proxy987", and "$Proxy987" as a result of "humanization".

      This would not be a problem if this value wasn't used as part of composed DOM ids in the multi-level className/classType selection of the dynamic configuration of the Asset Publisher.
      The script then tries to do A.one('#something<%= className %>'), but while special characters are valid DOM id characters, they are not valid selector characters un-escaped.

      There are a lot of possible solutions to this:

      • stop using Java class names or part of those as DOM ids;
      • (preferred by reporter) change AssetPublisherImpl.getClassName so it acknowledges Class Loader proxies;
      • escape className replacing invalid characters in their textual representation (from $ to DOLLAR);
      • escape selectors so that A.one('#a$b$c') becomes A.one('#a\\$b
        $c')
        ;
      • stop using A.one('#...') instead of the slightly faster A.one(document.getElementById('...')) that would have prevented this issue.

      STEPS TO REPRODUCE

      • Create a plugin with a custom entity
      • Define your own *AssetRenderer and *AssetRendererFactory for your entity
      • Implement *AssetRendererFactory.getClassTypes so that returns a non-empty Map of (even fictitious) class types
      • Create a page
      • Place the Asset Publisher
      • Configure it to filter only for one of your class types

      EXPECTED RESULT

      • The Asset Publisher correctly filters assets of the configured class type

      ACTUAL RESULT

      • The Asset Publisher configuration doesn't work at all, thus preventing the user from selecting any classType

        Attachments

          Activity

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                4 years, 7 weeks, 2 days ago

                Packages

                Version Package