2
* Copyright 2011 Google Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
// Author: vitaliyl@google.com (Vitaliy Lvin)
19
#ifndef PAGESPEED_KERNEL_BASE_ESCAPING_H_
20
#define PAGESPEED_KERNEL_BASE_ESCAPING_H_
22
#include "pagespeed/kernel/base/string.h"
23
#include "pagespeed/kernel/base/string_util.h"
25
namespace net_instaweb {
27
// Appends version of original escaped for JS string syntax, safe for inclusion
28
// into HTML, to *escaped, (optionally with quotes, if asked).
29
void EscapeToJsStringLiteral(const StringPiece& original,
31
GoogleString* escaped);
33
// Appends version of original escaped for JSON string syntax to *escaped,
34
// (optionally with quotes, if asked).
36
// Warning: this is dangerous if you have non-ASCII characters, in that it
37
// doesn't interpret the input encoding, and will just blindly turn them
38
// into \u escapes. However, it will ensure that the output won't have any
39
// dangerous characters that can cause format sniff.
40
void EscapeToJsonStringLiteral(const StringPiece& original,
42
GoogleString* escaped);
44
} // namespace net_instaweb
46
#endif // PAGESPEED_KERNEL_BASE_ESCAPING_H_