aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorfabrixxm <fabrix.xm@gmail.com>2011-08-17 17:35:37 +0200
committerfabrixxm <fabrix.xm@gmail.com>2011-08-17 17:35:37 +0200
commitbdf42473a0341f291cd256323d122aa80bb0cb0b (patch)
tree922a5ba24a34d7ea89673019e82f68436edb7091 /library
parent6c423feed2d8bc5bd36d2a1cbac073915e523749 (diff)
parentdb03b1ab173d61b1ee75271dac1e48f3475ad42c (diff)
downloadvolse-hubzilla-bdf42473a0341f291cd256323d122aa80bb0cb0b.tar.gz
volse-hubzilla-bdf42473a0341f291cd256323d122aa80bb0cb0b.tar.bz2
volse-hubzilla-bdf42473a0341f291cd256323d122aa80bb0cb0b.zip
Merge remote-tracking branch 'friendika/master' into newui
Diffstat (limited to 'library')
-rw-r--r--library/ASNValue.class.php169
-rw-r--r--library/asn1.php7
-rw-r--r--library/simplepie/simplepie.inc7
3 files changed, 175 insertions, 8 deletions
diff --git a/library/ASNValue.class.php b/library/ASNValue.class.php
new file mode 100644
index 000000000..7a3c5d20e
--- /dev/null
+++ b/library/ASNValue.class.php
@@ -0,0 +1,169 @@
+<?php
+//-----------------------------------------------------------------------------
+// ASNValue class by A.Oliinyk
+// contact@pumka.net
+//-----------------------------------------------------------------------------
+class ASNValue
+{
+ const TAG_INTEGER = 0x02;
+ const TAG_BITSTRING = 0x03;
+ const TAG_SEQUENCE = 0x30;
+
+ public $Tag;
+ public $Value;
+
+ function __construct($Tag=0x00, $Value='')
+ {
+ $this->Tag = $Tag;
+ $this->Value = $Value;
+ }
+
+ function Encode()
+ {
+ //Write type
+ $result = chr($this->Tag);
+
+ //Write size
+ $size = strlen($this->Value);
+ if ($size < 127) {
+ //Write size as is
+ $result .= chr($size);
+ }
+ else {
+ //Prepare length sequence
+ $sizeBuf = self::IntToBin($size);
+
+ //Write length sequence
+ $firstByte = 0x80 + strlen($sizeBuf);
+ $result .= chr($firstByte) . $sizeBuf;
+ }
+
+ //Write value
+ $result .= $this->Value;
+
+ return $result;
+ }
+
+ function Decode(&$Buffer)
+ {
+ //Read type
+ $this->Tag = self::ReadByte($Buffer);
+
+ //Read first byte
+ $firstByte = self::ReadByte($Buffer);
+
+ if ($firstByte < 127) {
+ $size = $firstByte;
+ }
+ else if ($firstByte > 127) {
+ $sizeLen = $firstByte - 0x80;
+ //Read length sequence
+ $size = self::BinToInt(self::ReadBytes($Buffer, $sizeLen));
+ }
+ else {
+ throw new Exception("Invalid ASN length value");
+ }
+
+ $this->Value = self::ReadBytes($Buffer, $size);
+ }
+
+ protected static function ReadBytes(&$Buffer, $Length)
+ {
+ $result = substr($Buffer, 0, $Length);
+ $Buffer = substr($Buffer, $Length);
+
+ return $result;
+ }
+
+ protected static function ReadByte(&$Buffer)
+ {
+ return ord(self::ReadBytes($Buffer, 1));
+ }
+
+ protected static function BinToInt($Bin)
+ {
+ $len = strlen($Bin);
+ $result = 0;
+ for ($i=0; $i<$len; $i++) {
+ $curByte = self::ReadByte($Bin);
+ $result += $curByte << (($len-$i-1)*8);
+ }
+
+ return $result;
+ }
+
+ protected static function IntToBin($Int)
+ {
+ $result = '';
+ do {
+ $curByte = $Int % 256;
+ $result .= chr($curByte);
+
+ $Int = ($Int - $curByte) / 256;
+ } while ($Int > 0);
+
+ $result = strrev($result);
+
+ return $result;
+ }
+
+ function SetIntBuffer($Value)
+ {
+ if (strlen($Value) > 1) {
+ $firstByte = ord($Value{0});
+ if ($firstByte & 0x80) { //first bit set
+ $Value = chr(0x00) . $Value;
+ }
+ }
+
+ $this->Value = $Value;
+ }
+
+ function GetIntBuffer()
+ {
+ $result = $this->Value;
+ if (ord($result{0}) == 0x00) {
+ $result = substr($result, 1);
+ }
+
+ return $result;
+ }
+
+ function SetInt($Value)
+ {
+ $Value = self::IntToBin($Value);
+
+ $this->SetIntBuffer($Value);
+ }
+
+ function GetInt()
+ {
+ $result = $this->GetIntBuffer();
+ $result = self::BinToInt($result);
+
+ return $result;
+ }
+
+ function SetSequence($Values)
+ {
+ $result = '';
+ foreach ($Values as $item) {
+ $result .= $item->Encode();
+ }
+
+ $this->Value = $result;
+ }
+
+ function GetSequence()
+ {
+ $result = array();
+ $seq = $this->Value;
+ while (strlen($seq)) {
+ $val = new ASNValue();
+ $val->Decode($seq);
+ $result[] = $val;
+ }
+
+ return $result;
+ }
+}
diff --git a/library/asn1.php b/library/asn1.php
index 713978e8c..e84398bf6 100644
--- a/library/asn1.php
+++ b/library/asn1.php
@@ -187,7 +187,6 @@ class ASN_BASE {
return new ASN_BOOLEAN((bool)$data);
case ASN_INTEGER:
return new ASN_INTEGER(strtr(base64_encode($data),'+/','-_'));
-// return new ASN_INTEGER(ord($data));
case ASN_BIT_STR:
return new ASN_BIT_STR(self::parseASNString($data, $level+1, $maxLevels));
case ASN_OCTET_STR:
@@ -290,9 +289,3 @@ class ASN_BASE {
}
-
-function accum($s) {
- $result = strtr(base64_encode($s),'+/=','-_,');
- return $result;
-}
-
diff --git a/library/simplepie/simplepie.inc b/library/simplepie/simplepie.inc
index c3ba02b7d..8a2739f52 100644
--- a/library/simplepie/simplepie.inc
+++ b/library/simplepie/simplepie.inc
@@ -5517,6 +5517,7 @@ class SimplePie_Item
$type = null;
$url = null;
$width = null;
+ $title = $title_parent;
$url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
if (isset($link['attribs']['']['type']))
@@ -5527,9 +5528,13 @@ class SimplePie_Item
{
$length = ceil($link['attribs']['']['length']);
}
+ if (isset($link['attribs']['']['title']))
+ {
+ $title = $this->sanitize($link['attribs']['']['title'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
- $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
+ $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title, $width);
}
}