Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
url_escaper.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Google Inc.
3  *
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
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
18 
19 #ifndef PAGESPEED_KERNEL_UTIL_URL_ESCAPER_H_
20 #define PAGESPEED_KERNEL_UTIL_URL_ESCAPER_H_
21 
24 
25 namespace net_instaweb {
26 
27 /*
28 The intent of this class to encode arbitrary URLs into one 'segment'
29 of a new URL. We escape many special chars like /\?&% to make sure that
30 this encoded version is only one segment.
31 
32 We would like the above URL to be reasonably legible if possible.
33 However it's also nice if it's short.
34 
35 Common URL format is:
36 
37  http:///www.foo.bar/z1234/b_c.d?e=f&g=h
38 
39 this suggests we should have short encodings for a-zA-Z0-9./?&
40 
41 The transform table is:
42 
43 a-zA-Z0-9_=+-. unchanged
44 ^ ,u
45 % ,P
46 / ,_
47 \ ,-
48 , ,,
49 ? ,q
50 & ,a
51 http:/// ,h
52 .pagespeed. ,M
53 
54 everything else ,XX where XX are hex digits using capital letters.
55 */
56 
57 namespace UrlEscaper {
58 
59 void EncodeToUrlSegment(const StringPiece& in, GoogleString* url_segment);
60 bool DecodeFromUrlSegment(const StringPiece& url_segment, GoogleString* out);
61 
62 }
63 
64 }
65 
66 #endif
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24