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

[ticket/11215] Correct paths when path info is used for controller access #1102

Merged
merged 24 commits into from
Sep 2, 2013

Conversation

imkingdavid
Copy link
Contributor

$server_parameters['REQUEST_URI'] = $request_uri . $path_info;
$server_parameters['SCRIPT_NAME'] = '';
$path = '';
for ($i = 0; $i < $corrections; $i++)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str_repeat() ?

@imkingdavid imkingdavid reopened this Nov 20, 2012
@imkingdavid
Copy link
Contributor Author

Accidentally closed it, it's still open.

@imkingdavid
Copy link
Contributor Author

@igorw @p @naderman
This patch adds a function that calculates the relative path from the given URL to the board web root. That path is then prepended to all template root path variables in page_header() as well as all links generated by append_sid().

This is perhaps not the most elegant solution, but it is the best I could come up with, and I have tested it and it works. If anyone has any suggestions for something else, let me know; otherwise, this can be merged so that controllers can return to using path_info instead of the query string.

return $path;
}

$corrections = substr_count($path_info, '/');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about http://localhost/phpBB/./././?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any number of /././././... is automatically removed by the browser. At least, it is for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I just noticed this function https://github.com/phpbb/phpbb3/blob/develop/phpBB/includes/functions.php#L1055 which can be used to clean the path if needed.

@p
Copy link
Contributor

p commented Nov 26, 2012

Since I have not seen an explanation for how you arrived at this solution:

  1. Research which environment variables php uses and passes to the userland. In case of an apache module, php does not use environment variables on input but uses apache apis to take the request apart. In case of cgi/fastcgi, php uses environment variables in particular path_info/script_uri/script_name. Then, php passes some/all of path_info/script_uri/script_name to the userland, regardless of sapi being used.
  2. php knows which part of the uri requested is for the physical filename and which part is for the "virtual path". It has to in order to output said filename to the browser. Research this for all sapis. You'll have to read php source as I don't think this is completely documented in user documentation.
  3. Create a table of all environment variables that are passed by php to userland with what is in them (physical path/virtual path/nothing), for each sapi.

Then we can start to think about how a valid solution might be implemented.

@imkingdavid
Copy link
Contributor Author

@p @igorw @naderman To bump this, I understand that this is not the most elegant solution. I'm just highly doubtful that we will find a very good solution that isn't going to completely redesign how we handle pathing.

I have yet to find any issues with this patch, and am willing to work further on making it better, but I don't have the time or interest to go as in depth as was described in the previous comment. If someone would like to provide a better solution, they are welcome to. Until then, I'm convinced that a hacky solution is what we're going to have to live with for the time being. I would much rather have a hacky solution that works for 3.1 than wait until 4.0 to get better paths.

@p
Copy link
Contributor

p commented Feb 27, 2013

Can you write tests for apache/mod_php, cgi and fastcgi that cover the functionality being discussed here?

@imkingdavid
Copy link
Contributor Author

@p How do I specify certain tests for certain servers?

@p
Copy link
Contributor

p commented Feb 28, 2013

I do not think this is covered by phpbb tests so you would need to implement it.

@p
Copy link
Contributor

p commented Mar 3, 2013

Implementing these tests in wolis should be straightforward (but not trivial, it will still take some effort). If you want to pursue this option I can help you with it.

@imkingdavid
Copy link
Contributor Author

I have very little familiarity with python, but am definitely willing to learn to use it if you don't mind helping me some. I'll take a look at wolis and we can go from there.

@imkingdavid
Copy link
Contributor Author

@p To bump this, I did find this function http://php.net/manual/en/function.php-sapi-name.php that might come in handy. I don't think I understand how tests on different sapi's would differ, though.

@p
Copy link
Contributor

p commented Apr 19, 2013

http environment variables may be set differently.

When Symfony Request calculates path info, both of the following URLs give "/"
as the path info: ./app.php and ./app.php/
This commit ensures that the proper correction is made.

PHPBB3-11215
* develop: (176 commits)
  [feature/bootstrap-dic] Bootstrap container from config.php
  [ticket/11548] Use new static methods for request and submit
  [ticket/10772] Updating tests
  [ticket/10772] Remove 3.1 code
  [ticket/11388] Add newlines at EOF
  [ticket/11388] INCLUDECSS
  [ticket/11548] Run array_map on complete error array and not just colour_error
  [ticket/11644] Skip phpbb_dbal_order_lower_test on MySQL 5.6
  [ticket/11388] Do not append assets_version if using remote path (e.g. http)
  [ticket/11388] Fix typo
  [ticket/11388] Remove typehints (causing tests to fail)
  [ticket/11388] Disable cache if IN_INSTALL defined
  [ticket/11388] Do not modify by reference
  [ticket/11388] typehits
  [ticket/11388] INCLUDEJS test for //(url)
  [ticket/11388] INCLUDEJS supports //(url)
  [ticket/11388] Fixing includejs test
  [ticket/11388] includejs inherit from includeasset
  [feature/twig] Unit tests for includejs
  [ticket/8319] Add migration file for update change
  ...
