Updates Requested bug PR-5.3-dev Pending

User tests: Successful: Unsuccessful:

avatar Attila-SWE
Attila-SWE
20 Dec 2024

My first PR so sorry if I messed something up. Please give me feedback then. Some considerations is that this only fixes images in images/ folder and does not fix other relative URL:s or such. Perhaps a broader fix is necessary?

Pull Request for Issue #44635.

Summary of Changes

Check to see if values in content history includes images with relative /images url

Testing Instructions

Open preview of content history with images in content with relative urls like images/test.png

Actual result BEFORE applying this Pull Request

Images broken because urls are relative to /administrator/ so for example DOMAIN/administrator/images/test.png

Expected result AFTER applying this Pull Request

Images shown and url of images is DOMAIN/images/test.png

Link to documentations

No documentation changes for docs.joomla.org needed
No documentation changes for manual.joomla.org needed

avatar Attila-SWE Attila-SWE - open - 20 Dec 2024
avatar Attila-SWE Attila-SWE - change - 20 Dec 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 20 Dec 2024
Category Administration com_content com_contenthistory
avatar Attila-SWE Attila-SWE - change - 20 Dec 2024
The description was changed
avatar Attila-SWE Attila-SWE - edited - 20 Dec 2024
avatar fgsw
fgsw - comment - 20 Dec 2024

@Attila-SWE Thanks for your first PR. Please close the issue.

I will test the PR but wan't to wait first if there is Feedback.

avatar Attila-SWE
Attila-SWE - comment - 20 Dec 2024

Done! So if I understand correctly then first create issue, then create pull request referring to issue and close issue? Is there any "documentation" for this regarding Joomla that I could read up on?

avatar fgsw
fgsw - comment - 20 Dec 2024

If you create a PR no Issue is needed.

I don't know about Documentation for this workflow.

avatar Attila-SWE Attila-SWE - change - 20 Dec 2024
Labels Added: PR-5.3-dev
avatar fgsw
fgsw - comment - 21 Dec 2024

@alikon Makes it sense to test the Pull Request as continuous-integration/drone/pr — Build is failing?

avatar alikon
alikon - comment - 21 Dec 2024

@fgsw drone is failing at Code style step

avatar Attila-SWE
Attila-SWE - comment - 21 Dec 2024

NP! Thanks for helping me learn

avatar fgsw fgsw - test_item - 23 Dec 2024 - Tested successfully
avatar fgsw
fgsw - comment - 23 Dec 2024

I have tested this item ✅ successfully on ecd0668

Untitled


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44645.
avatar chmst
chmst - comment - 25 Dec 2024

Thank you very much @Attila-SWE and congratulations to your first PR!

avatar alikon
alikon - comment - 31 Dec 2024

successfully tested by @Quy on ecd0668

avatar alikon alikon - alter_testresult - 31 Dec 2024 - Quy: Tested successfully
avatar alikon alikon - change - 31 Dec 2024
Status Pending Ready to Commit
avatar alikon
alikon - comment - 31 Dec 2024

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44645.

avatar Fedik Fedik - change - 31 Dec 2024
Status Ready to Commit Pending
avatar Fedik
Fedik - comment - 31 Dec 2024

Back to Pending status.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44645.

avatar Fedik
Fedik - comment - 31 Dec 2024

I am sorry, the changes will not going to work reliable. But thanks for your try.
You is assuming that all images are from images/ folder, however it not always true.

A solid fix going to be much more complex. It need something similar to what we have in SEF plugin

// Check for all unknown protocols (a protocol must contain at least one alphanumeric character followed by a ":").
$protocols = '[a-zA-Z0-9\-]+:';
$attributes = ['href=', 'src=', 'poster='];
foreach ($attributes as $attribute) {
if (strpos($buffer, $attribute) !== false) {
$regex = '#\s' . $attribute . '"(?!/|' . $protocols . '|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, ' ' . $attribute . '"' . $base . '$1"', $buffer);
$this->checkBuffer($buffer);
}
}
if (strpos($buffer, 'srcset=') !== false) {
$regex = '#\s+srcset="([^"]+)"#m';
$buffer = preg_replace_callback(
$regex,
function ($match) use ($base, $protocols) {
preg_match_all('#(?:[^\s]+)\s*(?:[\d\.]+[wx])?(?:\,\s*)?#i', $match[1], $matches);
foreach ($matches[0] as &$src) {
$src = preg_replace('#^(?!/|' . $protocols . '|\#|\')(.+)#', $base . '$1', $src);
}
return ' srcset="' . implode($matches[0]) . '"';
},
$buffer
);
$this->checkBuffer($buffer);
}

avatar Attila-SWE Attila-SWE - change - 9 Jan 2025
Labels Added: Updates Requested bug
avatar Attila-SWE
Attila-SWE - comment - 9 Jan 2025

New suggested solution.

avatar Fedik
Fedik - comment - 9 Jan 2025

Thanks. That looks much better. Still few things:

avatar Attila-SWE
Attila-SWE - comment - 9 Jan 2025

Should we also fix all relative 'href' or just 'src'?

avatar Fedik
Fedik - comment - 10 Jan 2025

If you like you can do for href also, sure.

Add a Comment

Login with GitHub to post a comment