This file is indexed.

/usr/include/falcon/uri.h is in falconpl-dev 0.9.6.9-git20120606-2.1+b1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
/*
   FALCON - The Falcon Programming Language.
   FILE: uri.h

   RFC 3986 - Uniform Resource Identifier
   -------------------------------------------------------------------
   Author: Giancarlo Niccolai
   Begin: Sun, 17 Feb 2008 12:23:28 +0100

   -------------------------------------------------------------------
   (C) Copyright 2004: the FALCON developers (see list in AUTHORS file)

   See LICENSE file for licensing details.
*/

#ifndef FALCON_URI_H
#define FALCON_URI_H

#include <falcon/setup.h>
#include <falcon/string.h>
#include <falcon/path.h>
#include <falcon/genericmap.h>

namespace Falcon
{

/** RFC 3986 - Uniform Resource Identifier.

   This class offer falcon engine and its users an interface to URI.
*/
class FALCON_DYN_CLASS URI: public BaseAlloc
{
   /** A copy of the original string, for diagniostics.*/
   String m_original;

   /** The final normalized and encoded URI. */
   mutable String m_encoded;

   /** False if this URI is not valid. */
   bool m_bValid;

   /** URI scheme (e.g. http) */
   String m_scheme;

   // Authority ----------------------
   /** User or user:password. */
   String m_userInfo;

   /** Host part of the URI. */
   String m_host;

   /** Port part of the URI. */
   String m_port;

   /** Path.
      Virtually divided into 4 elements:
      \code
      /[resource:]path/file.ext
      \endcode

      but calculus on path is done realtime.

      \note relative paths (not starting with /) cannot have a resource part.
   */
   Path m_path;

   /** Query string, recorded as-is. */
   mutable String m_query;

   /** Query part.
      Map of string->string.

      Will be used only if query parsing is explicitly requested.

      Many things using URI may not want this to be done, i.e. becasuse
      they want to parse the query on their own. Also, query form is free
      and may be a per-application format, even if the key=value& list is
      a quite eshtablished standard.
   */
   Map *m_queryMap;

   /** Iterator used for opaque traversal of query objects */
   MapIterator m_queryIter;

   /** Fragment. */
   String m_fragment;

   /** Encodes a prebuilt string which is then placed in the m_encoded field. */
   void encode( const String &u );

   /** Parses the query element. */
   bool internal_parseQuery( const String &str, uint32 pos, bool parseQuery , bool bDecode );

   /** Parses the fragment element. */
   bool internal_parseFragment( uint32 pos );

   bool internal_parse( const String &newUri, bool parseQuery, bool decode = true );

   friend class Path;
   
public:

   /** Empty constructor.
      Creates an empty URI. To be filled at a later time.
   */
   URI();

   /** Complete URI constructor.
      Decodes the uri and parses it in its fields.

      In case URI is not valid, isValid() will return false after construction.
   */
   URI( const String &suri );

   /** Copy constructor.
      Copies everything in the other URI, including validity.
   */
   URI( const URI &other );

   virtual ~URI();

   /** Parses the given string into this URI.
      The URI will be normalized and eventually decoded, so that the internal
      format of the URI.

      Normally, the method decodes any % code into it's value, and considers
      the uri as encoded into UTF-8 sequences.

      If the \b decode param is false, the input string is read as-is.

      By default, the function will just store the query field for later retrival
      with the query() accessor. The query field will be returned in its original
      form, undecoded. If the makeQueryMap boolean field is set to true,
      the parseQuery() method will be called upon succesful completion of URI parsing,
      before the function returns.

      \param newUri the new URI to be parsed.
      \param decode set to false to use the given URI as is.
      \param bMakeQueryMap if true, will create a string map with pre-parsed from query field, if present.
      \return true on success, false if the given string is not a valid URI.
   */
   bool parse( const String &newUri, bool parseQuery = false, bool decode = true );

   /** Parses the query field.
      Taken the query field of this class, it perform a RFC3986 scan for "&" separated
      keys and values pairs, each of which separated with a "=" sign.

      The result is set in the internal map of fields, that can then be inspected or
      changed keywise.

      This method overwrites existing keys with new ones, so it is not possible to
      use it to implement PHP-like URI arrays as in i.e.
      \code
         k[]=1&k[]=2
      \endcode

      \param decode true to automatically URL decode keys and values that will be stored in the map.
      \return true on success, false if the query field cannot be decoded.
   */
   bool parseQuery( bool decode = true );

