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

Icon::get() injection leads to HTML Output #6952

Closed
ArchBlood opened this issue Apr 15, 2024 · 7 comments · Fixed by #6955
Closed

Icon::get() injection leads to HTML Output #6952

ArchBlood opened this issue Apr 15, 2024 · 7 comments · Fixed by #6955

Comments

@ArchBlood
Copy link
Contributor

What steps will reproduce the problem?

Currently I'm facing some issues when trying to inject the Icon::get() method for icons through the Verified module, we use the Icon class for the icons within our widget class VerifiedIcon this works with the method of extending an existing widget class through EVENT_CREATE but this also requires us to also extend the existing view as well, I've currently gotten an example of our module to implement this through EVENT_BEFORE_RUN but the issue is that the Icon::get() function won't allow the use case we need.

What is the expected result?

The Icon::get() method should allow to be rendered correctly.

What do you get instead?

HTML output is displayed <i class="fa fa-check-circle tt" title="Verified" aria-hidden="true" role="img" style="color: #458e56;"></i><span class="sr-only">Verified</span>

Additional info

I've tried everything from encoding to decoding even tried multiple hack-ish methods without any ability to use the Icon:get() method in a way so that we don't need to rely on core view manipulation through EVENT_CREATE.

Q A
HumHub version 1.16.0-beta.2
PHP version 8.1.18
Operating system CloudLinux

Note: Also provide the full error stacks from Administration --> Information --> Logging and errors from your browser console if possible.
Note: Please use the community site for any questions on customizing HumHub.

@ArchBlood
Copy link
Contributor Author

ArchBlood commented Apr 15, 2024

For better understanding of what I mean here's the screenshot of how it's rendered;

As you'll see it's injected correctly but the output is returned as HTML due to Icon::get()

User Profile

Screenshot_1

Space

Screenshot_2

@ArchBlood
Copy link
Contributor Author

A simple solution would be removing Html::encode() from the view file, I don't really see any need for it anymore but if the HumHub staff still think it's needed we'll have to find another possible solution which requires looking into the Icon::get() method.

<h1 class="<?= $classPrefix ?>"><?= Button::asLink(Html::encode($title))->link($container->getUrl()) ?></h1>

@yurabakhtin
Copy link
Contributor

@ArchBlood I think the Html::encode() is used there in order to avoid js script like this:

alert

@felixhahnweilheim
Copy link
Contributor

Yes, but it could be moved from the view file into the widget class (init() function) where $title is defined.

@yurabakhtin yurabakhtin linked a pull request Apr 19, 2024 that will close this issue
4 tasks
@yurabakhtin
Copy link
Contributor

@felixhahnweilheim Yes, you are right, I have done this in the PR #6955.
@ArchBlood After the PR you can append an icon to a title in the event EVENT_BEFORE_RUN.
@luke- Please merge it.

@yurabakhtin yurabakhtin self-assigned this Apr 19, 2024
@ArchBlood
Copy link
Contributor Author

@felixhahnweilheim Yes, you are right, I have done this in the PR #6955. @ArchBlood After the PR you can append an icon to a title in the event EVENT_BEFORE_RUN. @luke- Please merge it.

Works very well for the needed use case.

@luke-
Copy link
Contributor

luke- commented Apr 19, 2024

PR is mreged.

@luke- luke- closed this as completed Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants