mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
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.
17 lines
523 B
C++
17 lines
523 B
C++
<?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);
|
|
}
|