   /** Changes query and the parses it field.
      This method calls in sequecnce the query() accessor and then the parseQuery() method.

      \param q a string that will be set as-is in the query field of this URI
      \param decode true to automatically URL decode keys and values that will be stored in the map.
      \return true on success, false if the query field cannot be decoded.
   */
   bool parseQuery( const String &q, bool decode = true )
   {
      query( q );
      return parseQuery( decode );
   }

   /** Sets the query field of this URI.
      The query field is set as-is. This destroys previously created maps of
      keys values that should be used as query field generators.

      The parameter should be URL encoded before being set into this method,
      or the \b encode parameter may be used to have this method to perform
      URL encoding.

      \param q the query to be set.
      \param encode if true, q is considered a plain string still to be encoded.
   */
   void query( const String &q, bool encode = false );

   /** Returns previously set query.
      This method returns a previously set query field as-is.

      The content of the key-value map of this URI object, if any, is ignored.

      \note To make a query field out of a query-map, use the makeQuery() method.
   */
   const String &query() const { return m_query; }

   /** Synthetizes a query field out of the key-values stored in this URI object.

      This call clears the content of the query field and changes it with an
      RFC3986 encoded key-value pair list in the format
      \code
         k1=v1&k2=v2&...&kn=vn
      \endcode

   \return The synthetized string.
   */
   const String &makeQuery() const;

   /** Returns the current URI.
      This method eventually builds a new URI from the internally parsed data
      and returns it.

      If a set of key-value pairs has been set in this URI, it is used to
      synthetize a query field using makeQuery() method. If this is not desired,
      i.e. because already done, or because the query field has been set
      separately, the \b synthQuery parameter may be set to false, and the content
      of the query field will be used instead.
   */
   const String &get( bool synthQuery = true ) const;

   //  A bit of parsing support.
   /** Character is a reserved delimiter under RFC3986 */
   inline static bool isResDelim( uint32 chr );

   /** Character is main section delimiter under RFC3986 */
   inline static bool isMainDelim( uint32 chr );

   /** Character is a general delimiter under RFC3986 */
   inline static bool isGenDelim( uint32 chr );

   /** Character is a subdelimiter under RFC4986 */
   inline static bool isSubDelim( uint32 chr );

   /** Unreserved characters under RFC3986 */
   inline static bool isUnreserved( uint32 chr );

   /** Normalzies the URI sequence.
      Transforms ranges of ALPHA
      (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E),
      underscore (%5F), or tilde (%7E) into their coresponding values.

      Other than that, it transforms %20 in spaces.

      The normalization is performed on a result string.

      Every string set in input by any method in this class is normalized
      prior to storage.

      However, notice that parts in the class may be invalid URI elements
      if extracted as is, as they are stored as Falcon international strings.
      Encoding to URI conformance happens only when required.

      \param part the element of the URI (or the complete URI) to be normalized.
      \param result the string where the normalization is performed.
   */
   //static void normalize( const String &part, String &result );

   /** Returns current scheme. */
   const String &scheme() const { return m_scheme; }

   /** Sets a different scheme for this URI.
      This will invalidate current URI until next uri() is called.
   */
   void scheme( const String &s );

   /** Returns current userInfo. */
   const String &userInfo() const { return m_userInfo; }

   /** Sets a different userInfo for this URI.
      This will invalidate current URI until next uri() is called.
   */
   void userInfo( const String &s );

   /** Returns current host. */
   const String &host() const { return m_host; }

   /** Sets a different host for this URI.
      This will invalidate current URI until next uri() is called.
   */
   void host( const String &h );

   /** Returns current port. */
   const String &port() const { return m_port; }

   /** Sets a different port for this URI.
      This will invalidate current URI until next uri() is called.
   */
   void port( const String &h );

   /** Returns current path. */
   const String &path() const { return m_path.get(); }

   /** Returns current path as a path class. */
   const Path &pathElement() const { return m_path; }
   
   /** Returns current path as a path class. */
   Path &pathElement() { return m_path; }

   /** Sets a different path for this URI.
      This will invalidate current URI until next uri() is called.
   */
   void path( const String &p );

   /** Sets a different path for this URI.
      This will invalidate current URI until next uri() is called.
   */
   void path( const Path &p );

