For reference to the assumed RELS-EXT see the following spec in CurateND
 @see https://github.com/ndlib/curate_nd/blob/115efec2e046257282a86fe2cd98c7d229d04cf9/spec/repository_models/osf_archive_spec.rb#L97
162159
def apply_previous_archived_version_if_applicable(rels_ext)
      # If a previously archived pid was passed in, use it to set pav:previousVersion
      # If not, check SOLR for one.
      pid = previously_archived_pid_finder.call(archive_type, osf_project_identifier)
      pid = ROF::Utility.check_solr_for_previous(config, osf_project_identifier) if pid.nil?
      rels_ext['pav:previousVersion'] = pid if pid
      rels_ext
    end
348405
function validateExcess(dir, file, shrinkwrap, opts, scope, cb) {  // jshint ignore:line
    file = file.toLowerCase();

    // don't consider node_modules/.bin
    if (file === '.bin') {
        return cb();
    }

    // consider top-level scoped packages only; e.g. those nested at the level
    // node_modules/{*}
    var isScopedDir = file[0] === '@';
    if (isScopedDir) {
        return findExcess(path.join(dir, scope + '/' + file), shrinkwrap, opts,
          file, cb);
    }

    // the file is in excess if it does not exist in the package.json's
    // dev dependencies; this step is skipped if we are not analyzing
    // dev dependencies
    if (opts.dev && shrinkwrap.devDependencies &&
        lowercaseContains(Object.keys(shrinkwrap.devDependencies), file)) {
        return cb();
    }

    // the file is in excess if it does not exist in the package.json's
    // regular dependencies
    if (shrinkwrap.dependencies && lowercaseContains(Object.keys(shrinkwrap.dependencies), file)) {
        return cb();
    }

    // if all checks pass up until this point, the file is in excess
    return cb(null, [file]);
}
934143
function absoluteURI(uri, base) {
    if (uri.substr(0, 2) == './')
      uri = uri.substr(2);

    // absolute urls are left in tact
    if (uri.match(absUrlRegEx) || uri.match(protocolRegEx))
      return uri;
    
    var baseParts = base.split('/');
    var uriParts = uri.split('/');
    
    baseParts.pop();
    
    while (curPart = uriParts.shift())
      if (curPart == '..')
        baseParts.pop();
      else
        baseParts.push(curPart);
    
    return baseParts.join('/');
  }
817463
def contents(revision=nil, cmd_options={})
      revision ||= 'tip'
      hg(manifest_cmd(revision), cmd_options).tap do |res|
        if RUBY_VERSION >= '1.9.1'
          res.force_encoding('utf-8')
        end
      end
    end
1353060
def build_archive_record
      this_rof = {}
      this_rof['owner'] = project['owner']
      this_rof['type'] = 'OsfArchive'
      this_rof['rights'] = map_rights
      this_rof['rels-ext'] = map_rels_ext
      this_rof['metadata'] = map_metadata
      this_rof['files'] = [source_slug + '.tar.gz']
      this_rof
    end
1118832
def match_extension(f):
    ''''''
    (root,ext) = os.path.splitext(f)
    return ext.lower() in extensions
1164360
def retcode(plugin, args='', key_name=None):
    '''
    
    '''
    data = {}

    # Remove all the spaces, the key must not have any space
    if key_name is None:
        key_name = _format_dict_key(args, plugin)

    data[key_name] = {}

    status = _execute_cmd(plugin, args, 'cmd.retcode')
    data[key_name]['status'] = status

    return data
467433
function rdpExtendedInfos(opt) {
	var self = {
		clientAddressFamily : new type.UInt16Le(AfInet.AfInet),
	    cbClientAddress : new type.UInt16Le(function() {
        	return self.clientAddress.size();
        }),
	    clientAddress : new type.BinaryString(new Buffer('\x00', 'ucs2'),{ readLength : new type.CallableValue(function() {
	    	return self.cbClientAddress;
	    }) }),
	    cbClientDir : new type.UInt16Le(function() {
        	return self.clientDir.size();
        }),
	    clientDir : new type.BinaryString(new Buffer('\x00', 'ucs2'), { readLength : new type.CallableValue(function() {
	    	return self.cbClientDir;
	    }) }),
	    clientTimeZone : new type.BinaryString(new Buffer(Array(172 + 1).join("\x00"))),
	    clientSessionId : new type.UInt32Le(),
	    performanceFlags : new type.UInt32Le()
	};
	return new type.Component(self, opt);
}
913084
def resolve_revision
      revision = @repository.tag.to_s.strip
      if revision.empty?
        revision = nil
      elsif (revision =~ SVN_REVISION_REGEX).nil?
        raise RetrieverError, "Revision reference contained illegal characters: #{revision.inspect}"
      end
      # timestamps can contain spaces; surround them with double quotes.
      revision = revision.inspect if revision.index(' ')
      revision
    end
