Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
6dbf7aa1
Commit
6dbf7aa1
authored
Nov 04, 2009
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- complete html-escaping also in printer.go
R=rsc
http://go/go-review/1017027
parent
c8c3f1d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
src/pkg/go/printer/printer.go
src/pkg/go/printer/printer.go
+12
-7
No files found.
src/pkg/go/printer/printer.go
View file @
6dbf7aa1
...
...
@@ -43,9 +43,12 @@ var (
htab
=
[]
byte
{
'\t'
};
htabs
=
[
...
]
byte
{
'\t'
,
'\t'
,
'\t'
,
'\t'
,
'\t'
,
'\t'
,
'\t'
,
'\t'
};
newlines
=
[
...
]
byte
{
'\n'
,
'\n'
,
'\n'
,
'\n'
,
'\n'
,
'\n'
,
'\n'
,
'\n'
};
// more than maxNewlines
ampersand
=
strings
.
Bytes
(
"&"
);
lessthan
=
strings
.
Bytes
(
"<"
);
greaterthan
=
strings
.
Bytes
(
">"
);
esc_quot
=
strings
.
Bytes
(
"""
);
// shorter than """
esc_apos
=
strings
.
Bytes
(
"'"
);
// shorter than "'"
esc_amp
=
strings
.
Bytes
(
"&"
);
esc_lt
=
strings
.
Bytes
(
"<"
);
esc_gt
=
strings
.
Bytes
(
">"
);
)
...
...
@@ -145,7 +148,7 @@ func (p *printer) write(data []byte) {
// next segment start
i0
=
i
+
1
;
case
'&'
,
'<'
,
'>'
:
case
'
"'
,
'\'
'
,
'
&'
,
'<'
,
'>'
:
if
p
.
Mode
&
GenHTML
!=
0
{
// write segment ending in b
p
.
write0
(
data
[
i0
:
i
]);
...
...
@@ -153,9 +156,11 @@ func (p *printer) write(data []byte) {
// write HTML-escaped b
var
esc
[]
byte
;
switch
b
{
case
'&'
:
esc
=
ampersand
;
case
'<'
:
esc
=
lessthan
;
case
'>'
:
esc
=
greaterthan
;
case
'"'
:
esc
=
esc_quot
;
case
'\'
'
:
esc
=
esc_apos
;
case
'&'
:
esc
=
esc_amp
;
case
'<'
:
esc
=
esc_lt
;
case
'>'
:
esc
=
esc_gt
;
}
p
.
write0
(
esc
);
...
...
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