   /** Returns true if the query part has this field. */
   bool hasField( const String &f ) const ;

   /** Returns the required value, if it exists. */
   bool getField( const String &key, String &value ) const;

   /** Sets a given query field.
      As a convention, if the string contains only a single 0 character (NUL), the
      final result won't include = in the query part, while an empty string will
      result in a query string containing only a keu and a "=" followed by nothing.
      Strings longer than 1 element are not interpreted this way, so a nul followed
      by some data would be rendere as "%00" followed by the rest of the value.
   */
   void setField( const String &key, const String &value );

   /** Removes a query field. */
   bool removeField( const String &key );

   /** Enumerates the query fields - gets the first field.
      Returns true if there is a first field in the query.
      \note The query element must have been previously parsed, or fields must have
      been explicitly inserted.
      \param key a string where the key of the first field will be placed
      \param value a string where the value of the first field will be placed
         (can be an empty string).

      \return true if there is a first field.
   */
   bool firstField( String &key, String &value );

   /** Enumerates the query fields - gets the next field.
      Returns true if there is a next field.
      \note The query element must have been previously parsed, or fields must have
      been explicitly inserted.

      \param key a string where the key of the first field will be placed
      \param value a string where the value of the first field will be placed
         (can be an empty string).
   */
   bool nextField( String &key, String &value );

   /** Enumerates the query fields - counts the fields.
      If the query has fields, or if fields have been explicitly set throug
      setField() method, returns the count of fields stored in this URI.

      \note The query element must have been previously parsed, or fields must have
      been explicitly inserted.

      \return count of fields in this query, 0 for none.
   */
   uint32 fieldCount();

   /** Returns the fragment part. */
   const String &fragment() const { return m_fragment; }

   /** Sets the fragment part. */
   void fragment( const String &s );

   /** Clears the content of this URI */
   void clear();

   /** Returns true if the URI is valid. */
   bool isValid() const { return m_bValid; }

   static void URLEncode( const String &source, String &target );
   static String URLEncode( const String &source )
   {
      String t;
      URLEncode( source, t );
      return t;
   }

   static void URLEncodePath( const String &source, String &target );
   static String URLEncodePath( const String &source )
   {
      String t;
      URLEncodePath( source, t );
      return t;
   }


   /**
     Decode an URI-URL encoded string.
     \param source the string to be decoded.
     \param target the target where to store the decoded string.
     \return true if the decoding was succesful, false otherwise.
   */
   static bool URLDecode( const String &source, String &target );
   static String URLDecode( const String &source )
   {
      String t;
      URLDecode( source, t );
      return t;
   }

   static unsigned char CharToHex( unsigned char ch )
   {
      return ch <= 9 ? '0' + ch : 'A' + (ch - 10);
   }

   static unsigned char HexToChar( unsigned char ch )
   {
      if ( ch >= '0' && ch <= '9' )
         return ch - '0';
      else if ( ch >= 'A' && ch <= 'F' )
         return ch - 'A'+ 10;
      else if ( ch >= 'a' && ch <= 'f' )
         return ch - 'a'+ 10;
      else
         return 0xFF;
   }
};

//==================================================
// Inline implementation
//

inline bool URI::isResDelim( uint32 chr )
{
   return isGenDelim( chr ) || isSubDelim( chr );
}

inline bool URI::isMainDelim( uint32 chr )
{
   return (chr == ':') || (chr == '?') || (chr == '#') || (chr == '@');
}

inline bool URI::isGenDelim( uint32 chr )
{
   return (chr == ':') || (chr == '/') || (chr == '?') ||
          (chr == '#') || (chr == '[') || (chr == ']') ||
          (chr == '@');
}

inline bool URI::isSubDelim( uint32 chr )
{
   return (chr == '!')  || (chr == '$') || (chr == '&') ||
          (chr == '\'') || (chr == '(') || (chr == ')') ||
          (chr == '*')  || (chr == '+') | (chr == ',') ||
          (chr == ';')  || (chr == '=');
}

inline bool URI::isUnreserved( uint32 chr )
{
   return (chr == '-')  || (chr == '_') || (chr == '.') || (chr == '~') ||
          (chr >= 'a' && chr <= 'z') ||
          (chr >= 'A' && chr <= 'Z') ||
          (chr >= '0' && chr <= '9');
}

} // Falcon namespace

#endif