Skip to content

JSon response not detected with header containing utf8#39

Merged
richard67 merged 5 commits into
joomla-framework:4.x-devfrom
JLTRY:4.x-dev
Apr 15, 2026
Merged

JSon response not detected with header containing utf8#39
richard67 merged 5 commits into
joomla-framework:4.x-devfrom
JLTRY:4.x-dev

Conversation

@JLTRY

@JLTRY JLTRY commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

case of header =
Array
(
[0] => application/json; charset=utf-8
)
correct phpstan

Pull Request for Issue #19

Summary of Changes

accept application/json; charset=utf-8 in header

Testing Instructions

checked with extension for Google authentification
https://extensions.joomla.org/extension/access-a-security/jo-s-google-auth/

Documentation Changes Required

no

case of header =
Array
(
    [0] => application/json; charset=utf-8
)
correct phpstan
@JLTRY

JLTRY commented Jan 5, 2026

Copy link
Copy Markdown
Contributor Author

@rdeutz @richard67 @LadySolveig I need this pull request to be able to run correctly my google auth extension
https://extensions.joomla.org/extension/access-a-security/jo-s-google-auth/
PErhaps is it due to french site and google providing an "application/json; charset=utf-8" in response header

Comment thread src/Client.php Outdated
@HLeithner

Copy link
Copy Markdown

Somethings are wrong here.

getHeader() is case insensitive, so the loop is not needed, also strpos is pre php 8.0, use str_starts_with instead.

my suggestion:
change

if (in_array('application/json', $response->getHeader('Content-Type'))) {

to

if (str_starts_with('application/json', strtolower($response->getHeader('Content-Type')[0]))) {

but that's not really correct, you should iterate over the getHeader() result array an check each row, as done in the original if statement.

do not use strpos use str_starts_with instead.
getHeader() is case insensitive
@JLTRY

JLTRY commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

@HLeithner I modified the code following your directives
I tested it OK with my component

@JLTRY JLTRY changed the title JSon response not detected JSon response not detected with header containing utf8 Jan 14, 2026
@JLTRY JLTRY requested a review from rdeutz January 14, 2026 14:45
@JLTRY

JLTRY commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

@HLeithner Can you lease review the code . I tested it OK with my component + with Strava authentification

@JLTRY

JLTRY commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

Pull request is approved . It should be merged

@richard67 richard67 merged commit bb24c0a into joomla-framework:4.x-dev Apr 15, 2026
@richard67

Copy link
Copy Markdown
Contributor

Thanks. We will create a new bug fix release 4.0.2 in the next days or few weeks.

@richard67

Copy link
Copy Markdown
Contributor

@JLTRY Does your extension also work on Joomla 6.1? I'm asking because I will prepare the PRs for the CMS (5.4-dev and 6.1-dev) to update to the new versions of this framework package which include your fix (3.0.3 for Joomla 5.4 and 4.0.2 for Joomla 6.x), and I am looking for testing instructions for human testers.

@JLTRY

JLTRY commented Apr 20, 2026

Copy link
Copy Markdown
Contributor Author

Yes my extension works with joomla 6.10 .You just need to have Google credentials and indicate them in my extension 's parameters. I will update the documentation
@richard67 => done https://joomla.jltryoen.fr/en/extensions-joomla/composants/294-jos-google-auth-en

@richard67

Copy link
Copy Markdown
Contributor

@JLTRY Measnwhile I have the 2 PRs ready for fetching the change into the CMS, one for the 5.4-dev and one for the 6.1-dev branch. Could could help with testing as each PR needs 2 successful human tests for getting accepted.

Thanks in advance, and thanks again for the fix.

@JLTRY

JLTRY commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

@richard67 at least I have tested the modification for joomla 6.10

Unfortunetly I do not have such details as administrator/logs/plg_system_sismosexampleoauth2.php
The only verification I can have is that user is connected
and in traces
com_jogoogleauth.php

Is it OK for you
I can provide Screenshots and this description
@richard67 Let me know where to put them

For joomla 5.X I have installed a new test site for that and need to configure Google credentials

@richard67

Copy link
Copy Markdown
Contributor

@JLTRY If that means a successful test, i.e. verified that it does not work without the fix, and that it works with the fix, you can submit your test result in the issue tracker:

There you can use the blue "Test this" button at the top left corner, select your test result (hopefully success) below that button, then maybe enter a comment in the big text field at the bottom telling that you have used your extension for testing, and then finally submit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants