Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
z-push
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Björn Fischer
z-push
Commits
fd2ebc3e
Commit
fd2ebc3e
authored
Dec 12, 2016
by
Manfred Kutas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZP-1121 Output opaque data.
Released under the Affero GNU General Public License (AGPL) version 3.
parent
a441242c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
17 deletions
+43
-17
wbxmlencoder.php
src/lib/wbxml/wbxmlencoder.php
+43
-17
No files found.
src/lib/wbxml/wbxmlencoder.php
View file @
fd2ebc3e
...
@@ -162,20 +162,22 @@ class WBXMLEncoder extends WBXMLDefs {
...
@@ -162,20 +162,22 @@ class WBXMLEncoder extends WBXMLDefs {
*
*
* @param resource $stream
* @param resource $stream
* @param boolean $asBase64 if true, the data will be encoded as base64, default: false
* @param boolean $asBase64 if true, the data will be encoded as base64, default: false
* @param boolean $opaque if true, output the opaque data, default: false
*
*
* @access public
* @access public
* @return
* @return
*/
*/
public
function
contentStream
(
$stream
,
$asBase64
=
false
)
{
public
function
contentStream
(
$stream
,
$asBase64
=
false
,
$opaque
=
false
)
{
if
(
!
$asBase64
)
{
// Do not append filters to opaque data as it might contain null char
if
(
!
$asBase64
&&
!
$opaque
)
{
stream_filter_register
(
'replacenullchar'
,
'ReplaceNullcharFilter'
);
stream_filter_register
(
'replacenullchar'
,
'ReplaceNullcharFilter'
);
$rnc_filter
=
stream_filter_append
(
$stream
,
'replacenullchar'
);
$rnc_filter
=
stream_filter_append
(
$stream
,
'replacenullchar'
);
}
}
$this
->
_outputStack
();
$this
->
_outputStack
();
$this
->
_contentStream
(
$stream
,
$asBase64
);
$this
->
_contentStream
(
$stream
,
$asBase64
,
$opaque
);
if
(
!
$asBase64
)
{
if
(
!
$asBase64
&&
!
$opaque
)
{
stream_filter_remove
(
$rnc_filter
);
stream_filter_remove
(
$rnc_filter
);
}
}
...
@@ -286,9 +288,17 @@ class WBXMLEncoder extends WBXMLDefs {
...
@@ -286,9 +288,17 @@ class WBXMLEncoder extends WBXMLDefs {
* @param boolean $asBase64
* @param boolean $asBase64
* @return
* @return
*/
*/
private
function
_contentStream
(
$stream
,
$asBase64
)
{
private
function
_contentStream
(
$stream
,
$asBase64
,
$opaque
)
{
$stat
=
fstat
(
$stream
);
// write full stream, including the finalizing terminator to the output stream (stuff outTermStr() would do)
// write full stream, including the finalizing terminator to the output stream (stuff outTermStr() would do)
if
(
$opaque
)
{
$this
->
outByte
(
self
::
WBXML_OPAQUE
);
$this
->
outMBUInt
(
$stat
[
'size'
]);
}
else
{
$this
->
outByte
(
self
::
WBXML_STR_I
);
$this
->
outByte
(
self
::
WBXML_STR_I
);
}
if
(
$asBase64
)
{
if
(
$asBase64
)
{
$out_filter
=
stream_filter_append
(
$this
->
_out
,
'convert.base64-encode'
);
$out_filter
=
stream_filter_append
(
$this
->
_out
,
'convert.base64-encode'
);
}
}
...
@@ -296,11 +306,12 @@ class WBXMLEncoder extends WBXMLDefs {
...
@@ -296,11 +306,12 @@ class WBXMLEncoder extends WBXMLDefs {
if
(
$asBase64
)
{
if
(
$asBase64
)
{
stream_filter_remove
(
$out_filter
);
stream_filter_remove
(
$out_filter
);
}
}
if
(
!
$opaque
)
{
fwrite
(
$this
->
_out
,
chr
(
0
));
fwrite
(
$this
->
_out
,
chr
(
0
));
}
if
(
$this
->
log
)
{
if
(
$this
->
log
)
{
// data is out, do some logging
// data is out, do some logging
$stat
=
fstat
(
$stream
);
$this
->
logContent
(
sprintf
(
"<<< written %d of %d bytes of %s data >>>"
,
$written
,
$stat
[
'size'
],
$asBase64
?
"base64 encoded"
:
"plain"
));
$this
->
logContent
(
sprintf
(
"<<< written %d of %d bytes of %s data >>>"
,
$written
,
$stat
[
'size'
],
$asBase64
?
"base64 encoded"
:
"plain"
));
}
}
}
}
...
@@ -330,24 +341,39 @@ class WBXMLEncoder extends WBXMLDefs {
...
@@ -330,24 +341,39 @@ class WBXMLEncoder extends WBXMLDefs {
}
}
/**
/**
* Outputs a string table
* Output the multibyte integers to the stream.
*
* A multi-byte integer consists of a series of octets,
* where the most significant bit is the continuation flag
* and the remaining seven bits are a scalar value.
* The octets are arranged in a big-endian order,
* eg, the most significant seven bits are transmitted first.
*
* @see https://www.w3.org/1999/06/NOTE-wbxml-19990624/#_Toc443384895
*
*
* @param $uint
* @param
int
$uint
*
*
* @access private
* @access private
* @return
* @return
void
*/
*/
private
function
outMBUInt
(
$uint
)
{
private
function
outMBUInt
(
$uint
)
{
while
(
1
)
{
if
(
$uint
==
0x0
)
{
return
$this
->
outByte
(
$uint
);
}
$out
=
''
;
for
(
$i
=
0
;
$uint
!=
0
;
$i
++
)
{
$byte
=
$uint
&
0x7f
;
$byte
=
$uint
&
0x7f
;
$uint
=
$uint
>>
7
;
$uint
=
$uint
>>
7
;
if
(
$uint
==
0
)
{
if
(
$i
==
0
)
{
$
this
->
outByte
(
$byte
)
;
$
out
=
chr
(
$byte
)
.
$out
;
break
;
}
}
else
{
else
{
$
this
->
outByte
(
$byte
|
0x80
)
;
$
out
=
chr
(
$byte
|
0x80
)
.
$out
;
}
}
}
}
fwrite
(
$this
->
_out
,
$out
);
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment