Product Code Database
Example Keywords: tie -gloves $41
   » » Wiki: Delimiter
Tag Wiki 'Delimiter'.
Tag

A delimiter is a sequence of one or more characters for specifying the boundary between separate, independent regions in , mathematical expressions or other . An example of a delimiter is the character, which acts as a field delimiter in a sequence of comma-separated values. Another example of a delimiter is the time gap used to separate letters and words in the transmission of .

In , delimiters are often used to specify the scope of an operation, and can occur both as isolated symbols (e.g., colon in "1 : 4") and as a pair of opposing-looking symbols (e.g., in \langle a, b \rangle).

Delimiters represent one of various means of specifying boundaries in a . Declarative notation, for example, is an alternate method (without the use of delimiters) that uses a length field at the start of a data stream to specify the number of characters that the data stream contains.

(1973). 9780719005558, Oxford University Press.
describing the method in Hollerith notation under the Fortran programming language.


Overview
Delimiters may be characterized as field and record delimiters, or as bracket delimiters.


Field and record delimiters
Field delimiters separate data fields. Record delimiters separate groups of fields.
(1993). 9789051991147, IOS Press.
p. 141

For example, the CSV format uses a comma as the delimiter between fields, and an indicator as the delimiter between records:

fname,lname,age,salary
nancy,davolio,33,$30000
erin,borakova,28,$25250
tony,raphael,35,$28700
     
This specifies a simple flat-file database table using the CSV file format.


Bracket delimiters
Bracket delimiters, also called block delimiters, region delimiters, or balanced delimiters, mark both the start and end of a region of text.
(2025). 9780596002893, O'Reilly.
p. 319
(1999). 9781558604421, Morgan Kaufmann.

Common examples of bracket delimiters include:

(2000). 9780596000271, O'Reilly.


Conventions
Historically, computing platforms have used certain delimiters by convention. The following tables depict a few examples for comparison.

Programming languages ( See also, Comparison of programming languages (syntax)).

Field and Record delimiters ( See also, , Control character).


Delimiter collision
Delimiter collision is a problem that occurs when an author or programmer introduces delimiters into text without actually intending them to be interpreted as boundaries between separate regions.
(2025). 9780596528126, Oxford University Press.
describing solutions for embedded-delimiter problems p. 472.
In the case of XML, for example, this can occur whenever an author attempts to specify an character.

In most file types there is both a field delimiter and a record delimiter, both of which are subject to collision. In the case of comma-separated values files, for example, field collision can occur whenever an author attempts to include a comma as part of a field value (e.g., salary = "$30,000"), and record delimiter collision would occur whenever a field contained multiple lines. Both record and field delimiter collision occur frequently in text files.

In some contexts, a malicious user or attacker may seek to exploit this problem intentionally. Consequently, delimiter collision can be the source of security vulnerabilities and exploits. Malicious users can take advantage of delimiter collision in languages such as and to deploy such well-known attacks as and cross-site scripting, respectively.


Solutions
Because delimiter collision is a very common problem, various methods for avoiding it have been invented. Some authors may attempt to avoid the problem by choosing a delimiter character (or sequence of characters) that is not likely to appear in the data stream itself. This ad hoc approach may be suitable, but it necessarily depends on a correct guess of what will appear in the data stream, and offers no security against malicious collisions. Other, more formal conventions are therefore applied as well.


ASCII delimited text
The ASCII and Unicode character sets were designed to solve this problem by the provision of non-printing characters that can be used as delimiters. These are the range from ASCII 28 to 31.

The use of ASCII 31 as a field separator and ASCII 30 solves the problem of both field and record delimiters that appear in a text data stream. Discussion on ASCII Delimited Text vs CSV and Tab Delimited


Escape character
One method for avoiding delimiter collision is to use . From a language design standpoint, these are adequate, but they have drawbacks:

  • text can be rendered unreadable when littered with numerous escape characters, a problem referred to as leaning toothpick syndrome (due to use of \ to escape / in regular expressions, leading to sequences such as "\/\/");
  • text becomes difficult to parse through regular expression
  • they require a mechanism to "escape the escapes" when not intended as escape characters; and
  • although easy to type, they can be cryptic to someone unfamiliar with the language.
    (2025). 9780596529376, O'Reilly.
  • they do not protect against injection attacks


