This file is indexed.

/usr/share/php/texy/src/Texy/TexyModifier.php is in php-texy 2.6-1.

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
<?php

/**
 * This file is part of the Texy! (http://texy.info)
 * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 */


/**
 * Modifier processor.
 *
 * Modifiers are texts like .(title)[class1 class2 #id]{color: red}>^
 *   .         starts with dot
 *   (...)     title or alt modifier
 *   [...]     classes or ID modifier
 *   {...}     inner style modifier
 *   < > <> =  horizontal align modifier
 *   ^ - _     vertical align modifier
 *
 * @author     David Grudl
 */
final class TexyModifier extends TexyObject
{
	/** @var string */
	public $id;

	/** @var array of classes (as keys) */
	public $classes = array();

	/** @var array of CSS styles */
	public $styles = array();

	/** @var array of HTML element attributes */
	public $attrs = array();

	/** @var string */
	public $hAlign;

	/** @var string */
	public $vAlign;

	/** @var string */
	public $title;

	/** @var string */
	public $cite;

	/** @var array  list of properties which are regarded as HTML element attributes */
	public static $elAttrs = array(
		'abbr'=>1,'accesskey'=>1,'align'=>1,'alt'=>1,'archive'=>1,'axis'=>1,'bgcolor'=>1,'cellpadding'=>1,
		'cellspacing'=>1,'char'=>1,'charoff'=>1,'charset'=>1,'cite'=>1,'classid'=>1,'codebase'=>1,'codetype'=>1,
		'colspan'=>1,'compact'=>1,'coords'=>1,'data'=>1,'datetime'=>1,'declare'=>1,'dir'=>1,'face'=>1,'frame'=>1,
		'headers'=>1,'href'=>1,'hreflang'=>1,'hspace'=>1,'ismap'=>1,'lang'=>1,'longdesc'=>1,'name'=>1,
		'noshade'=>1,'nowrap'=>1,'onblur'=>1,'onclick'=>1,'ondblclick'=>1,'onkeydown'=>1,'onkeypress'=>1,
		'onkeyup'=>1,'onmousedown'=>1,'onmousemove'=>1,'onmouseout'=>1,'onmouseover'=>1,'onmouseup'=>1,'rel'=>1,
		'rev'=>1,'rowspan'=>1,'rules'=>1,'scope'=>1,'shape'=>1,'size'=>1,'span'=>1,'src'=>1,'standby'=>1,
		'start'=>1,'summary'=>1,'tabindex'=>1,'target'=>1,'title'=>1,'type'=>1,'usemap'=>1,'valign'=>1,
		'value'=>1,'vspace'=>1,
	);


	/**
	 * @param  string modifier to parse
	 */
	public function __construct($mod = NULL)
	{
		$this->setProperties($mod);
	}


	public function setProperties($mod)
	{
		if (!$mod) {
			return;
		}

		$p = 0;
		$len = strlen($mod);

		while ($p < $len) {
			$ch = $mod[$p];

			if ($ch === '(') { // title
				$a = strpos($mod, ')', $p) + 1;
				$this->title = Texy::unescapeHtml(trim(substr($mod, $p + 1, $a - $p - 2)));
				$p = $a;

			} elseif ($ch === '{') { // style & attributes
				$a = strpos($mod, '}', $p) + 1;
				foreach (explode(';', substr($mod, $p + 1, $a - $p - 2)) as $value) {
					$pair = explode(':', $value, 2);
					$prop = strtolower(trim($pair[0]));
					if ($prop === '' || !isset($pair[1])) {
						continue;
					}
					$value = trim($pair[1]);

					if (isset(self::$elAttrs[$prop])) { // attribute
						$this->attrs[$prop] = $value;
					} elseif ($value !== '') { // style
						$this->styles[$prop] = $value;
					}
				}
				$p = $a;

			} elseif ($ch === '[') { // classes & ID
				$a = strpos($mod, ']', $p) + 1;
				$s = str_replace('#', ' #', substr($mod, $p + 1, $a - $p - 2));
				foreach (explode(' ', $s) as $value) {
					if ($value === '') {
						continue;
					} elseif ($value{0} === '#') {
						$this->id = substr($value, 1);
					} else {
						$this->classes[$value] = TRUE;
					}
				}
				$p = $a;

			} elseif ($ch === '^') { // alignment
				$this->vAlign = 'top'; $p++;
			} elseif ($ch === '-') {
				$this->vAlign = 'middle'; $p++;
			} elseif ($ch === '_') {
				$this->vAlign = 'bottom'; $p++;
			} elseif ($ch === '=') {
				$this->hAlign = 'justify'; $p++;
			} elseif ($ch === '>') {
				$this->hAlign = 'right'; $p++;
			} elseif (substr($mod, $p, 2) === '<>') {
				$this->hAlign = 'center'; $p+=2;
			} elseif ($ch === '<') {
				$this->hAlign = 'left'; $p++;
			} else {
				break;
			}
		}
	}


