Skip to content

Commit

Permalink
Merge pull request #34 from slackhq/mdob-upstream-changes
Browse files Browse the repository at this point in the history
Upstream changes, fixing string concatenation and more
  • Loading branch information
JPolacek authored Dec 3, 2021
2 parents 4995b69 + 16d0e30 commit ccea8da
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/AttrTransform/TargetBlank.hack
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HTMLPurifier_AttrTransform_TargetBlank extends HTMLPurifier\HTMLPurifier_A
HTMLPurifier\HTMLPurifier_Context $context,
): dict<string, string> {
if (!$config->def->defaults['HTML.TargetBlank']) {
# This transform is turned off in the configuration
// This transform is turned off in the configuration
return $attr;
}
if (!C\contains_key($attr, 'href')) {
Expand Down
2 changes: 1 addition & 1 deletion src/AttrTransform/TargetNoopener.hack
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class HTMLPurifier_AttrTransform_TargetNoopener extends HTMLPurifier\HTMLPurifie
HTMLPurifier\HTMLPurifier_Context $context,
): dict<string, string> {
if (!$config->def->defaults['HTML.TargetNoopener']) {
# This transform is turned off in the configuration
// This transform is turned off in the configuration
return $attr;
}
if (C\contains_key($attr, 'rel')) {
Expand Down
2 changes: 1 addition & 1 deletion src/AttrTransform/TargetNoreferrer.hack
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class HTMLPurifier_AttrTransform_TargetNoreferrer extends HTMLPurifier\HTMLPurif
HTMLPurifier\HTMLPurifier_Context $context,
): dict<string, string> {
if (!$config->def->defaults['HTML.TargetNoreferrer']) {
# This transform is turned off in the configuration
// This transform is turned off in the configuration
return $attr;
}
if (C\contains_key($attr, 'rel')) {
Expand Down
2 changes: 1 addition & 1 deletion src/ContentSets.hack
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class HTMLPurifier_ContentSets {
// $this->info[$key] = implode(' | ', array_keys($lookup));
// }
// $this->keys = array_keys($this->info);
// $this->values = array_values($this->info);
// $this->values = varray($this->info);
// }

// /**
Expand Down
3 changes: 3 additions & 0 deletions src/Definition/HTMLDefinition.hack
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier\HTMLPurifier_Definition {
"rel" => new HTML\HTMLPurifier_AttrDef_HTML_LinkTypes("rel"),
"target" => new HTML\HTMLPurifier_AttrDef_HTML_FrameTarget(vec["_blank"]),
"href" => new AttrDef\HTMLPurifier_AttrDef_URI(),
"data-clog-click" => new AttrDef\HTML\HTMLPurifier_AttrDef_HTML_Bool(),
"data-clog-ui-element" => new AttrDef\HTMLPurifier_AttrDef_Text(),
"data-clog-ui-step" => new AttrDef\HTMLPurifier_AttrDef_Text(),
];
$a_element = new HTMLPurifier\HTMLPurifier_ElementDef(
true,
Expand Down
2 changes: 1 addition & 1 deletion src/DefinitionCache/Serializer.hack
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class HTMLPurifier_DefinitionCache_Serializer {
public function checkDefType(HTMLPurifier\HTMLPurifier_Definition $def): bool {
if ($def->type !== $this->type) {
// trigger_error("Cannot use definition of type {$def->type} in cache for {$this->type}");
echo "Cannot use definition of type {$def->type} in cache for {$this->type}";
echo "Cannot use definition of type ".(string)$def->type." in cache for {$this->type}";
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/DefinitionCacheFactory.hack
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class HTMLPurifier_DefinitionCacheFactory {
dict['Serializer' => dict[]];

public function __construct() {
# uses create instead of construct
// uses create instead of construct
}

public static function instance(
Expand Down
2 changes: 1 addition & 1 deletion src/Doctype.hack
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HTMLPurifier_Doctype {
// // System DTD identifier
// public ?string $dtdSystem;

# Constructor Paramter Promotion
// Constructor Paramter Promotion
public function __construct(
public string $name = '',
public bool $xml = true,
Expand Down
1 change: 1 addition & 0 deletions src/Encoder.hack
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class HTMLPurifier_Encoder {
// Codepoints outside the Unicode range are illegal
($mUcs4 > 0x10FFFF)
) {
// do nothing
} elseif (
0xFEFF != $mUcs4 && // omit BOM
// check for valid Char unicode codepoints
Expand Down
2 changes: 1 addition & 1 deletion src/EntityParser.hack
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace HTMLPurifier;
*/
class HTMLPurifier_EntityParser {
public function __construct() {
# code...
// code...
}

public function substituteSpecialEntities(string $_string): string {
Expand Down
2 changes: 1 addition & 1 deletion src/Lexer/DOMLex.hack
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier\HTMLPurifier_Lexer {
}
return false;
} else if ($node->nodeType === \XML_CDATA_SECTION_NODE) {
# undo libxml's special treatment of <script> and <style> tags
// undo libxml's special treatment of <script> and <style> tags
$last = C\lastx($tokens);
//php version uses node->data, Hack doesn't have data field
$data = $node->nodeValue;
Expand Down
4 changes: 2 additions & 2 deletions src/URI.hack
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class HTMLPurifier_URI {
if ($c is nonnull && $this->path is nonnull) {
$seg_nc_encode = $segment_nc_encoder->encode(Str\slice($this->path, 0, $c));
$seg_encode = $this->path is nonnull ? $segments_encoder->encode(Str\slice($this->path, $c)) : null;
$this->path = $seg_nc_encode.$seg_encode;
$this->path = $seg_nc_encode.(string)$seg_encode;
} else {
if ($this->path is nonnull) $this->path = $segment_nc_encoder->encode($this->path);
}
Expand Down Expand Up @@ -226,7 +226,7 @@ class HTMLPurifier_URI {
$result .= $this->scheme.':';
}
if ($authority !== '') {
$result .= '//'.$authority;
$result .= '//'.(string)$authority;
}
$result .= $this->path;
if ($this->query !== '') {
Expand Down
2 changes: 1 addition & 1 deletion src/URIScheme/data.hack
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class HTMLPurifier_URIScheme_data extends HTMLPurifier\HTMLPurifier_URIScheme {
$uri->port = 0;
$uri->fragment = '';
$uri->query = '';
$uri->path = "$content_type;base64,".\base64_encode($raw_data);
$uri->path = (string)$content_type.";base64," . \base64_encode($raw_data);
return true;
}

Expand Down

0 comments on commit ccea8da

Please sign in to comment.