Annotation of parser3/src/doc/string.dox, revision 1.6
1.1 paf 1: /** @page String String
2:
1.6 ! paf 3: In memory strings[String] are stored as letters[actually, cord objects from libgd cord library, see cord.h file]
! 4: plus list of fragments[String::Fragment] which contain language of fragment+it's length.
! 5:
! 6: Fragments that are received from stdout of scripts are considered clean(String::Language ::L_CLEAN),
! 7: but those from visitor - from stderr of scripts, from environment, from form,
! 8: from dist[table:load] or from sql server[table:sql]
! 9: are considered tainted(String::Language ::UL_TAINTED),
! 10: when string involved in different operations, it can be split, but all resulting parts
! 11: still remember languages of their fragments.
! 12: String can be written to Request::wcontext, then part of fragments can change their language.
! 13: Language is set to those fragments, which were not in particular language, but just tainted[L_TAINTED],
! 14: they become "dirty, but we need what to do to make them clean, that is we know their language".
! 15: Say,
1.1 paf 16: @verbatim
1.3 paf 17: ^void:sql{insert into news (title) values ('$form:title')]
1.1 paf 18: @endverbatim
1.6 ! paf 19: when parameter of sql is processed, with help of Temp_lang
! 20: we set "current language"[Request::flang],
! 21: and when string got written[Request::write_assign_lang]
! 22: L_TAINTED string from $form:title part of parameter of sql-method,
! 23: the one in apostrophes, got assigned an L_SQL language.
! 24:
! 25: String can be converted to normal Ñ-string by String::cstr().
! 26: If it is called with this parameter String::cstr(String::L_UNSPECIFIED) then
! 27: when it will be converted, fragment languages would be taken into consideration, and
! 28: corresponding cleansing performed.
! 29: Particular language can also be specified String::cstr(String::Language) [by default =L_AS_IS],
! 30: then all string fragments would forcibly considered to be in that language,
! 31: regardles of the language inside fragment.
! 32:
! 33: This is used, for instance, in work with file names
! 34: [ATTENTION: never ever use this construction if you care about your secret files,
! 35: it is used only as an example]:
1.1 paf 36: @verbatim
1.3 paf 37: $file[^table::load[$form:file_name]]
1.1 paf 38: @endverbatim
1.6 ! paf 39: here with normal $form:file_name processing would be L_HTML|L_OPTIMIZE_BIT, while we need L_FILE_SPEC,
! 40: and it would be stupid everywhere to do like we do in table:sql, insisting on {} parameters.
! 41:
! 42: Usual language of output is String::Language::L_HTML|String::Language::L_OPTIMIZE_BIT,
! 43: exception is CGI script, which got started outside of web-server,
! 44: in that case language String::Language::L_AS_IS is used.
1.1 paf 45:
1.6 ! paf 46: In fragments where language is marked as OPTIMIZED (String::Language::L_OPTIMIZE_BIT),
! 47: when they are converted into string String::cstr white spaces would be optimized:
! 48: out of several consequent characters would be left only first, others would be wiped off the result.
1.1 paf 49:
1.6 ! paf 50: When code works with char* it is assumed it is can never be 0.
! 51: k
1.5 paf 52: */
E-mail: