Fix Explore>Map description showing raw HTML tags#6595
Fix Explore>Map description showing raw HTML tags#6595Salehcodes wants to merge 6 commits intocommons-app:mainfrom
Conversation
|
Thanks @Salehcodes for your contribution. I'm not sure if users really pass HTML tags in these fields. There are some existing issues with more context around this. Could you please check those and see if this PR handles those use cases? |
|
Thanks a lot for your feedback :) |
|
One that was fixed recently for the author field: #5030. It's not a natural for a user to use tags, but since you're saying our codebase is inconsistent, I'll take a look at those areas and get back to you. Would you recommend having these checks for every edit text field within the codebase? |
|
Thank you, yes i think its very good idea as by checking we make sure nothing like this happens again in any field. |
|
In #5030 I worked with rendered HTML with no wiki code. Still, I think different text fields can have different expectations:
|
|
Thank you @whym for your inputs! My only point here is that we need to understand if this is happening due to some glitch or we're just dealing with user input. If it's the latter, then we need not solve for it. Users can even decide to use asterisks for bold, underscores for italic, etc. which isn't HTML but a common behaviour on chat applications. And if not, then your first point about file content retrieval would help. @Salehcodes could you please confirm the use case once and possibly share a screen cast too for the inconsistencies you were referring to? |
Screen_Recording_20260103_124428_Commons.mp4As you can see here the description before pressing details button included raw html tags eg. Ps. I did not upload this image this is real user image and input which I noticed that a lot of them in my area use html tags idk why. |
|
(This may be already obvious, but just to make it clear) I think it's reasonable to expect rendering similar to the website version (around "Description: In Nazareth" for example). In this case the syntax mentioned here seems to be part of MediaWiki's limited HTML that is rendered accordingly on the website. The file page has the Israeli Pikiwiki project tag saying "This file has been submitted through the Israeli Pikiwiki project and uploaded here automatically". The automatic process might have contained rather rare (but still valid) syntax. |
|
@Salehcodes did you get a chance to check this: #6595 (comment)? |
|
I will look into this asap> @Salehcodes did you get a chance to check this: #6595 (comment)? |
|
@RitikaPahwa4444 I looked into this and I found out that the square comes from MediaWiki UI i added to the code the stripping of screen recording : before.mp4after: after.mp4 |
|
Can we have unit tests for this (what is to be parsed, ignored, left alone, etc)? One way to make it easier to test might be to refactor the conversion code added/modified here into a method. This might be useful as a reference: |
|
@whym Thanks for the suggestion I’ve updated the PR accordingly. I also added a unit test (StringUtilImgTagTest) that verifies |
|
✅ Generated APK variants! |
|
Should that HTML be shown as a link? |
|
I started looking into what we could do to make the HTML like this more machine friendly at Commons Village Pump/Technical. (I just wanted to share the information. The best case scenario is that we will be able to use the "noprint" class to approximate (most) elements to be hidden, but there is nothing actionable yet and things could be messier than I hope, and I don't have a time frame to solve it on the Commons website side.) @nicolas-raoul: do you mean this part? |
|
@whym Yes. Understood, thanks for deep-diving on this! 🙂 |
|
HTML now has now changed and the icon image is surrounded by a I think it's safer to create a new HTML function with this removal feature, and leave the existing one unchanged. We don't know if all other usage of the function is compatible with the change. (At least I haven't checked.) A different example: https://commons.wikimedia.org/wiki/File:St_Peter,_Bounces_Road,_Edmonton_-_geograph.org.uk_-_3802520.jpg |


Description (required)
Fixes #6594
The description text shown in the Explore>map bottom sheet previously displayed raw HTML tags such as
<br>and<b>, instead of rendering formatting. This reduced readability and made the UI appear visually broken.This PR updates the description binding in
ExploreMapFragment.passInfoToSheet()to use:HtmlCompat.fromHtml(descriptionText, HtmlCompat.FROM_HTML_MODE_LEGACY)
This allows HTML to be rendered as styled text (e.g., bold and line breaks), matching the formatting already used in the Details screen.
Tests performed (required)
Tested on:
Build variant: betaDebug
Device: Samsung Galaxy S23
Android version: Android 16 (API level 35)
Steps:
Opened Explore → Map
Selected a nearby marker and tapped the bottom info banner
Verified that HTML is properly rendered:
<b>→ bold text<br>→ correct line breakNo visible raw HTML tags
Uploaded a test image to Beta Commons to ensure environment functionality
Test upload URL:
https://commons.wikimedia.beta.wmflabs.org/wiki/File%3ATest_html_tags.jpg
Screenshots (for UI changes only)