Navigation Menu

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

PHP Notice: Undefined index: HTTP_HOST #10973

Closed
wants to merge 3 commits into from

Conversation

demis-palma
Copy link
Contributor

@demis-palma demis-palma commented Jun 29, 2016

Summary of Changes

The current code relies on the presence of the super-global variable HTTP_HOST, which is not always set.
In case of HTTP 1.0 requests, HTTP_HOST is not set. This causes a series of PHP notices:

Undefined index: HTTP_HOST in [...]/libraries/joomla/application/web.php on line 867
Undefined index: HTTP_HOST in [...]/libraries/joomla/uri/uri.php on line 85
Undefined index: HTTP_HOST in [...]/modules/mod_wrapper/helper.php on line 48

Testing Instructions

  1. Force your browser to use HTTP protocol 1.0 instead of 1.1, or simply telnet to your testing web server to the port 80
    telnet localhost 80
    and ask for the user reminder form using HTTP 1.0 protocol:
    GET index.php?option=com_users&view=remind HTTP/1.0 (Don't forget to press enter twice after this command.)
  2. Check the error log of your web server for the PHP notices mentioned above.

In case you have PHP DISPLAY ERROR active, the PHP notices will be present in the HTML output in addition to the web server log, but it's hard to find them by eye within the whole HTML code received in the telnet console.

@demis-palma
Copy link
Contributor Author

It seems that the tests rely on the presence of the super-global variable HTTP_HOST too.

@ggppdk
Copy link
Contributor

ggppdk commented Jun 30, 2016

@demis-palma

You code does not seem account for the port number from the case that SERVER_NAME is used and port != 80

[EDIT]
i have to check this

@piotr-cz
Copy link
Contributor

As far as I remember the HTTP_HOST includes a port if it's other than 80.
On the other side, SERVER_NAME never includes a port

@demis-palma
Copy link
Contributor Author

Since the automatic tests are clearly crafted on the current behaviour of the program (which works perfectly with HTTP 1.1, but not with HTTP 1.0),
I've limited the fix only to the prevention of the PHP notice, and leave the programs behaves exactly as it did before.
This is achieved using input->get() instead of accessing super global variables directly, which is always a good practice.

Preventing PHP notices is important to avoid path information discosure on servers configured to display notices in the HTML output.

@demis-palma
Copy link
Contributor Author

It still fails. I have to debug the unit tests as well. 💩 !

@demis-palma
Copy link
Contributor Author

demis-palma commented Jun 30, 2016

The test JApplicationWebTest::testDetectRequestUri should be rewritten. It makes direct use of super-globals instead of JInput object, and assumes that the functions tested do the same.

So, to summarise: this patch fixes the PHP notice mentioned at the top, and nothing more.

@Quy
Copy link
Contributor

Quy commented Aug 21, 2017

This can be closed because of PR #17655 .

@joomla-cms-bot
Copy link

Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/10973

@ghost
Copy link

ghost commented Aug 21, 2017

closed as stated above.


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

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.

None yet

5 participants