mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 20:38:47 +00:00
Add detection for Hack files with ".hh" file extension
Hack is Facebook's dialect of PHP: http://hacklang.org/. This adds support for detecting it via the ".hh" file extension; although that extension techincally conflicts with C++ headers, the files look different enough that the existing classifier based on sample code has no trouble distinguising them. This diff deliberately does not deal with detecting ".php" as another valid extension for Hack code. That's much trickier since the code looks basically identical to PHP to the classifier, and needs a different approach.
This commit is contained in:
16
samples/Hack/UnescapedString.hh
Normal file
16
samples/Hack/UnescapedString.hh
Normal file
@@ -0,0 +1,16 @@
|
||||
<?hh // strict
|
||||
|
||||
// Outside of this file, no one knows that UNESCAPED_STRING is a string
|
||||
newtype UNESCAPED_STRING = string;
|
||||
|
||||
// This is how we initially taint a string.
|
||||
function unescaped_string(string $s): UNESCAPED_STRING {
|
||||
return $s;
|
||||
}
|
||||
|
||||
// This is the only thing you can do with an UNESCAPED_STRING (other than pass
|
||||
// it around)
|
||||
function escape_unescaped_string(UNESCAPED_STRING $s): string {
|
||||
// Your use case will decide how you want to escape your strings
|
||||
return sprintf('Escaped ---> "%s" <--- Escaped', $s);
|
||||
}
|
||||
Reference in New Issue
Block a user