357452
function rewrite_extension(source, ext) {
  var source_ext = path.extname(source);
  return (source_ext === ext) ? source : (source + ext);
}
187827
function determineSafety (doc) {
	log(`determineSafety: doc ${JSON.stringify(doc)}`);

	const tmpFile = `/tmp/validate-uploads-${process.pid}.json`;
	try {
		// Create query for check-regex.
		const checkRegexQuery = {
			pattern: doc.pattern,
			validateVuln_language: doc.language,
			validateVuln_nPumps: 250000,
			validateVuln_timeLimit: 1,
			useCache: 0 // Using the cache would be somewhat circular.
		};
		log(`checkRegex query: ${JSON.stringify(checkRegexQuery)}`);
		fs.writeFileSync(tmpFile, JSON.stringify(checkRegexQuery));

		// Run query.
		const cmd = `${process.env.VULN_REGEX_DETECTOR_ROOT}/bin/check-regex.pl ${tmpFile} 2>/dev/null`;
		log(`determineSafety: cmd ${cmd}`);
		const stdout = childProcess.execSync(cmd, {encoding: 'utf8'});
		const result = JSON.parse(stdout);
		log(`determineSafety: result ${JSON.stringify(result)}`);

		// Interpret result.
		if (result.isVulnerable && result.validateReport.timedOut) { // Vulnerable: detector plus validation
			log(`Vulnerable!`);
			return {
				_id: doc._id,
				pattern: doc.pattern,
				language: doc.language,
				result: PATTERN_VULNERABLE,
				evilInput: result.validateReport.evilInput
			};
		} else {
			// Detectors timed out or said it was safe.
			// NB This permits false 'SAFE' reports into the database.
			log(`Not vulnerable (or analysis timed out).`);
			return {
				_id: doc._id,
				pattern: doc.pattern,
				language: doc.language,
				result: PATTERN_SAFE
			};
		}
	} catch (e) {
		log(`Error: ${JSON.stringify(e)}`);
		return undefined;
	} finally {
		fs.unlinkSync(tmpFile);
	}
}
1356522
function (sUrl, sBase) {
			return new URI(sUrl).absoluteTo(sBase).toString()
				.replace(rEscapedTick, "'")
				.replace(rEscapedOpenBracket, "(")
				.replace(rEscapedCloseBracket, ")");
		}