* develop: (53 commits)
  [ticket/11671] Update composer.lock
  [ticket/11671] Update composer.lock
  [ticket/11671] Add phing as a dependency and upgrade deps
  [ticket/11668] Move lint test to the end for travis
  [ticket/11626] Remove last reference to template in ldap
  [ticket/11626] Remove LDAP dependency on template
  [develop-olympus] Increment version number to 3.0.13-dev.
  [develop-olympus] Add changelog for 3.0.12 release.
  [develop-olympus] Bump version numbers for 3.0.12-RC1 release.
  [develop-olympus] Bumping version numbers to final for 3.0.12 releases.
  [ticket/11669] Fix PHP bug #55124 (recursive mkdir on /./)
  [ticket/11668] Run lint test at the end of the test suite
  [ticket/11548] Fix test errors in groups test on develop
  [ticket/11548] Check upload avatar URL the same way as in phpBB 3.0
  [ticket/11548] Fix incorrect usage of array_map on acp groups page
  [ticket/11665] Fix test class name
  [ticket/11664] Stop creating php.html file in root path in tests
  [ticket/11665] Can't change file names already sent to set_filenames
  [ticket/11662] Typos: occured -> occurred
  [ticket/11662] Typos: occured -> occurred
  ...
* develop:
  [ticket/11647] Always use &amp; for URLs
  [ticket/11647] Allow custom ports
  [ticket/11647] Use $config for assets_version
  [ticket/11647] Fix invalid variable name
  [ticket/11647] New assets handling
  [ticket/11647] Fix tests for INCLUDEJS
* develop: (214 commits)
  [ticket/10999] Fix assets_version in ACP
  [prep-release-3.0.12] More changelog items for the 3.0.12 release.
  [ticket/11687] Add assets_version to phpbb_config
  [ticket/11670] Consistency with logo: Replace "phpBB(tm)" with "phpBB(R)".
  [ticket/11674] Do not include vendor folder if there are no dependencies.
  [ticket/11685] Remove logout confirmation page
  [ticket/11684] Remove useless confirmation page after login and admin login
  [ticket/9657] Define user before injecting
  [ticket/9657] Remove old code
  [ticket/9657] Keep approval state of posts/topics when copying them
  [ticket/9657] Add functional tests for forking a copy
  [ticket/9657] Add functional test for splitting topic
  [ticket/11112] Do not change opensource.org link to https
  [ticket/9657] Add functional test for restoring a post/topic
  [ticket/11112] Use https for user-visible links to phpbb.com
  [ticket/9657] Fix a little error when moving softdeleted topics
  [ticket/9657] Add unit tests for softdeleting and moving posts/topics
  [ticket/9657] Remove last references to m_restore permission
  [ticket/9657] Fix english language :(
  [ticket/9657] Notifications do not require emails or jabber anymore
  ...
* develop:
  [ticket/11675] Fix template loop
  [ticket/11690] Old module class names may get autoloaded by class_exists
  [ticket/9649] Display information on index for moderators on unapproved posts
  [ticket/11686] Not checking for phpBB Debug errors on functional tests
  [ticket/11553] Typo
  [ticket/11553] Replace bullet with unicode
  [ticket/11553] Move bulletin points to pseudo class
  [ticket/11600] Remove duplicate test case
  [ticket/11600] Use lowercase null and remove duplicate test cases
  [ticket/11600] Use local variable for $user in test_localize_errors
  [ŧicket/11600] Split get driver tests into tests for all and only enabled ones
  [ticket/11600] Increase code test coverage of avatar manager
* develop:
  [ticket/11694] Do not locate assets with root path
@@ -1,12 +1,34 @@
<IfModule mod_rewrite.c>
#
# Uncomment the following line if you will be using any of the URL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment no longer necessary

@EXreaction
Copy link
Contributor

Looks good to me

EXreaction added a commit that referenced this pull request Sep 2, 2013
[ticket/11215] Correct paths when path info is used for controller access
@EXreaction EXreaction merged commit 4fd99a7 into phpbb:develop Sep 2, 2013
@nickvergessen
Copy link
Contributor

I'm missing tests for app.php ?

It still needs to generate such URLs?

@EXreaction
Copy link
Contributor

What tests are you missing and what URLs are you talking about?

@nickvergessen
Copy link
Contributor

urls with app.php?controller= when the php module is disabled?

@EXreaction
Copy link
Contributor

I'm assuming you mean with the apache module mod-rewrite? The urls are now phpbb.com/app.php/some/path when the rewriting is disabled. Mod rewrite isn't required for this functionality.

Urls using rewriting will be phpbb.com/some/path

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.

5 participants