-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add update hook to update .htaccess in files directory on existing sites #19
base: 6.x
Are you sure you want to change the base?
Conversation
99% sure nobody customizes this .htaccess file BUT if we want to be 100% sure we could do the following safer procedure:
Sounds like a plan? PS. If file.inc does not define file_htaccess_lines() right from the start and that function - to put the htaccess file in place - was done in some other way - we need to further analyze. If it was done in the same way all the time - we're fine. Finally if file_htaccess_lines() func did not exist and then appeared - we're still fine. Don't know if I'm making sense - but the overall idea is to take al possible .htaccess contents that drupal ever defined and consider those known good .htaccesses that are safe to overwrite if we got them still present on our site... by the way if we're lucky the md5sum might be just ONE. |
okay using git log + git show and a bit of manual search and replace I managed to isolate ALL possible htaccess file contents provided by D6 at any momment in time. What I did:
// c - commit hash git log --follow --oneline -- "includes/file.inc" | awk '{print $1}' | while read c; do f= it's slow inefficient maybe but runs in a second and gets the job done.
Then I found that before that function htaccess contents were written from within/by a function named file_check_directory() towards the end - where the htaccess string was hardcoded. rinse and repeat pumping F3 for .htaccess, until there's nothing left. |
finally here's the end result with all variants of htaccess file's contents we can safely overwrite: |
next step is to either put those as values in a PHP array or generate the hashes of the variants and use those in the update hook... There are 6 variants. When diffing we must take into account possible empty lines in the start/end of the diff src and dest, so we must either diff as text after trimming both src and dest... or generate like 2N md5sums for each variant where N = number of empty lines added to start/end... I hope the idea is clear and the heavy lifting was to extract the htaccess variants as they were in different flavours and functions. |
Thanks for all your work on this!
I wonder if the |
This is to fix #16
I'm a little unsure about this. I've never customized the .htaccess file in the files directory, but I wonder if others might have? I don't want to wipe out their changes, but I don't want to leave sites on PHP vulnerable to attack.