818683
function ProcessExifDir($DirStart, $OffsetBase, $ExifLength)
    {

        $NumDirEntries = 0;
        $ValuePtr = array();

        $NumDirEntries = $this->Get16u($DirStart[0], $DirStart[1]);


        $this->debug("<br>Directory with $NumDirEntries entries\n");

        for ($de = 0; $de < $NumDirEntries; $de++)
        {
            //$DirEntry = array_slice($DirStart,2+12*$de);
            $DirEntry = substr($DirStart, 2 + 12 * $de);

            $Tag = $this->Get16u($DirEntry[0], $DirEntry[1]);
            $Format = $this->Get16u($DirEntry[2], $DirEntry[3]);
            $Components = $this->Get32u($DirEntry[4], $DirEntry[5], $DirEntry[6], $DirEntry[7]);

            /**
            if ((Format-1) >= NUM_FORMATS) {
            // (-1) catches illegal zero case as unsigned underflows to positive large.
            ErrNonfatal("Illegal number format %d for tag %04x", Format, Tag);
            continue;
            }
             */

            $ByteCount = $Components * $this->BytesPerFormat[$Format];

            if ($ByteCount > 4)
            {
                $OffsetVal = $this->Get32u($DirEntry[8], $DirEntry[9], $DirEntry[10], $DirEntry[11]);
                if ($OffsetVal + $ByteCount > $ExifLength)
                {
                    $this->debug("Illegal value pointer($OffsetVal) for tag $Tag", 1);
                }
                //$ValuePtr = array_slice($OffsetBase,$OffsetVal);
                $ValuePtr = substr($OffsetBase, $OffsetVal);
            }
            else
            {
                //$ValuePtr = array_slice($DirEntry,8);
                $ValuePtr = substr($DirEntry, 8);
            }

            switch ($Tag)
            {

                case TAG_MAKE:
                    $this->ImageInfo["h"]["make"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;

                case TAG_MODEL:
                    $this->ImageInfo["h"]["model"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;

                case TAG_DATETIME_ORIGINAL:
                    $this->ImageInfo[TAG_DATETIME_ORIGINAL] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    $this->ImageInfo["h"]["DateTime"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;

                case TAG_USERCOMMENT:
                    // Olympus has this padded with trailing spaces.  Remove these first.
                    for ($a = $ByteCount; ;)
                    {
                        $a--;
                        if ($ValuePtr[$a] == ' ')
                        {
                            //$ValuePtr[$a] = '\0';
                        }
                        else
                        {
                            break;
                        }
                        if ($a == 0)
                        {
                            break;
                        }
                    }

                    $tmp = '';
                    // Copy the comment
                    if (($ValuePtr[0] . $ValuePtr[1] . $ValuePtr[2] . $ValuePtr[3] . $ValuePtr[4]) == "ASCII")
                    {
                        for ($a = 5; $a < 10; $a++)
                        {
                            $c = $ValuePtr[$a];
                            if ($c != '\0' && $c != ' ')
                            {
                                $tmp = substr($ValuePtr, 0, $ByteCount);
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (($ValuePtr[0] . $ValuePtr[1] . $ValuePtr[2] . $ValuePtr[3] . $ValuePtr[4] . $ValuePtr[5] . $ValuePtr[6]) == "Unicode")
                        {
                            $tmp = substr($ValuePtr, 0, $ByteCount);
                            //  * Handle Unicode characters here...
                        }
                        else
                        {
                            //$this->ImageInfo[TAG_USERCOMMENT] = implode("",array_slice($ValuePtr,0,$ByteCount));
                            $tmp = substr($ValuePtr, 0, $ByteCount);
                        }
                    }
                    $this->ImageInfo['h']["exifComment"] = $this->string_format($tmp);
                    break;

                case TAG_ARTIST:
                    $this->ImageInfo['h']["artist"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;

                case TAG_COPYRIGHT:
                    $this->ImageInfo['h']["copyright"] = htmlentities(substr($ValuePtr, 0, $ByteCount));
                    break;

                case TAG_FNUMBER:
                    // Simplest way of expressing aperture, so I trust it the most.
                    // (overwrite previously computd value if there is one)
                    $tmp = $this->ConvertAnyFormat(substr($ValuePtr, 0), $Format);
                    $this->ImageInfo['h']["fnumber"] = sprintf("f/%3.1f", (double)$tmp[0]);
                    break;

                case TAG_APERTURE:
                case TAG_MAXAPERTURE:
                    // More relevant info always comes earlier, so only use this field if we don't
                    // have appropriate aperture information yet.
                    if (!isset($this->ImageInfo['h']["aperture"]))
                    {
                        $tmpArr = $this->ConvertAnyFormat($ValuePtr, $Format);
                        $this->ImageInfo['h']["aperture"] = exp($tmpArr[0] * log(2) * 0.5);
                    }
                    break;

                case TAG_FOCALLENGTH:
                    // Nice digital cameras actually save the focal length as a function
                    // of how farthey are zoomed in.
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["focalLength"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
                    if (isset($this->ImageInfo['h']["CCDWidth"]))
                    {
                        $this->ImageInfo['h']["focalLength"] .= sprintf("(35mm equivalent: %dmm)", (int)($tmp[0] / $this->ImageInfo['h']["CCDWidth"] * 36 + 0.5));
                    }
                    break;

                case TAG_SUBJECT_DISTANCE:
                    // Inidcates the distacne the autofocus camera is focused to.
                    // Tends to be less accurate as distance increases.
                    //$this->ImageInfo["h"]["Distance"] =  $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["Distance"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
                    if ($this->ImageInfo['h']["Distance"] < 0)
                    {
                        $this->ImageInfo['h']["focusDistance"] = "Infinite";
                    }
                    else
                    {
                        $this->ImageInfo['h']["focusDistance"] = sprintf("%4.2fm", (double)$this->ImageInfo['h']["Distance"]);
                    }


                    break;

                case TAG_EXPOSURETIME:
                    // Simplest way of expressing exposure time, so I trust it most.
                    // (overwrite previously computd value if there is one)
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["exposureTime"] = sprintf("%6.3f s (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
                    if ($tmp[0] <= 0.5)
                    {
                        $this->ImageInfo['h']["exposureTime"] .= sprintf(" (1/%d)", (int)(0.5 + 1 / $tmp[0]));
                    }
                    break;

                case TAG_SHUTTERSPEED:
                    // More complicated way of expressing exposure time, so only use
                    // this value if we don't already have it from somewhere else.
                    if (isset($this->ImageInfo['TAG_EXPOSURETIME']) && $this->ImageInfo['TAG_EXPOSURETIME'] == 0)
                    {
                        $sp = $this->ConvertAnyFormat($ValuePtr, $Format);
                        $this->ImageInfo[TAG_SHUTTERSPEED] = (1 / exp($sp[0] * log(2)));
                    }
                    break;

                case TAG_FLASH:
                    $this->ImageInfo["h"]["flashUsed"] = "No";
                    if ($this->ConvertAnyFormat($ValuePtr, $Format) & 7)
                    {
                        $this->ImageInfo["h"]["flashUsed"] = "Yes";
                    }
                    break;

                case TAG_ORIENTATION:
                    $this->ImageInfo[TAG_ORIENTATION] = $this->ConvertAnyFormat($ValuePtr, $Format);
                    if ($this->ImageInfo[TAG_ORIENTATION] < 1 || $this->ImageInfo[TAG_ORIENTATION] > 8)
                    {
                        $this->debug(sprintf("Undefined rotation value %d", $this->ImageInfo[TAG_ORIENTATION], 0), 1);
                        $this->ImageInfo[TAG_ORIENTATION] = 0;
                    }
                    break;

                case TAG_EXIF_IMAGELENGTH:
                    //       * Image height
                    $a = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
                    if ($this->ExifImageLength < $a)
                    {
                        $this->ExifImageLength = $a;
                    }
                    $this->ImageInfo[TAG_EXIF_IMAGELENGTH] = $this->ExifImageLength;
                    $this->ImageInfo["h"]["Height"] = $this->ExifImageLength;
                    break;
                case TAG_EXIF_IMAGEWIDTH:
                    // Use largest of height and width to deal with images that have been
                    // rotated to portrait format.
                    $a = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
                    if ($this->ExifImageWidth < $a)
                    {
                        $this->ExifImageWidth = $a;
                    }
                    $this->ImageInfo[TAG_EXIF_IMAGEWIDTH] = $this->ExifImageWidth;
                    $this->ImageInfo["h"]["Width"] = $this->ExifImageWidth;

                    break;

                case TAG_FOCALPLANEXRES:
                    $this->FocalplaneXRes = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->FocalplaneXRes = $this->FocalplaneXRes[0];
                    $this->ImageInfo[TAG_FOCALPLANEXRES] = $this->FocalplaneXRes[0];
                    break;

                case TAG_FOCALPLANEUNITS:
                    switch ($this->ConvertAnyFormat($ValuePtr, $Format))
                    {
                        case 1:
                            $this->FocalplaneUnits = 25.4;
                            break; // inch
                        case 2:
                            // According to the information I was using, 2 means meters.
                            // But looking at the Cannon powershot's files, inches is the only
                            // sensible value.
                            $this->FocalplaneUnits = 25.4;
                            break;

                        case 3:
                            $this->FocalplaneUnits = 10;
                            break; // centimeter
                        case 4:
                            $this->FocalplaneUnits = 1;
                            break; // milimeter
                        case 5:
                            $this->FocalplaneUnits = .001;
                            break; // micrometer
                    }
                    $this->ImageInfo[TAG_FOCALPLANEUNITS] = $this->FocalplaneUnits;
                    break;

                // Remaining cases contributed by: Volker C. Schoech (schoech@gmx.de)

                case TAG_EXPOSURE_BIAS:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["exposureBias"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
                    break;

                case TAG_WHITEBALANCE:
                    $tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("1" => "Sunny", "2" => "fluorescent", "3" => "incandescent");
                    $this->ImageInfo['h']["whiteBalance"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Cloudy");
                    break;

                case TAG_METERING_MODE:
                    $tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);

                    $tmpArr = array("2" => "center weight", "3" => "spot", "5" => "matrix");
                    $this->ImageInfo['h']["meteringMode"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;

                case TAG_EXPOSURE_PROGRAM:
                    $tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("2" => "program (auto)", "3" => "aperture priority (semi-auto)", "4" => "shutter priority (semi-auto)");
                    $this->ImageInfo['h']["exposure"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");

                    break;

                case TAG_ISO_EQUIVALENT:
                    $tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
                    if ($tmp < 50)
                    {
                        $tmp *= 200;
                    }
                    $this->ImageInfo['h']["isoEquiv"] = sprintf("%2d", (int)$tmp);
                    break;

                case TAG_COMPRESSION_LEVEL:
                    $tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("1" => "Basic", "2" => "Normal", "4" => "Fine");
                    $this->ImageInfo['h']["jpegQuality"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;

                case TAG_THUMBNAIL_OFFSET:
                    //$this->ThumbnailOffset = $this->ConvertAnyFormat($ValuePtr, $Format);
                    //$this->DirWithThumbnailPtrs = $DirStart;
                    break;

                case TAG_THUMBNAIL_LENGTH:
                    //$this->ThumbnailSize = $this->ConvertAnyFormat($ValuePtr, $Format);
                    //$this->ImageInfo[TAG_THUMBNAIL_LENGTH] = $this->ThumbnailSize;
                    break;

                //----------------------------------------------
                case TAG_IMAGE_DESC:
                    $this->ImageInfo['h']["imageDesc"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_X_RESOLUTION:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["xResolution"] = sprintf("%4.2f (%d/%d) %s", (double)$tmp[0], $tmp[1][0], $tmp[1][1], $this->ImageInfo['h']["resolutionUnit"]);
                    break;
                case TAG_Y_RESOLUTION:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["yResolution"] = sprintf("%4.2f (%d/%d) %s", (double)$tmp[0], $tmp[1][0], $tmp[1][1], $this->ImageInfo['h']["resolutionUnit"]);
                    break;
                case TAG_RESOLUTION_UNIT:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("2" => "Inches", "3" => "Centimeters");

                    $this->ImageInfo['h']["resolutionUnit"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;
                case TAG_SOFTWARE:
                    $this->ImageInfo['h']["software"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_FILE_MODDATE;
                    $this->ImageInfo['h']["fileModifiedDate"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_YCBCR_POSITIONING:
                    $this->ImageInfo['h']["YCbCrPositioning"] = $this->ConvertAnyFormat($ValuePtr, $Format);
                    break;
                case TAG_EXIF_VERSION:
                    $this->ImageInfo['h']["exifVersion"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_DATE_TIME_DIGITIZED:
                    $this->ImageInfo['h']["dateTimeDigitized"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_COMPONENT_CONFIG: // need more tests for this
                    $tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);

                    $tmpArr = array("0" => "Does Not Exists", "1" => "Y", "2" => "Cb", "3" => "Cr", "4" => "R", "5" => "G", "6" => "B");

                    if (strlen($tmp) < 4)
                    {
                        $this->ImageInfo['h']["componentConfig"] = $tmpArr["0"];
                    }
                    else
                    {
                        for ($i = 0; $i < strlen($tmp); $i++)
                        {
                            if ($tmp["$i"] != 0)
                            {
                                $this->ImageInfo['h']["componentConfig"] .= $tmpArr[$tmp["$i"]];
                            }
                        }
                    }
                    break;
                case TAG_MAKER_NOTE:
                    //$this->ImageInfo['h']["makerNote"] = substr($ValuePtr,0,$ByteCount);
                    $this->ImageInfo['h']["makerNote"] = "NOT IMPLEMENTED";
                    break;
                case TAG_SUB_SEC_TIME:
                    $this->ImageInfo['h']["subSectionTime"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_SUB_SEC_TIME_ORIG:
                    $this->ImageInfo['h']["subSectionTimeOriginal"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_SUB_SEC_TIME_DIGITIZED:
                    $this->ImageInfo['h']["subSectionTimeDigtized"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_FLASHPIX_VER:
                    $this->ImageInfo['h']["flashpixVersion"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_COLOR_SPACE:
                    $this->ImageInfo['h']["colorSpace"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_RELATED_SOUND_FILE:
                    $this->ImageInfo['h']["relatedSoundFile"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_GPS_LATITUDE_REF:
                    $this->ImageInfo['h']["GPSLatitudeRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    $this->ImageInfo['h']["GPSLatitudeRef"] = trim($this->ImageInfo['h']["GPSLatitudeRef"]);
                    $tmp = substr($this->ImageInfo['h']["GPSLatitudeRef"], 0, 1);
                    if ($tmp == "S")
                    {
                        $this->ImageInfo['h']["GPSLatitudeRef"] = "South latitude";
                    }
                    else
                    {
                        if ($tmp == "N")
                        {
                            $this->ImageInfo['h']["GPSLatitudeRef"] = "North latitude";
                        }
                        else
                        {
                            $this->ImageInfo['h']["GPSLatitudeRef"] = "Reserved";
                        }
                    }
                    break;
                case TAG_GPS_LATITUDE:
                    $tmp = substr($ValuePtr, 0, $ByteCount);

                    $this->ImageInfo['h']["GPSLatitude"]["Degrees"] = ord(substr($tmp, 0, 1));
                    $this->ImageInfo['h']["GPSLatitude"]["Minutes"] = ord(substr($tmp, 1, 1));
                    $this->ImageInfo['h']["GPSLatitude"]["Seconds"] = ord(substr($tmp, 2, 1));
                    break;

                case TAG_GPS_LONGITUDE:
                    $tmp = substr($ValuePtr, 0, $ByteCount);

                    $this->ImageInfo['h']["GPSLongitude"]["Degrees"] = ord(substr($tmp, 0, 1));
                    $this->ImageInfo['h']["GPSLongitude"]["Minutes"] = ord(substr($tmp, 1, 1));
                    $this->ImageInfo['h']["GPSLongitude"]["Seconds"] = ord(substr($tmp, 2, 1));

                    break;

                case TAG_GPS_LONGITUDE_REF:
                    $this->ImageInfo['h']["GPSLongitudeRef"] = substr($ValuePtr, 0, $ByteCount);
                    $this->ImageInfo['h']["GPSLongitudeRef"] = trim($this->ImageInfo['h']["GPSLongitudeRef"]);
                    $tmp = substr($this->ImageInfo['h']["GPSLongitudeRef"], 0, 1);
                    if ($tmp == "E")
                    {
                        $this->ImageInfo['h']["GPSLongitudeRef"] = "East Longitude";
                    }
                    else
                    {
                        if ($tmp == "W")
                        {
                            $this->ImageInfo['h']["GPSLongitudeRef"] = "West Longitude";
                        }
                        else
                        {
                            $this->ImageInfo['h']["GPSLongitudeRef"] = "Reserved";
                        }
                    }

                    break;


                case TAG_GPS_TrackRef: /* Reference for direction of movement    GPSTrackRef */
                    $this->ImageInfo['h']["GPSTrackRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;


                case TAG_GPS_GPSTrack: /* Direction of movement					GPSTrack */
                    $this->ImageInfo['h']["GPSTrack"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_GPS_GPSImgDirectionRef: /* Reference for direction of image       GPSImgDirectionRef */
                    $this->ImageInfo['h']["GPSImgDirectionRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_GPS_GPSImgDirection: /* Direction of image                     GPSImgDirection     */
                    $this->ImageInfo['h']["GPSImgDirection"] = $this->ConvertAnyFormat($ValuePtr, $Format);
                    break;
                case TAG_GPS_GPSMapDatum: /* Geodetic survey data used              GPSMapDatum         */
                    $this->ImageInfo['h']["GPSMapDatum"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_GPS_GPSDestLatitudeRef: /* Reference for latitude of destination  GPSDestLatitudeRef  */
                    $this->ImageInfo['h']["GPSDestLatitudeRef"] = substr($ValuePtr, 0, $ByteCount);
                    $this->ImageInfo['h']["GPSDestLatitudeRef"] = trim($this->ImageInfo['h']["GPSDestLatitudeRef"]);
                    $tmp = substr($this->ImageInfo['h']["GPSDestLatitudeRef"], 0, 1);
                    if ($tmp == "S")
                    {
                        $this->ImageInfo['h']["GPSDestLatitudeRef"] = "South latitude";
                    }
                    else
                    {
                        if ($tmp == "N")
                        {
                            $this->ImageInfo['h']["GPSDestLatitudeRef"] = "North latitude";
                        }
                        else
                        {
                            $this->ImageInfo['h']["GPSDestLatitudeRef"] = "Reserved";
                        }
                    }

                    break;
                case TAG_GPS_GPSDestLatitude: /* Latitude of destination                GPSDestLatitude     */
                    $tmp = substr($ValuePtr, 0, $ByteCount);

                    $this->ImageInfo['h']["GPSDestLatitude"]["Degrees"] = ord(substr($tmp, 0, 1));
                    $this->ImageInfo['h']["GPSDestLatitude"]["Minutes"] = ord(substr($tmp, 1, 1));
                    $this->ImageInfo['h']["GPSDestLatitude"]["Seconds"] = ord(substr($tmp, 2, 1));

                    break;
                case TAG_GPS_GPSDestLongitudeRef: /* Reference for longitude of destination GPSDestLongitudeRef 21     */
                    $this->ImageInfo['h']["GPSDestLongitudeRef"] = substr($ValuePtr, 0, $ByteCount);
                    $this->ImageInfo['h']["GPSDestLongitudeRef"] = trim($this->ImageInfo['h']["GPSDestLongitudeRef"]);
                    $tmp = substr($this->ImageInfo['h']["GPSDestLongitudeRef"], 0, 1);
                    if ($tmp == "E")
                    {
                        $this->ImageInfo['h']["GPSDestLongitudeRef"] = "East Longitude";
                    }
                    else
                    {
                        if ($tmp == "W")
                        {
                            $this->ImageInfo['h']["GPSDestLongitudeRef"] = "West Longitude";
                        }
                        else
                        {
                            $this->ImageInfo['h']["GPSDestLongitudeRef"] = "Reserved";
                        }
                    }

                    break;
                case TAG_GPS_GPSDestLongitude: /* Longitude of destination               GPSDestLongitude    22     */
                    $this->ImageInfo['h']["GPSDestLongitude"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_GPS_GPSDestBearingRef: /* Reference for bearing of destination   GPSDestBearingRef   23     */
                    $this->ImageInfo['h']["GPSDestBearingRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_GPS_GPSDestBearing: /* Bearing of destination                 GPSDestBearing      24     */
                    $this->ImageInfo['h']["GPSDestBearing"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_GPS_GPSDestDistanceRef: /* Reference for distance to destination  GPSDestDistanceRef  25     */
                    $this->ImageInfo['h']["GPSDestDistanceRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_GPS_GPSDestDistance: /* Distance to destination                GPSDestDistance     26     */
                    //$this->ImageInfo['h']["GPSDestDistance"] = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["GPSDestDistance"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);;
                    break;
                case TAG_GPS_GPSProcessingMethod: /* Name of GPS processing method          GPSProcessingMethod 27     */
                    //$this->ImageInfo['h']["GPSProcessingMethod"] = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["GPSProcessingMethod"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);;
                    break;
                case TAG_GPS_GPSAreaInformation: /* Name of GPS area                       GPSAreaInformation  28     */
                    $this->ImageInfo['h']["GPSAreaInformation"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_GPS_GPSDateStamp: /* GPS date                               GPSDateStamp        29     */
                    $this->ImageInfo['h']["GPSDateStamp"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_GPS_GPSDifferential: /* GPS differential correction            GPSDifferential     30     */
                    $this->ImageInfo['h']["GPSDifferential"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;

                case TAG_AUDIO_MU_LAW:
                    $this->ImageInfo['h']["AudioMuLaw"] = $this->ConvertAnyFormat($ValuePtr, $Format);
                    break;
                case TAG_AUDIO_IMA_ADPCM_DESC: //  IMA-ADPCM Audio File Description Example - 40
                    $this->ImageInfo['h']["AudioIMA-ADPCM-DESC"] = $this->ConvertAnyFormat($ValuePtr, $Format);
                    break;
                case TAG_AUDIO_MU_LAW_DESC: //  µ-Law Audio File Description Sample - 50
                    $this->ImageInfo['h']["AudioMuLawDesc"] = $this->ConvertAnyFormat($ValuePtr, $Format);
                    break;

                case TAG_EXPOSURE_INDEX:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["ExposureIndex"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);;
                    break;

                case TAG_SENSING_METHOD:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("1" => "Not Defined", "2" => "One-chip color area sensor", "3" => "Two-chip color area sensor",
                        "4" => "Three -chip color area sensor", "5" => "Color sequential area sensor",
                        "6" => "Trilinear sensor", "7" => "Color sequential linear sensor"
                    );

                    $this->ImageInfo['h']["sensing"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;
                case TAG_SOUCE_TYPE:
                    $this->ImageInfo['h']["sourceType"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_SCENE_TYPE:
                    $this->ImageInfo['h']["sceneType"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_CFA_PATTERN:
                    $this->ImageInfo['h']["CFAPattern"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
                    break;
                case TAG_CUSTOM_RENDERED:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["customRendered"] = ($tmp == 0) ? 'Normal Process' : ($tmp == 1 ? 'Custom Process' : 'Reserved');
                    break;
                case TAG_EXPOSURE_MODE:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array('Auto Exposure', 'Manual Exposure', 'Auto Bracket');
                    $this->ImageInfo['h']["exposureMode"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;
                case TAG_WHITE_BALANCE:
                    $this->ImageInfo['h']["whiteBalance"] = $this->ConvertAnyFormat($ValuePtr, $Format);
                    break;
                case TAG_DIGITAL_ZOOM_RATIO:
                    $tmp = $this->ImageInfo['h']["zoomRatio"] = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["zoomRatio"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
                    break;
                case TAG_FLENGTH_IN35MM:
                    $this->ImageInfo['h']["flength35mm"] = $this->ConvertAnyFormat($ValuePtr, $Format);
                    break;
                case TAG_SCREEN_CAP_TYPE:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("Standard", "Landscape", "Portrait", "Night Scene");
                    $this->ImageInfo['h']["screenCaptureType"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;
                case TAG_GAIN_CONTROL:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("None", "Low Gain Up", "High Gain Up", "Low Gain Down", "High Gain Down");
                    $this->ImageInfo['h']["gainControl"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;
                case TAG_CONTRAST:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("Normal", "Soft", "Hard");
                    $this->ImageInfo['h']["contrast"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;
                case TAG_SATURATION:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("Normal", "Low Saturation", "High Saturation");
                    $this->ImageInfo['h']["saturation"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;
                case TAG_SHARPNESS:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("Normal", "Soft", "Hard");
                    $this->ImageInfo['h']["sharpness"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;
                case TAG_DIST_RANGE:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("Unknown", "Macro", "Close View", "Distant View");
                    $this->ImageInfo['h']["distanceRange"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;
                case TAG_DEVICE_SETTING_DESC:
                    /*
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("Unknown","Macro","Close View","Distant View");
                    $this->ImageInfo['h']["distanceRange"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    */
                    $this->ImageInfo['h']["deviceSettingDesc"] = "NOT IMPLEMENTED";
                    break;
                case TAG_COMPRESS_SCHEME:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("1" => "Uncompressed", "6" => "JPEG compression (thumbnails only)");
                    $this->ImageInfo['h']["compressScheme"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;
                case TAG_IMAGE_WD:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["jpegImageWidth"] = $tmp;
                    break;
                case TAG_IMAGE_HT:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["jpegImageHeight"] = $tmp;
                    break;
                case TAG_IMAGE_BPS:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["jpegBitsPerSample"] = $tmp;
                    break;
                case TAG_IMAGE_PHOTO_INT:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["jpegPhotometricInt"] = $tmp;
                    $tmpArr = array("2" => "RGB", "6" => "YCbCr");
                    $this->ImageInfo['h']["jpegPhotometricInt"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");

                    break;
                case TAG_IMAGE_SOFFSET:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["jpegStripOffsets"] = $tmp;
                    break;
                case TAG_IMAGE_SPP:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["jpegSamplesPerPixel"] = $tmp;
                    break;
                case TAG_IMAGE_RPS:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["jpegRowsPerStrip"] = $tmp;
                    break;
                case TAG_IMAGE_SBC:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["jpegStripByteCounts"] = $tmp;
                    break;
                case TAG_IMAGE_P_CONFIG:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $tmpArr = array("1" => "Chunky Format", "2" => "Planar Format");
                    $this->ImageInfo['h']["jpegPlanarConfig"] =
                        (isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
                    break;
                case TAG_FOCALPLANE_YRESOL:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["focalPlaneYResolution"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
                    break;
                case TAG_BRIGHTNESS:
                    $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
                    $this->ImageInfo['h']["brightness"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
                    break;
                //---------------------------------------------
                case TAG_EXIF_OFFSET:
                case TAG_INTEROP_OFFSET:
                {

                    $SubdirStart = substr($OffsetBase, $this->Get32u($ValuePtr[0], $ValuePtr[1], $ValuePtr[2], $ValuePtr[3]));
                    //if ($SubdirStart < $OffsetBase || $SubdirStart > $OffsetBase+$ExifLength){
                    //    debug("Illegal exif or interop ofset directory link",1);
                    //}else{
                    //echo "<h1>Calling sub-exif dir</h1>";
                    $this->ProcessExifDir($SubdirStart, $OffsetBase, $ExifLength);
                    //}
                    continue;
                }
                default:
                    {
                    $this->debug("UNKNOWN TAG: $Tag");
                    }
            }
        }

        {
            // In addition to linking to subdirectories via exif tags,
            // there's also a potential link to another directory at the end of each
            // directory.  this has got to be the result of a comitee!
            $tmpDirStart = substr($DirStart, 2 + 12 * $NumDirEntries);
            if (strlen($tmpDirStart) + 4 <= strlen($OffsetBase) + $ExifLength)
            {
                $Offset = $this->Get32u($tmpDirStart[0], $tmpDirStart[1], $tmpDirStart[2], $tmpDirStart[3]);
                if ($Offset)
                {
                    $SubdirStart = substr($OffsetBase, $Offset);
                    if (strlen($SubdirStart) > strlen($OffsetBase) + $ExifLength)
                    {
                        if (strlen($SubdirStart) < strlen($OffsetBase) + $ExifLength + 20)
                        {
                            // Jhead 1.3 or earlier would crop the whole directory!
                            // As Jhead produces this form of format incorrectness,
                            // I'll just let it pass silently
                        }
                        else
                        {
                            $this->errno = 51;
                            $this->errstr = "Illegal subdirectory link";
                            $this->debug($this->errstr, 1);
                        }
                    }
                    else
                    {
                        if (strlen($SubdirStart) <= strlen($OffsetBase) + $ExifLength)
                        {
                            $this->ProcessExifDir($SubdirStart, $OffsetBase, $ExifLength);
                        }
                    }
                }
            }
            else
            {
                // The exif header ends before the last next directory pointer.
            }
        }

        /**
         * Check if thumbnail has been cached or not.
         * If yes! then read the file.
         */
        /*
        if(file_exists($this->thumbnail) && $this->caching && (filemtime($this->thumbnail) == filemtime($this->file) )) {
            $this->ImageInfo["h"]["Thumbnail"] = $this->thumbnail;
            $this->ImageInfo["h"]["ThumbnailSize"] =  sprintf("%d bytes",filesize($this->thumbnail));
        } else{
            if ($this->ThumbnailSize && $this->ThumbnailOffset){
                if ($this->ThumbnailSize + $this->ThumbnailOffset <= $ExifLength){
                    // The thumbnail pointer appears to be valid.  Store it.
                    $this->ImageInfo["h"]["Thumbnail"] = substr($OffsetBase,$this->ThumbnailOffset);

                    // Save the thumbnail /
                    if($this->caching && is_dir($this->cacheDir)) {
                        $this->saveThumbnail($this->thumbnail);
                        $this->ImageInfo["h"]["Thumbnail"] = $this->thumbnail;
                    }
                    $this->ImageInfo["h"]["ThumbnailSize"] =  sprintf("%d bytes",strlen($this->ImageInfo["h"]["Thumbnail"]));
                }
            }
        }
        */
    }
1141930
function filesInRepository(dir) {
        var ignoreDirs = cog.getOption('ignore_dirs');
        // TODO: Allow an array and move to config.
        var ignoreFiles = /~$/;
        var files = glob.sync(dir ? dir + '/*' : '*');
        var ret = [];
        for (var i = 0; i < files.length; i++) {
            if (fs.lstatSync(files[i]).isDirectory()) {
                // Ignore standard directories of uninterest.
                if (!dir && ignoreDirs.indexOf(files[i]) >= 0) {
                    continue;
                }
                ret = filesInRepository(files[i]).concat(ret);
            } else {
                if (!ignoreFiles.test(files[i])) {
                    ret.push(files[i]);
                }
            }
        }
        return ret;
    }
667868
def read_rels(archive):
    """"""
    xml_source = archive.read(ARC_WORKBOOK_RELS)
    tree = fromstring(xml_source)
    for element in safe_iterator(tree, '{%s}Relationship' % PKG_REL_NS):
        rId = element.get('Id')
        pth = element.get("Target")
        typ = element.get('Type')
        # normalise path
        if pth.startswith("/xl"):
            pth = pth.replace("/xl", "xl")
        elif not pth.startswith("xl") and not pth.startswith(".."):
            pth = "xl/" + pth
        yield rId, {'path':pth, 'type':typ}
468550
function parseRemoteBranches(str) {
  var res = [],
      regex = /[\w]{40}\s+refs\/heads\/(.+)/g,
      match;

  while ((match = regex.exec(str)) != null) {
    if (match.index === regex.lastIndex) {
      regex.lastIndex++;
    }
    res.push(match[1]);
  }

  if (!res.length) {
    throw new Error('Unable to parse ls-remote response', str);
  }
  return res;
}
1321005
function legacyExtensionLoading (ext, name) {
    if (typeof ext === 'function') {
      ext = ext(new showdown.Converter());
    }
    if (!showdown.helper.isArray(ext)) {
      ext = [ext];
    }
    var valid = validate(ext, name);

    if (!valid.valid) {
      throw Error(valid.error);
    }

    for (var i = 0; i < ext.length; ++i) {
      switch (ext[i].type) {
        case 'lang':
          langExtensions.push(ext[i]);
          break;
        case 'output':
          outputModifiers.push(ext[i]);
          break;
        default:// should never reach here
          throw Error('Extension loader error: Type unrecognized!!!');
      }
    }
  }