Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
7f372559
Commit
7f372559
authored
Feb 25, 2013
by
xiaofeng@google.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Down-integrate from internal branch
parent
de3494fe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
4 deletions
+29
-4
text_format_test.py
python/google/protobuf/internal/text_format_test.py
+20
-0
text_format.py
python/google/protobuf/text_format.py
+7
-2
java_doc_comment.h
src/google/protobuf/compiler/java/java_doc_comment.h
+1
-1
subprocess.h
src/google/protobuf/compiler/subprocess.h
+1
-1
No files found.
python/google/protobuf/internal/text_format_test.py
View file @
7f372559
...
@@ -429,6 +429,26 @@ class TextFormatTest(unittest.TestCase):
...
@@ -429,6 +429,26 @@ class TextFormatTest(unittest.TestCase):
(
'1:17 : Couldn
\'
t parse integer: bork'
),
(
'1:17 : Couldn
\'
t parse integer: bork'
),
text_format
.
Merge
,
text
,
message
)
text_format
.
Merge
,
text
,
message
)
def
testMergeStringFieldUnescape
(
self
):
message
=
unittest_pb2
.
TestAllTypes
()
text
=
r'''repeated_string: "\xf\x62"
repeated_string: "\\xf\\x62"
repeated_string: "\\\xf\\\x62"
repeated_string: "\\\\xf\\\\x62"
repeated_string: "\\\\\xf\\\\\x62"
repeated_string: "\x5cx20"'''
text_format
.
Merge
(
text
,
message
)
SLASH
=
'
\\
'
self
.
assertEqual
(
'
\x0f
b'
,
message
.
repeated_string
[
0
])
self
.
assertEqual
(
SLASH
+
'xf'
+
SLASH
+
'x62'
,
message
.
repeated_string
[
1
])
self
.
assertEqual
(
SLASH
+
'
\x0f
'
+
SLASH
+
'b'
,
message
.
repeated_string
[
2
])
self
.
assertEqual
(
SLASH
+
SLASH
+
'xf'
+
SLASH
+
SLASH
+
'x62'
,
message
.
repeated_string
[
3
])
self
.
assertEqual
(
SLASH
+
SLASH
+
'
\x0f
'
+
SLASH
+
SLASH
+
'b'
,
message
.
repeated_string
[
4
])
self
.
assertEqual
(
SLASH
+
'x20'
,
message
.
repeated_string
[
5
])
def
assertRaisesWithMessage
(
self
,
e_class
,
e
,
func
,
*
args
,
**
kwargs
):
def
assertRaisesWithMessage
(
self
,
e_class
,
e
,
func
,
*
args
,
**
kwargs
):
"""Same as assertRaises, but also compares the exception message."""
"""Same as assertRaises, but also compares the exception message."""
if
hasattr
(
e_class
,
'__name__'
):
if
hasattr
(
e_class
,
'__name__'
):
...
...
python/google/protobuf/text_format.py
View file @
7f372559
...
@@ -608,12 +608,17 @@ def _CEscape(text, as_utf8):
...
@@ -608,12 +608,17 @@ def _CEscape(text, as_utf8):
return
""
.
join
([
escape
(
c
)
for
c
in
text
])
return
""
.
join
([
escape
(
c
)
for
c
in
text
])
_CUNESCAPE_HEX
=
re
.
compile
(
'
\\\\
x([0-9a-fA-F]{2}|
[0-9a-fA-F])'
)
_CUNESCAPE_HEX
=
re
.
compile
(
r'(\\+)x([0-9a-fA-F])(?!
[0-9a-fA-F])'
)
def
_CUnescape
(
text
):
def
_CUnescape
(
text
):
def
ReplaceHex
(
m
):
def
ReplaceHex
(
m
):
return
chr
(
int
(
m
.
group
(
0
)[
2
:],
16
))
# Only replace the match if the number of leading back slashes is odd. i.e.
# the slash itself is not escaped.
if
len
(
m
.
group
(
1
))
&
1
:
return
m
.
group
(
1
)
+
'x0'
+
m
.
group
(
2
)
return
m
.
group
(
0
)
# This is required because the 'string_escape' encoding doesn't
# This is required because the 'string_escape' encoding doesn't
# allow single-digit hex escapes (like '\xf').
# allow single-digit hex escapes (like '\xf').
result
=
_CUNESCAPE_HEX
.
sub
(
ReplaceHex
,
text
)
result
=
_CUNESCAPE_HEX
.
sub
(
ReplaceHex
,
text
)
...
...
src/google/protobuf/compiler/java/java_doc_comment.h
View file @
7f372559
...
@@ -59,7 +59,7 @@ void WriteMethodDocComment(io::Printer* printer,
...
@@ -59,7 +59,7 @@ void WriteMethodDocComment(io::Printer* printer,
const
MethodDescriptor
*
method
);
const
MethodDescriptor
*
method
);
// Exposed for testing only.
// Exposed for testing only.
string
EscapeJavadoc
(
const
string
&
input
);
LIBPROTOC_EXPORT
string
EscapeJavadoc
(
const
string
&
input
);
}
// namespace java
}
// namespace java
}
// namespace compiler
}
// namespace compiler
...
...
src/google/protobuf/compiler/subprocess.h
View file @
7f372559
...
@@ -53,7 +53,7 @@ class Message;
...
@@ -53,7 +53,7 @@ class Message;
namespace
compiler
{
namespace
compiler
{
// Utility class for launching sub-processes.
// Utility class for launching sub-processes.
class
Subprocess
{
class
LIBPROTOC_EXPORT
Subprocess
{
public
:
public
:
Subprocess
();
Subprocess
();
~
Subprocess
();
~
Subprocess
();
...
...
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