~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/pagespeed/kernel/util/url_escaper.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
17
 
// Author: jmarantz@google.com (Joshua Marantz)
18
 
 
19
 
#ifndef PAGESPEED_KERNEL_UTIL_URL_ESCAPER_H_
20
 
#define PAGESPEED_KERNEL_UTIL_URL_ESCAPER_H_
21
 
 
22
 
#include "pagespeed/kernel/base/string.h"
23
 
#include "pagespeed/kernel/base/string_util.h"
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
 
}  // namespace UrlEscaper
63
 
 
64
 
}  // namespace net_instaweb
65
 
 
66
 
#endif  // PAGESPEED_KERNEL_UTIL_URL_ESCAPER_H_