Escape sequence
Escape sequences are similar to escape characters, except they usually consist of some kind of mnemonic instead of just a single character. One use is in that include a doublequote (") character. For example in , the code:

print "Nancy said \x22Hello World!\x22 to the crowd."; ### use \x22

produces the same output as:

print "Nancy said \"Hello World!\" to the crowd."; ### use escape char

One drawback of escape sequences, when used by people, is the need to memorize the codes that represent individual characters (see also: character entity reference, numeric character reference).


Dual quoting delimiters
In contrast to escape sequences and escape characters, dual delimiters provide yet another way to avoid delimiter collision. Some languages, for example, allow the use of either a single quote (') or a double quote (") to specify a string literal. For example, in :

print 'Nancy said "Hello World!" to the crowd.';

produces the desired output without requiring escapes. This approach, however, only works when the string does not contain both types of quotation marks.


Padding quoting delimiters
In contrast to escape sequences and escape characters, padding delimiters provide yet another way to avoid delimiter collision. , for example, uses double quotes as delimiters. This is similar to escaping the delimiter.

print "Nancy said ""Hello World!"" to the crowd."

produces the desired output without requiring escapes. Like regular escaping it can, however, become confusing when many quotes are used. The code to print the above source code would look more confusing:

print "print ""Nancy said """"Hello World!"""" to the crowd."""


Configurable alternative quoting delimiters
In contrast to dual delimiters, multiple delimiters are even more flexible for avoiding delimiter collision.

For example, in : print qq^Nancy doesn't want to say "Hello World!" anymore.^; print qq@Nancy doesn't want to say "Hello World!" anymore.@; print qq(Nancy doesn't want to say "Hello World!" anymore.); all produce the desired output through use of quote operators, which allow any convenient character to act as a delimiter. Although this method is more flexible, few languages support it. Perl and Ruby are two that do.

(2025). 9780596002145, O'Reilly. .
In Ruby, these are indicated as general delimited strings. p. 11


Content boundary
A content boundary is a special type of delimiter that is specifically designed to resist delimiter collision. It works by allowing the author to specify a sequence of characters that is guaranteed to always indicate a boundary between parts in a multi-part message, with no other possible interpretation.
(2025). 9780974094526, Javvin Technologies Inc..
p. 26

The delimiter is frequently generated from a random sequence of characters that is statistically improbable to occur in the content. This may be followed by an identifying mark such as a , a , or some other distinguishing mark. Alternatively, the content may be scanned to guarantee that a delimiter does not appear in the text. This may allow the delimiter to be shorter or simpler, and increase the human readability of the document. ( See e.g., MIME, ).


Whitespace or indentation
Some programming and computer languages allow the use of whitespace delimiters or as a means of specifying boundaries between independent regions in text.
(2025). 9783540416876, Oxford University Press.
Describes whitespace delimiters. p. 258.


Regular expression syntax
In specifying a regular expression, alternate delimiters may also be used to simplify the syntax for match and substitution operations in .
(2025). 9780596528126, Oxford University Press.
page 472.

For example, a simple match operation may be specified in Perl with the following syntax:

$string1 = 'Nancy said "Hello World!" to the crowd.'; # specify a target string print $string1 =~ m/aeiou+/; # match one or more vowels

The syntax is flexible enough to specify match operations with alternate delimiters, making it easy to avoid delimiter collision:

$string1 = 'Nancy said "http://Hello/World.htm" is not a valid address.'; # target string

print $string1 =~ m@http://@; # match using alternate regular expression delimiter print $string1 =~ m{http://}; # same as previous, but different delimiter print $string1 =~ m!http://!; # same as previous, but different delimiter.


Here document
A allows the inclusion of arbitrary content by describing a special end sequence. Many languages support this including , bash scripts, ruby and . A here document starts by describing what the end sequence will be and continues until that sequence is seen at the start of a new line. Perl operators and precedence

Here is an example in perl:

print < Newlines, commas, and other characters can cause delimiter collisions. ENDOFHEREDOC

This code would print:

It's very hard to encode a string with "certain characters".
     

Newlines, commas, and other characters can cause delimiter collisions.

By using a special end sequence all manner of characters are allowed in the string.


ASCII armor
Although principally used as a mechanism for text encoding of binary data, is a programming and systems administration technique that also helps to avoid delimiter collision in some circumstances.
(2025). 9780470852859, John Wiley and Sons.
(an example usage of ASCII armoring in encryption applications)
(2025). 9781584503477, Charles River Media. .
(an example usage of ASCII armoring in encryption applications)
This technique is contrasted from the other approaches described above because it is more complicated, and therefore not suitable for small applications and simple data storage formats. The technique employs a special encoding scheme, such as base64, to ensure that delimiter or other significant characters do not appear in transmitted data. The purpose is to prevent multilayered , i.e. for .

This technique is used, for example, in 's ASP.NET web development technology, and is closely associated with the "VIEWSTATE" component of that system.

(2025). 9780789729019, Que.
(describes the use of Base64 encoding and VIEWSTATE inside HTML source code)


Example
The following simplified example demonstrates how this technique works in practice.

The first code fragment shows a simple in which the VIEWSTATE value contains characters that are incompatible with the delimiters of the HTML tag itself:

This first code fragment is not well-formed, and would therefore not work properly in a "real world" deployed system.

To store arbitrary text in an HTML attribute, HTML entities can be used. In this case "&quot;" stands in for the double-quote:

Alternatively, any encoding could be used that doesn't include characters that have special meaning in the context, such as base64:

Or :

This prevents delimiter collision and ensures that incompatible characters will not appear inside the HTML code, regardless of what characters appear in the original (decoded) text.


See also


External links

Page 1 of 1
1
Page 1 of 1
1

Account

Social:
Pages:  ..   .. 
Items:  .. 

Navigation

General: Atom Feed Atom Feed  .. 
Help:  ..   .. 
Category:  ..   .. 
Media:  ..   .. 
Posts:  ..   ..   .. 

Statistics

Page:  .. 
Summary:  .. 
1 Tags
10/10 Page Rank
5 Page Refs
1s Time