	/**
	 * Decorates TexyHtml element.
	 * @param  Texy   base Texy object
	 * @param  TexyHtml  element to decorate
	 * @return void
	 */
	public function decorate($texy, $el)
	{
		$elAttrs = & $el->attrs;

		// tag & attibutes
		$tmp = $texy->allowedTags; // speed-up
		if (!$this->attrs) {

		} elseif ($tmp === Texy::ALL) {
			$elAttrs = $this->attrs;
			$el->validateAttrs($texy->dtd);

		} elseif (is_array($tmp) && isset($tmp[$el->getName()])) {
			$tmp = $tmp[$el->getName()];

			if ($tmp === Texy::ALL) {
				$elAttrs = $this->attrs;

			} elseif (is_array($tmp) && count($tmp)) {
				$tmp = array_flip($tmp);
				foreach ($this->attrs as $key => $value) {
					if (isset($tmp[$key])) {
						$el->attrs[$key] = $value;
					}
				}
			}
			$el->validateAttrs($texy->dtd);
		}

		// title
		if ($this->title !== NULL) {
			$elAttrs['title'] = $texy->typographyModule->postLine($this->title);
		}

		// classes & ID
		if ($this->classes || $this->id !== NULL) {
			$tmp = $texy->_classes; // speed-up
			if ($tmp === Texy::ALL) {
				foreach ($this->classes as $value => $foo) {
					$elAttrs['class'][] = $value;
				}
				$elAttrs['id'] = $this->id;
			} elseif (is_array($tmp)) {
				foreach ($this->classes as $value => $foo) {
					if (isset($tmp[$value])) {
						$elAttrs['class'][] = $value;
					}
				}

				if (isset($tmp['#' . $this->id])) {
					$elAttrs['id'] = $this->id;
				}
			}
		}

		// styles
		if ($this->styles) {
			$tmp = $texy->_styles; // speed-up
			if ($tmp === Texy::ALL) {
				foreach ($this->styles as $prop => $value) {
					$elAttrs['style'][$prop] = $value;
				}
			} elseif (is_array($tmp)) {
				foreach ($this->styles as $prop => $value) {
					if (isset($tmp[$prop])) {
						$elAttrs['style'][$prop] = $value;
					}
				}
			}
		}

		// horizontal align
		if ($this->hAlign) {
			if (empty($texy->alignClasses[$this->hAlign])) {
				$elAttrs['style']['text-align'] = $this->hAlign;
			} else {
				$elAttrs['class'][] = $texy->alignClasses[$this->hAlign];
			}
		}

		// vertical align
		if ($this->vAlign) {
			if (empty($texy->alignClasses[$this->vAlign])) {
				$elAttrs['style']['vertical-align'] = $this->vAlign;
			} else {
				$elAttrs['class'][] = $texy->alignClasses[$this->vAlign];
			}
		}

		return $el;
	}

}