Geshi/ExtEnscript: Treats file-extensions case-insensitively#201
Geshi/ExtEnscript: Treats file-extensions case-insensitively#201danielmarschall wants to merge 5 commits intowebsvnphp:masterfrom
Conversation
include/svnlook.php
Outdated
| foreach ($extGeshi as $language => $extensions) { | ||
| if (in_array($filename, $extensions) || in_array($ext, $extensions)) { | ||
| $extensions_lc = array_map('strtolower', $extensions); | ||
| if (in_array(strtolower($filename), $extensions_lc) || in_array(strtolower($ext), $extensions_lc)) { |
There was a problem hiding this comment.
Why so complicated? extGeshi will stay canonically lowercase and $ext will be lower-cased?
Off topic: I wonder then this will return true:
in_array($filename, $extensions)
There was a problem hiding this comment.
The code fror content type detection does not probe for the entire filename.
There was a problem hiding this comment.
Line in question:
./filedetails.php:$extn = strtolower(strrchr($path, '.'));
There was a problem hiding this comment.
Off topic: I wonder then this will return
true:in_array($filename, $extensions)
Hm... Just a theory: MAKE files don't contain a classical filename extension. But they can be identifiered using their name "Makefile", so I guess in this case, we would need to add "Makefile" to the GeShi extensions.
Why so complicated?
extGeshiwill stay canonically lowercase and$extwill be lower-cased?
Yes, that is indeed easier. But personally I feel safer when both sides are lower-cased before comparing them. Back to my example, it's possible that people add "Makefile" to extGeshi, and they might be very frustrated because it doesn't work anymore (or is WebSvn converting extGeshi to all-lower-case somewhere in the program flow?).
in regards filedetails.php it looks like $extn is forced lower-case and then used at two instances:
- in_array($extn, $zipped)
- $contentType[$extn]
In this case I also want to become independent of case-sensitivety, so I would prefer to change:
- Don't force
$extnto be lower-case - in_array($extn, $zipped) => i would also like to compare case-insensitively
- $contentType[$extn] => search for the (first) element in the array, indepdenent of the case
What do you think?
There was a problem hiding this comment.
Off topic: I wonder then this will return
true:in_array($filename, $extensions)Hm... Just a theory: MAKE files don't contain a classical filename extension. But they can be identifiered using their name "Makefile", so I guess in this case, we would need to add "Makefile" to the GeShi extensions.
Why so complicated?
extGeshiwill stay canonically lowercase and$extwill be lower-cased?Yes, that is indeed easier. But personally I feel safer when both sides are lower-cased before comparing them. Back to my example, it's possible that people add
"Makefile"toextGeshi, and they might be very frustrated because it doesn't work anymore (or is WebSvn convertingextGeshito all-lower-case somewhere in the program flow?).
I agree on Makefiles, I have just tried. There is no mapping and it works exactly that way. I am revoking my comment for the entire file. More than that, I would not lowercase the whole filename because of cases like Makefile and CMakeLists.txt.
in regards
filedetails.phpit looks like$extnis forced lower-case and then used at two instances:* in_array($extn, $zipped) * $contentType[$extn]In this case I also want to become independent of case-sensitivety, so I would prefer to change:
* Don't force `$extn` to be lower-case * in_array($extn, $zipped) => i would also like to compare case-insensitively * $contentType[$extn] => search for the (first) element in the array, indepdenent of the caseWhat do you think?
Hmm, lowercasing the entire filename looks wrong to me. Makefile != makefile in terms of any make implementation. I wouldn't touch it.
So for the same of simplicity I still prefer:
if (in_array($filename, $extensions) || in_array(strtolower($ext), $extensions)) {
There was a problem hiding this comment.
Ok, I have applied the changes. But I think we really need to add a hint to the documentation that $contentType,
$zipped, and $extGeshi must only contain lower-case entries.
There was a problem hiding this comment.
Ok, I have applied the changes. But I think we really need to add a hint to the documentation that
$contentType,$zipped, and$extGeshimust only contain lower-case entries.
I agree, please make a separate PR for the doc change.
michael-o
left a comment
There was a problem hiding this comment.
I still prefer to keep this as simple as possible.
The Geshi highlighting does not work with files which have upper-case file extensions, for example PROJECT.PAS (upper case because it is a DOS retro-coding project) is not detected as TurboPascal/Delphi file.
This PR solves the problem.