You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by da...@apache.org on 2015/11/13 12:50:05 UTC
[01/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Repository: cordova-firefoxos
Updated Branches:
refs/heads/master 3a1effe22 -> 325bb661e
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js b/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
index 6c34fbe..5e5a969 100644
--- a/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
+++ b/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
@@ -1,3854 +1,3854 @@
-/*
- * JSHint, by JSHint Community.
- *
- * Licensed under the same slightly modified MIT license that JSLint is.
- * It stops evil-doers everywhere.
- *
- * JSHint is a derivative work of JSLint:
- *
- * Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * The Software shall be used for Good, not Evil.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * JSHint was forked from 2010-12-16 edition of JSLint.
- *
- */
-
-/*
- JSHINT is a global function. It takes two parameters.
-
- var myResult = JSHINT(source, option);
-
- The first parameter is either a string or an array of strings. If it is a
- string, it will be split on '\n' or '\r'. If it is an array of strings, it
- is assumed that each string represents one line. The source can be a
- JavaScript text or a JSON text.
-
- The second parameter is an optional object of options which control the
- operation of JSHINT. Most of the options are booleans: They are all
- optional and have a default value of false. One of the options, predef,
- can be an array of names, which will be used to declare global variables,
- or an object whose keys are used as global names, with a boolean value
- that determines if they are assignable.
-
- If it checks out, JSHINT returns true. Otherwise, it returns false.
-
- If false, you can inspect JSHINT.errors to find out the problems.
- JSHINT.errors is an array of objects containing these members:
-
- {
- line : The line (relative to 0) at which the lint was found
- character : The character (relative to 0) at which the lint was found
- reason : The problem
- evidence : The text line in which the problem occurred
- raw : The raw message before the details were inserted
- a : The first detail
- b : The second detail
- c : The third detail
- d : The fourth detail
- }
-
- If a fatal error was found, a null will be the last element of the
- JSHINT.errors array.
-
- You can request a Function Report, which shows all of the functions
- and the parameters and vars that they use. This can be used to find
- implied global variables and other problems. The report is in HTML and
- can be inserted in an HTML <body>.
-
- var myReport = JSHINT.report(limited);
-
- If limited is true, then the report will be limited to only errors.
-
- You can request a data structure which contains JSHint's results.
-
- var myData = JSHINT.data();
-
- It returns a structure with this form:
-
- {
- errors: [
- {
- line: NUMBER,
- character: NUMBER,
- reason: STRING,
- evidence: STRING
- }
- ],
- functions: [
- name: STRING,
- line: NUMBER,
- last: NUMBER,
- param: [
- STRING
- ],
- closure: [
- STRING
- ],
- var: [
- STRING
- ],
- exception: [
- STRING
- ],
- outer: [
- STRING
- ],
- unused: [
- STRING
- ],
- global: [
- STRING
- ],
- label: [
- STRING
- ]
- ],
- globals: [
- STRING
- ],
- member: {
- STRING: NUMBER
- },
- unuseds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- implieds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- urls: [
- STRING
- ],
- json: BOOLEAN
- }
-
- Empty arrays will not be included.
-
-*/
-
-/*jshint
- evil: true, nomen: false, onevar: false, regexp: false, strict: true, boss: true
-*/
-
-/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
- "(begin)", "(breakage)", "(context)", "(error)", "(global)",
- "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
- "(params)", "(scope)", "(statement)", "(verb)", "*", "+", "++", "-",
- "--", "\/", "<", "<=", "==", "===", ">", ">=", $, $$, $A, $F, $H, $R, $break,
- $continue, $w, Abstract, Ajax, __filename, __dirname, ActiveXObject, Array,
- ArrayBuffer, ArrayBufferView, Autocompleter, Assets, Boolean, Builder,
- Buffer, Browser, COM, CScript, Canvas, CustomAnimation, Class, Control,
- Chain, Color, Cookie, Core, DataView, Date, Debug, Draggable, Draggables,
- Droppables, Document, DomReady, DOMReady, Drag, E, Enumerator, Enumerable,
- Element, Elements, Error, Effect, EvalError, Event, Events, FadeAnimation,
- Field, Flash, Float32Array, Float64Array, Form, FormField, Frame, Function,
- Fx, Group, Hash, HotKey, HTMLElement, HtmlTable, Iframe, IframeShim, Image,
- Int16Array, Int32Array, Int8Array, Insertion, InputValidator, JSON, Keyboard,
- Locale, LN10, LN2, LOG10E, LOG2E, MAX_VALUE, MIN_VALUE, Mask, Math, MenuItem,
- MoveAnimation, MooTools, Native, NEGATIVE_INFINITY, Number, Object,
- ObjectRange, Option, Options, OverText, PI, POSITIVE_INFINITY,
- PeriodicalExecuter, Point, Position, Prototype, RangeError, Rectangle,
- ReferenceError, RegExp, ResizeAnimation, Request, RotateAnimation, SQRT1_2,
- SQRT2, ScrollBar, Scriptaculous, Scroller, Slick, Slider, Selector, String,
- Style, SyntaxError, Sortable, Sortables, SortableObserver, Sound, Spinner,
- System, Swiff, Text, TextArea, Template, Timer, Tips, Type, TypeError,
- Toggle, Try, URI, URIError, URL, VBArray, WScript, Web, Window, XMLDOM,
- XMLHttpRequest, XPathEvaluator, XPathException, XPathExpression,
- XPathNamespace, XPathNSResolver, XPathResult, "\\", a, addEventListener,
- address, alert, apply, applicationCache, arguments, arity, asi, b, bitwise,
- block, blur, boolOptions, boss, browser, c, call, callee, caller, cases,
- charAt, charCodeAt, character, clearInterval, clearTimeout, close, closed,
- closure, comment, condition, confirm, console, constructor, content, couch,
- create, css, curly, d, data, datalist, dd, debug, decodeURI,
- decodeURIComponent, defaultStatus, defineClass, deserialize, devel,
- document, edition, else, emit, encodeURI, encodeURIComponent, entityify,
- eqeqeq, eqnull, errors, es5, escape, eval, event, evidence, evil, ex,
- exception, exec, exps, expr, exports, FileReader, first, floor, focus,
- forin, fragment, frames, from, fromCharCode, fud, funct, function, functions,
- g, gc, getComputedStyle, getRow, GLOBAL, global, globals, globalstrict,
- hasOwnProperty, help, history, i, id, identifier, immed, implieds,
- include, indent, indexOf, init, ins, instanceOf, isAlpha,
- isApplicationRunning, isArray, isDigit, isFinite, isNaN, join, jshint,
- JSHINT, json, jquery, jQuery, keys, label, labelled, last, laxbreak,
- latedef, lbp, led, left, length, line, load, loadClass, localStorage,
- location, log, loopfunc, m, match, maxerr, maxlen, member,message, meta,
- module, moveBy, moveTo, mootools, name, navigator, new, newcap, noarg,
- node, noempty, nomen, nonew, nud, onbeforeunload, onblur, onerror, onevar,
- onfocus, onload, onresize, onunload, open, openDatabase, openURL, opener,
- opera, outer, param, parent, parseFloat, parseInt, passfail, plusplus,
- predef, print, process, prompt, prototype, prototypejs, push, quit, range,
- raw, reach, reason, regexp, readFile, readUrl, removeEventListener, replace,
- report, require, reserved, resizeBy, resizeTo, resolvePath, resumeUpdates,
- respond, rhino, right, runCommand, scroll, screen, scrollBy, scrollTo,
- scrollbar, search, seal, send, serialize, setInterval, setTimeout, shift,
- slice, sort,spawn, split, stack, status, start, strict, sub, substr, supernew,
- shadow, supplant, sum, sync, test, toLowerCase, toString, toUpperCase, toint32,
- token, top, type, typeOf, Uint16Array, Uint32Array, Uint8Array, undef,
- unused, urls, value, valueOf, var, version, WebSocket, white, window, Worker
-*/
-
-/*global exports: false */
-
-// We build the application inside a function so that we produce only a single
-// global variable. That function will be invoked immediately, and its return
-// value is the JSHINT function itself.
-
-var JSHINT = (function () {
- "use strict";
-
- var anonname, // The guessed name for anonymous functions.
-
-// These are operators that should not be used with the ! operator.
-
- bang = {
- '<' : true,
- '<=' : true,
- '==' : true,
- '===': true,
- '!==': true,
- '!=' : true,
- '>' : true,
- '>=' : true,
- '+' : true,
- '-' : true,
- '*' : true,
- '/' : true,
- '%' : true
- },
-
-// These are the JSHint boolean options.
-
- boolOptions = {
- asi : true, // if automatic semicolon insertion should be tolerated
- bitwise : true, // if bitwise operators should not be allowed
- boss : true, // if advanced usage of assignments should be allowed
- browser : true, // if the standard browser globals should be predefined
- couch : true, // if CouchDB globals should be predefined
- curly : true, // if curly braces around blocks should be required (even in if/for/while)
- debug : true, // if debugger statements should be allowed
- devel : true, // if logging globals should be predefined (console, alert, etc.)
- eqeqeq : true, // if === should be required
- eqnull : true, // if == null comparisons should be tolerated
- es5 : true, // if ES5 syntax should be allowed
- evil : true, // if eval should be allowed
- expr : true, // if ExpressionStatement should be allowed as Programs
- forin : true, // if for in statements must filter
- globalstrict: true, // if global "use strict"; should be allowed (also enables 'strict')
- immed : true, // if immediate invocations must be wrapped in parens
- jquery : true, // if jQuery globals should be predefined
- latedef : true, // if the use before definition should not be tolerated
- laxbreak : true, // if line breaks should not be checked
- loopfunc : true, // if functions should be allowed to be defined within loops
- mootools : true, // if MooTools globals should be predefined
- newcap : true, // if constructor names must be capitalized
- noarg : true, // if arguments.caller and arguments.callee should be disallowed
- node : true, // if the Node.js environment globals should be predefined
- noempty : true, // if empty blocks should be disallowed
- nonew : true, // if using `new` for side-effects should be disallowed
- nomen : true, // if names should be checked
- onevar : true, // if only one var statement per function should be allowed
- passfail : true, // if the scan should stop on first error
- plusplus : true, // if increment/decrement should not be allowed
- prototypejs : true, // if Prototype and Scriptaculous globals shoudl be predefined
- regexp : true, // if the . should not be allowed in regexp literals
- rhino : true, // if the Rhino environment globals should be predefined
- undef : true, // if variables should be declared before used
- shadow : true, // if variable shadowing should be tolerated
- strict : true, // require the "use strict"; pragma
- sub : true, // if all forms of subscript notation are tolerated
- supernew : true, // if `new function () { ... };` and `new Object;` should be tolerated
- white : true // if strict whitespace rules apply
- },
-
-// browser contains a set of global names which are commonly provided by a
-// web browser environment.
-
- browser = {
- ArrayBuffer : false,
- ArrayBufferView : false,
- addEventListener: false,
- applicationCache: false,
- blur : false,
- clearInterval : false,
- clearTimeout : false,
- close : false,
- closed : false,
- DataView : false,
- defaultStatus : false,
- document : false,
- event : false,
- FileReader : false,
- Float32Array : false,
- Float64Array : false,
- focus : false,
- frames : false,
- getComputedStyle: false,
- HTMLElement : false,
- history : false,
- Int16Array : false,
- Int32Array : false,
- Int8Array : false,
- Image : false,
- length : false,
- localStorage : false,
- location : false,
- moveBy : false,
- moveTo : false,
- name : false,
- navigator : false,
- onbeforeunload : true,
- onblur : true,
- onerror : true,
- onfocus : true,
- onload : true,
- onresize : true,
- onunload : true,
- open : false,
- openDatabase : false,
- opener : false,
- Option : false,
- parent : false,
- print : false,
- removeEventListener: false,
- resizeBy : false,
- resizeTo : false,
- screen : false,
- scroll : false,
- scrollBy : false,
- scrollTo : false,
- setInterval : false,
- setTimeout : false,
- status : false,
- top : false,
- Uint16Array : false,
- Uint32Array : false,
- Uint8Array : false,
- WebSocket : false,
- window : false,
- Worker : false,
- XMLHttpRequest : false,
- XPathEvaluator : false,
- XPathException : false,
- XPathExpression : false,
- XPathNamespace : false,
- XPathNSResolver : false,
- XPathResult : false
- },
-
- couch = {
- "require" : false,
- respond : false,
- getRow : false,
- emit : false,
- send : false,
- start : false,
- sum : false,
- log : false,
- exports : false,
- module : false
- },
-
- devel = {
- alert : false,
- confirm : false,
- console : false,
- Debug : false,
- opera : false,
- prompt : false
- },
-
- escapes = {
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '/' : '\\/',
- '\\': '\\\\'
- },
-
- funct, // The current function
-
- functionicity = [
- 'closure', 'exception', 'global', 'label',
- 'outer', 'unused', 'var'
- ],
-
- functions, // All of the functions
-
- global, // The global scope
- implied, // Implied globals
- inblock,
- indent,
- jsonmode,
-
- jquery = {
- '$' : false,
- jQuery : false
- },
-
- lines,
- lookahead,
- member,
- membersOnly,
-
- mootools = {
- '$' : false,
- '$$' : false,
- Assets : false,
- Browser : false,
- Chain : false,
- Class : false,
- Color : false,
- Cookie : false,
- Core : false,
- Document : false,
- DomReady : false,
- DOMReady : false,
- Drag : false,
- Element : false,
- Elements : false,
- Event : false,
- Events : false,
- Fx : false,
- Group : false,
- Hash : false,
- HtmlTable : false,
- Iframe : false,
- IframeShim : false,
- InputValidator : false,
- instanceOf : false,
- Keyboard : false,
- Locale : false,
- Mask : false,
- MooTools : false,
- Native : false,
- Options : false,
- OverText : false,
- Request : false,
- Scroller : false,
- Slick : false,
- Slider : false,
- Sortables : false,
- Spinner : false,
- Swiff : false,
- Tips : false,
- Type : false,
- typeOf : false,
- URI : false,
- Window : false
- },
-
- nexttoken,
-
- node = {
- __filename : false,
- __dirname : false,
- exports : false,
- Buffer : false,
- GLOBAL : false,
- global : false,
- module : false,
- process : false,
- require : false
- },
-
- noreach,
- option,
- predefined, // Global variables defined by option
- prereg,
- prevtoken,
-
- prototypejs = {
- '$' : false,
- '$$' : false,
- '$A' : false,
- '$F' : false,
- '$H' : false,
- '$R' : false,
- '$break' : false,
- '$continue' : false,
- '$w' : false,
- Abstract : false,
- Ajax : false,
- Class : false,
- Enumerable : false,
- Element : false,
- Event : false,
- Field : false,
- Form : false,
- Hash : false,
- Insertion : false,
- ObjectRange : false,
- PeriodicalExecuter: false,
- Position : false,
- Prototype : false,
- Selector : false,
- Template : false,
- Toggle : false,
- Try : false,
- Autocompleter : false,
- Builder : false,
- Control : false,
- Draggable : false,
- Draggables : false,
- Droppables : false,
- Effect : false,
- Sortable : false,
- SortableObserver : false,
- Sound : false,
- Scriptaculous : false
- },
-
- rhino = {
- defineClass : false,
- deserialize : false,
- gc : false,
- help : false,
- load : false,
- loadClass : false,
- print : false,
- quit : false,
- readFile : false,
- readUrl : false,
- runCommand : false,
- seal : false,
- serialize : false,
- spawn : false,
- sync : false,
- toint32 : false,
- version : false
- },
-
- scope, // The current scope
- src,
- stack,
-
-// standard contains the global names that are provided by the
-// ECMAScript standard.
-
- standard = {
- Array : false,
- Boolean : false,
- Date : false,
- decodeURI : false,
- decodeURIComponent : false,
- encodeURI : false,
- encodeURIComponent : false,
- Error : false,
- 'eval' : false,
- EvalError : false,
- Function : false,
- hasOwnProperty : false,
- isFinite : false,
- isNaN : false,
- JSON : false,
- Math : false,
- Number : false,
- Object : false,
- parseInt : false,
- parseFloat : false,
- RangeError : false,
- ReferenceError : false,
- RegExp : false,
- String : false,
- SyntaxError : false,
- TypeError : false,
- URIError : false
- },
-
- standard_member = {
- E : true,
- LN2 : true,
- LN10 : true,
- LOG2E : true,
- LOG10E : true,
- MAX_VALUE : true,
- MIN_VALUE : true,
- NEGATIVE_INFINITY : true,
- PI : true,
- POSITIVE_INFINITY : true,
- SQRT1_2 : true,
- SQRT2 : true
- },
-
- strict_mode,
- syntax = {},
- tab,
- token,
- urls,
- warnings,
-
-// Regular expressions. Some of these are stupidly long.
-
-// unsafe comment or string
- ax = /@cc|<\/?|script|\]\s*\]|<\s*!|</i,
-// unsafe characters that are silently deleted by one or more browsers
- cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
-// token
- tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jshint|jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
-// characters in strings that need escapement
- nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
- nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
-// star slash
- lx = /\*\/|\/\*/,
-// identifier
- ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
-// javascript url
- jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
-// catches /* falls through */ comments
- ft = /^\s*\/\*\s*falls\sthrough\s*\*\/\s*$/;
-
- function F() {} // Used by Object.create
-
- function is_own(object, name) {
-
-// The object.hasOwnProperty method fails when the property under consideration
-// is named 'hasOwnProperty'. So we have to use this more convoluted form.
-
- return Object.prototype.hasOwnProperty.call(object, name);
- }
-
-// Provide critical ES5 functions to ES3.
-
- if (typeof Array.isArray !== 'function') {
- Array.isArray = function (o) {
- return Object.prototype.toString.apply(o) === '[object Array]';
- };
- }
-
- if (typeof Object.create !== 'function') {
- Object.create = function (o) {
- F.prototype = o;
- return new F();
- };
- }
-
- if (typeof Object.keys !== 'function') {
- Object.keys = function (o) {
- var a = [], k;
- for (k in o) {
- if (is_own(o, k)) {
- a.push(k);
- }
- }
- return a;
- };
- }
-
-// Non standard methods
-
- if (typeof String.prototype.entityify !== 'function') {
- String.prototype.entityify = function () {
- return this
- .replace(/&/g, '&')
- .replace(/</g, '<')
- .replace(/>/g, '>');
- };
- }
-
- if (typeof String.prototype.isAlpha !== 'function') {
- String.prototype.isAlpha = function () {
- return (this >= 'a' && this <= 'z\uffff') ||
- (this >= 'A' && this <= 'Z\uffff');
- };
- }
-
- if (typeof String.prototype.isDigit !== 'function') {
- String.prototype.isDigit = function () {
- return (this >= '0' && this <= '9');
- };
- }
-
- if (typeof String.prototype.supplant !== 'function') {
- String.prototype.supplant = function (o) {
- return this.replace(/\{([^{}]*)\}/g, function (a, b) {
- var r = o[b];
- return typeof r === 'string' || typeof r === 'number' ? r : a;
- });
- };
- }
-
- if (typeof String.prototype.name !== 'function') {
- String.prototype.name = function () {
-
-// If the string looks like an identifier, then we can return it as is.
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can simply slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe
-// sequences.
-
- if (ix.test(this)) {
- return this;
- }
- if (nx.test(this)) {
- return '"' + this.replace(nxg, function (a) {
- var c = escapes[a];
- if (c) {
- return c;
- }
- return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
- }) + '"';
- }
- return '"' + this + '"';
- };
- }
-
-
- function combine(t, o) {
- var n;
- for (n in o) {
- if (is_own(o, n)) {
- t[n] = o[n];
- }
- }
- }
-
- function assume() {
- if (option.couch)
- combine(predefined, couch);
-
- if (option.rhino)
- combine(predefined, rhino);
-
- if (option.prototypejs)
- combine(predefined, prototypejs);
-
- if (option.node)
- combine(predefined, node);
-
- if (option.devel)
- combine(predefined, devel);
-
- if (option.browser)
- combine(predefined, browser);
-
- if (option.jquery)
- combine(predefined, jquery);
-
- if (option.mootools)
- combine(predefined, mootools);
-
- if (option.globalstrict)
- option.strict = true;
- }
-
-
-// Produce an error warning.
-
- function quit(m, l, ch) {
- throw {
- name: 'JSHintError',
- line: l,
- character: ch,
- message: m + " (" + Math.floor((l / lines.length) * 100) +
- "% scanned)."
- };
- }
-
- function warning(m, t, a, b, c, d) {
- var ch, l, w;
- t = t || nexttoken;
- if (t.id === '(end)') { // `~
- t = token;
- }
- l = t.line || 0;
- ch = t.from || 0;
- w = {
- id: '(error)',
- raw: m,
- evidence: lines[l - 1] || '',
- line: l,
- character: ch,
- a: a,
- b: b,
- c: c,
- d: d
- };
- w.reason = m.supplant(w);
- JSHINT.errors.push(w);
- if (option.passfail) {
- quit('Stopping. ', l, ch);
- }
- warnings += 1;
- if (warnings >= option.maxerr) {
- quit("Too many errors.", l, ch);
- }
- return w;
- }
-
- function warningAt(m, l, ch, a, b, c, d) {
- return warning(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
- function error(m, t, a, b, c, d) {
- var w = warning(m, t, a, b, c, d);
- quit("Stopping, unable to continue.", w.line, w.character);
- }
-
- function errorAt(m, l, ch, a, b, c, d) {
- return error(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
-
-
-// lexical analysis and token construction
-
- var lex = (function lex() {
- var character, from, line, s;
-
-// Private lex methods
-
- function nextLine() {
- var at,
- tw; // trailing whitespace check
-
- if (line >= lines.length)
- return false;
-
- character = 1;
- s = lines[line];
- line += 1;
- at = s.search(/ \t/);
-
- if (at >= 0)
- warningAt("Mixed spaces and tabs.", line, at + 1);
-
- s = s.replace(/\t/g, tab);
- at = s.search(cx);
-
- if (at >= 0)
- warningAt("Unsafe character.", line, at);
-
- if (option.maxlen && option.maxlen < s.length)
- warningAt("Line too long.", line, s.length);
-
- // Check for trailing whitespaces
- tw = s.search(/\s+$/);
- if (option.white && ~tw)
- warningAt("Trailing whitespace.", line, tw);
-
- return true;
- }
-
-// Produce a token object. The token inherits from a syntax symbol.
-
- function it(type, value) {
- var i, t;
- if (type === '(color)' || type === '(range)') {
- t = {type: type};
- } else if (type === '(punctuator)' ||
- (type === '(identifier)' && is_own(syntax, value))) {
- t = syntax[value] || syntax['(error)'];
- } else {
- t = syntax[type];
- }
- t = Object.create(t);
- if (type === '(string)' || type === '(range)') {
- if (jx.test(value)) {
- warningAt("Script URL.", line, from);
- }
- }
- if (type === '(identifier)') {
- t.identifier = true;
- if (value === '__iterator__' || value === '__proto__') {
- errorAt("Reserved name '{a}'.",
- line, from, value);
- } else if (option.nomen &&
- (value.charAt(0) === '_' ||
- value.charAt(value.length - 1) === '_')) {
- warningAt("Unexpected {a} in '{b}'.", line, from,
- "dangling '_'", value);
- }
- }
- t.value = value;
- t.line = line;
- t.character = character;
- t.from = from;
- i = t.id;
- if (i !== '(endline)') {
- prereg = i &&
- (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
- i === 'return');
- }
- return t;
- }
-
-// Public lex methods
-
- return {
- init: function (source) {
- if (typeof source === 'string') {
- lines = source
- .replace(/\r\n/g, '\n')
- .replace(/\r/g, '\n')
- .split('\n');
- } else {
- lines = source;
- }
-
- // If the first line is a shebang (#!), make it a blank and move on.
- // Shebangs are used by Node scripts.
- if (lines[0] && lines[0].substr(0, 2) == '#!')
- lines[0] = '';
-
- line = 0;
- nextLine();
- from = 1;
- },
-
- range: function (begin, end) {
- var c, value = '';
- from = character;
- if (s.charAt(0) !== begin) {
- errorAt("Expected '{a}' and instead saw '{b}'.",
- line, character, begin, s.charAt(0));
- }
- for (;;) {
- s = s.slice(1);
- character += 1;
- c = s.charAt(0);
- switch (c) {
- case '':
- errorAt("Missing '{a}'.", line, character, c);
- break;
- case end:
- s = s.slice(1);
- character += 1;
- return it('(range)', value);
- case '\\':
- warningAt("Unexpected '{a}'.", line, character, c);
- }
- value += c;
- }
-
- },
-
-// token -- this is called by advance to get the next token.
-
- token: function () {
- var b, c, captures, d, depth, high, i, l, low, q, t;
-
- function match(x) {
- var r = x.exec(s), r1;
- if (r) {
- l = r[0].length;
- r1 = r[1];
- c = r1.charAt(0);
- s = s.substr(l);
- from = character + l - r1.length;
- character += l;
- return r1;
- }
- }
-
- function string(x) {
- var c, j, r = '';
-
- if (jsonmode && x !== '"') {
- warningAt("Strings must use doublequote.",
- line, character);
- }
-
- function esc(n) {
- var i = parseInt(s.substr(j + 1, n), 16);
- j += n;
- if (i >= 32 && i <= 126 &&
- i !== 34 && i !== 92 && i !== 39) {
- warningAt("Unnecessary escapement.", line, character);
- }
- character += n;
- c = String.fromCharCode(i);
- }
- j = 0;
- for (;;) {
- while (j >= s.length) {
- j = 0;
- if (!nextLine()) {
- errorAt("Unclosed string.", line, from);
- }
- }
- c = s.charAt(j);
- if (c === x) {
- character += 1;
- s = s.substr(j + 1);
- return it('(string)', r, x);
- }
- if (c < ' ') {
- if (c === '\n' || c === '\r') {
- break;
- }
- warningAt("Control character in string: {a}.",
- line, character + j, s.slice(0, j));
- } else if (c === '\\') {
- j += 1;
- character += 1;
- c = s.charAt(j);
- switch (c) {
- case '\\':
- case '"':
- case '/':
- break;
- case '\'':
- if (jsonmode) {
- warningAt("Avoid \\'.", line, character);
- }
- break;
- case 'b':
- c = '\b';
- break;
- case 'f':
- c = '\f';
- break;
- case 'n':
- c = '\n';
- break;
- case 'r':
- c = '\r';
- break;
- case 't':
- c = '\t';
- break;
- case 'u':
- esc(4);
- break;
- case 'v':
- if (jsonmode) {
- warningAt("Avoid \\v.", line, character);
- }
- c = '\v';
- break;
- case 'x':
- if (jsonmode) {
- warningAt("Avoid \\x-.", line, character);
- }
- esc(2);
- break;
- default:
- warningAt("Bad escapement.", line, character);
- }
- }
- r += c;
- character += 1;
- j += 1;
- }
- }
-
- for (;;) {
- if (!s) {
- return it(nextLine() ? '(endline)' : '(end)', '');
- }
- t = match(tx);
- if (!t) {
- t = '';
- c = '';
- while (s && s < '!') {
- s = s.substr(1);
- }
- if (s) {
- errorAt("Unexpected '{a}'.", line, character, s.substr(0, 1));
- }
- } else {
-
- // identifier
-
- if (c.isAlpha() || c === '_' || c === '$') {
- return it('(identifier)', t);
- }
-
- // number
-
- if (c.isDigit()) {
- if (!isFinite(Number(t))) {
- warningAt("Bad number '{a}'.",
- line, character, t);
- }
- if (s.substr(0, 1).isAlpha()) {
- warningAt("Missing space after '{a}'.",
- line, character, t);
- }
- if (c === '0') {
- d = t.substr(1, 1);
- if (d.isDigit()) {
- if (token.id !== '.') {
- warningAt("Don't use extra leading zeros '{a}'.",
- line, character, t);
- }
- } else if (jsonmode && (d === 'x' || d === 'X')) {
- warningAt("Avoid 0x-. '{a}'.",
- line, character, t);
- }
- }
- if (t.substr(t.length - 1) === '.') {
- warningAt(
-"A trailing decimal point can be confused with a dot '{a}'.", line, character, t);
- }
- return it('(number)', t);
- }
- switch (t) {
-
- // string
-
- case '"':
- case "'":
- return string(t);
-
- // // comment
-
- case '//':
- if (src) {
- warningAt("Unexpected comment.", line, character);
- }
- s = '';
- token.comment = true;
- break;
-
- // /* comment
-
- case '/*':
- if (src) {
- warningAt("Unexpected comment.", line, character);
- }
- for (;;) {
- i = s.search(lx);
- if (i >= 0) {
- break;
- }
- if (!nextLine()) {
- errorAt("Unclosed comment.", line, character);
- }
- }
- character += i + 2;
- if (s.substr(i, 1) === '/') {
- errorAt("Nested comment.", line, character);
- }
- s = s.substr(i + 2);
- token.comment = true;
- break;
-
- // /*members /*jshint /*global
-
- case '/*members':
- case '/*member':
- case '/*jshint':
- case '/*jslint':
- case '/*global':
- case '*/':
- return {
- value: t,
- type: 'special',
- line: line,
- character: character,
- from: from
- };
-
- case '':
- break;
- // /
- case '/':
- if (token.id === '/=') {
- errorAt(
-"A regular expression literal can be confused with '/='.", line, from);
- }
- if (prereg) {
- depth = 0;
- captures = 0;
- l = 0;
- for (;;) {
- b = true;
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '':
- errorAt("Unclosed regular expression.",
- line, from);
- return;
- case '/':
- if (depth > 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, '/');
- }
- c = s.substr(0, l - 1);
- q = {
- g: true,
- i: true,
- m: true
- };
- while (q[s.charAt(l)] === true) {
- q[s.charAt(l)] = false;
- l += 1;
- }
- character += l;
- s = s.substr(l);
- q = s.charAt(0);
- if (q === '/' || q === '*') {
- errorAt("Confusing regular expression.",
- line, from);
- }
- return it('(regexp)', c);
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- break;
- case '(':
- depth += 1;
- b = false;
- if (s.charAt(l) === '?') {
- l += 1;
- switch (s.charAt(l)) {
- case ':':
- case '=':
- case '!':
- l += 1;
- break;
- default:
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
- }
- } else {
- captures += 1;
- }
- break;
- case '|':
- b = false;
- break;
- case ')':
- if (depth === 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, ')');
- } else {
- depth -= 1;
- }
- break;
- case ' ':
- q = 1;
- while (s.charAt(l) === ' ') {
- l += 1;
- q += 1;
- }
- if (q > 1) {
- warningAt(
-"Spaces are hard to count. Use {{a}}.", line, from + l, q);
- }
- break;
- case '[':
- c = s.charAt(l);
- if (c === '^') {
- l += 1;
- if (option.regexp) {
- warningAt("Insecure '{a}'.",
- line, from + l, c);
- } else if (s.charAt(l) === ']') {
- errorAt("Unescaped '{a}'.",
- line, from + l, '^');
- }
- }
- q = false;
- if (c === ']') {
- warningAt("Empty class.", line,
- from + l - 1);
- q = true;
- }
-klass: do {
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '[':
- case '^':
- warningAt("Unescaped '{a}'.",
- line, from + l, c);
- q = true;
- break;
- case '-':
- if (q) {
- q = false;
- } else {
- warningAt("Unescaped '{a}'.",
- line, from + l, '-');
- q = true;
- }
- break;
- case ']':
- if (!q) {
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, '-');
- }
- break klass;
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- q = true;
- break;
- case '/':
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, '/');
- q = true;
- break;
- case '<':
- q = true;
- break;
- default:
- q = true;
- }
- } while (c);
- break;
- case '.':
- if (option.regexp) {
- warningAt("Insecure '{a}'.", line,
- from + l, c);
- }
- break;
- case ']':
- case '?':
- case '{':
- case '}':
- case '+':
- case '*':
- warningAt("Unescaped '{a}'.", line,
- from + l, c);
- }
- if (b) {
- switch (s.charAt(l)) {
- case '?':
- case '+':
- case '*':
- l += 1;
- if (s.charAt(l) === '?') {
- l += 1;
- }
- break;
- case '{':
- l += 1;
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- warningAt(
-"Expected a number and instead saw '{a}'.", line, from + l, c);
- }
- l += 1;
- low = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- low = +c + (low * 10);
- }
- high = low;
- if (c === ',') {
- l += 1;
- high = Infinity;
- c = s.charAt(l);
- if (c >= '0' && c <= '9') {
- l += 1;
- high = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- high = +c + (high * 10);
- }
- }
- }
- if (s.charAt(l) !== '}') {
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
- } else {
- l += 1;
- }
- if (s.charAt(l) === '?') {
- l += 1;
- }
- if (low > high) {
- warningAt(
-"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
- }
- }
- }
- }
- c = s.substr(0, l - 1);
- character += l;
- s = s.substr(l);
- return it('(regexp)', c);
- }
- return it('(punctuator)', t);
-
- // punctuator
-
- case '#':
- return it('(punctuator)', t);
- default:
- return it('(punctuator)', t);
- }
- }
- }
- }
- };
- }());
-
-
- function addlabel(t, type) {
-
- if (t === 'hasOwnProperty') {
- warning("'hasOwnProperty' is a really bad name.");
- }
-
-// Define t in the current function in the current scope.
-
- if (is_own(funct, t) && !funct['(global)']) {
- if (funct[t] === true) {
- if (option.latedef)
- warning("'{a}' was used before it was defined.", nexttoken, t);
- } else {
- if (!option.shadow)
- warning("'{a}' is already defined.", nexttoken, t);
- }
- }
-
- funct[t] = type;
- if (funct['(global)']) {
- global[t] = funct;
- if (is_own(implied, t)) {
- if (option.latedef)
- warning("'{a}' was used before it was defined.", nexttoken, t);
- delete implied[t];
- }
- } else {
- scope[t] = funct;
- }
- }
-
-
- function doOption() {
- var b, obj, filter, o = nexttoken.value, t, v;
- switch (o) {
- case '*/':
- error("Unbegun comment.");
- break;
- case '/*members':
- case '/*member':
- o = '/*members';
- if (!membersOnly) {
- membersOnly = {};
- }
- obj = membersOnly;
- break;
- case '/*jshint':
- case '/*jslint':
- obj = option;
- filter = boolOptions;
- break;
- case '/*global':
- obj = predefined;
- break;
- default:
- error("What?");
- }
- t = lex.token();
-loop: for (;;) {
- for (;;) {
- if (t.type === 'special' && t.value === '*/') {
- break loop;
- }
- if (t.id !== '(endline)' && t.id !== ',') {
- break;
- }
- t = lex.token();
- }
- if (t.type !== '(string)' && t.type !== '(identifier)' &&
- o !== '/*members') {
- error("Bad option.", t);
- }
- v = lex.token();
- if (v.id === ':') {
- v = lex.token();
- if (obj === membersOnly) {
- error("Expected '{a}' and instead saw '{b}'.",
- t, '*/', ':');
- }
- if (t.value === 'indent' && (o === '/*jshint' || o === '/*jslint')) {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.white = true;
- obj.indent = b;
- } else if (t.value === 'maxerr' && (o === '/*jshint' || o === '/*jslint')) {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxerr = b;
- } else if (t.value === 'maxlen' && (o === '/*jshint' || o === '/*jslint')) {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxlen = b;
- } else if (v.value === 'true') {
- obj[t.value] = true;
- } else if (v.value === 'false') {
- obj[t.value] = false;
- } else {
- error("Bad option value.", v);
- }
- t = lex.token();
- } else {
- if (o === '/*jshint' || o === '/*jslint') {
- error("Missing option value.", t);
- }
- obj[t.value] = false;
- t = v;
- }
- }
- if (filter) {
- assume();
- }
- }
-
-
-// We need a peek function. If it has an argument, it peeks that much farther
-// ahead. It is used to distinguish
-// for ( var i in ...
-// from
-// for ( var i = ...
-
- function peek(p) {
- var i = p || 0, j = 0, t;
-
- while (j <= i) {
- t = lookahead[j];
- if (!t) {
- t = lookahead[j] = lex.token();
- }
- j += 1;
- }
- return t;
- }
-
-
-
-// Produce the next token. It looks for programming errors.
-
- function advance(id, t) {
- switch (token.id) {
- case '(number)':
- if (nexttoken.id === '.') {
- warning("A dot following a number can be confused with a decimal point.", token);
- }
- break;
- case '-':
- if (nexttoken.id === '-' || nexttoken.id === '--') {
- warning("Confusing minusses.");
- }
- break;
- case '+':
- if (nexttoken.id === '+' || nexttoken.id === '++') {
- warning("Confusing plusses.");
- }
- break;
- }
- if (token.type === '(string)' || token.identifier) {
- anonname = token.value;
- }
-
- if (id && nexttoken.id !== id) {
- if (t) {
- if (nexttoken.id === '(end)') {
- warning("Unmatched '{a}'.", t, t.id);
- } else {
- warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
- nexttoken, id, t.id, t.line, nexttoken.value);
- }
- } else if (nexttoken.type !== '(identifier)' ||
- nexttoken.value !== id) {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, id, nexttoken.value);
- }
- }
- prevtoken = token;
- token = nexttoken;
- for (;;) {
- nexttoken = lookahead.shift() || lex.token();
- if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
- return;
- }
- if (nexttoken.type === 'special') {
- doOption();
- } else {
- if (nexttoken.id !== '(endline)') {
- break;
- }
- }
- }
- }
-
-
-// This is the heart of JSHINT, the Pratt parser. In addition to parsing, it
-// is looking for ad hoc lint patterns. We add .fud to Pratt's model, which is
-// like .nud except that it is only used on the first token of a statement.
-// Having .fud makes it much easier to define statement-oriented languages like
-// JavaScript. I retained Pratt's nomenclature.
-
-// .nud Null denotation
-// .fud First null denotation
-// .led Left denotation
-// lbp Left binding power
-// rbp Right binding power
-
-// They are elements of the parsing method called Top Down Operator Precedence.
-
- function expression(rbp, initial) {
- var left, isArray = false;
-
- if (nexttoken.id === '(end)')
- error("Unexpected early end of program.", token);
-
- advance();
- if (initial) {
- anonname = 'anonymous';
- funct['(verb)'] = token.value;
- }
- if (initial === true && token.fud) {
- left = token.fud();
- } else {
- if (token.nud) {
- left = token.nud();
- } else {
- if (nexttoken.type === '(number)' && token.id === '.') {
- warning("A leading decimal point can be confused with a dot: '.{a}'.",
- token, nexttoken.value);
- advance();
- return token;
- } else {
- error("Expected an identifier and instead saw '{a}'.",
- token, token.id);
- }
- }
- while (rbp < nexttoken.lbp) {
- isArray = token.value == 'Array';
- advance();
- if (isArray && token.id == '(' && nexttoken.id == ')')
- warning("Use the array literal notation [].", token);
- if (token.led) {
- left = token.led(left);
- } else {
- error("Expected an operator and instead saw '{a}'.",
- token, token.id);
- }
- }
- }
- return left;
- }
-
-
-// Functions for conformance of style.
-
- function adjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white) {
- if (left.character !== right.from && left.line === right.line) {
- warning("Unexpected space after '{a}'.", right, left.value);
- }
- }
- }
-
- function nobreak(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white && (left.character !== right.from || left.line !== right.line)) {
- warning("Unexpected space before '{a}'.", right, right.value);
- }
- }
-
- function nospace(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white && !left.comment) {
- if (left.line === right.line) {
- adjacent(left, right);
- }
- }
- }
-
- function nonadjacent(left, right) {
- if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.line === right.line && left.character === right.from) {
- warning("Missing space after '{a}'.",
- nexttoken, left.value);
- }
- }
- }
-
- function nobreaknonadjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (!option.laxbreak && left.line !== right.line) {
- warning("Bad line breaking before '{a}'.", right, right.id);
- } else if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.character === right.from) {
- warning("Missing space after '{a}'.",
- nexttoken, left.value);
- }
- }
- }
-
- function indentation(bias) {
- var i;
- if (option.white && nexttoken.id !== '(end)') {
- i = indent + (bias || 0);
- if (nexttoken.from !== i) {
- warning(
-"Expected '{a}' to have an indentation at {b} instead at {c}.",
- nexttoken, nexttoken.value, i, nexttoken.from);
- }
- }
- }
-
- function nolinebreak(t) {
- t = t || token;
- if (t.line !== nexttoken.line) {
- warning("Line breaking error '{a}'.", t, t.value);
- }
- }
-
-
- function comma() {
- if (token.line !== nexttoken.line) {
- if (!option.laxbreak) {
- warning("Bad line breaking before '{a}'.", token, nexttoken.id);
- }
- } else if (token.character !== nexttoken.from && option.white) {
- warning("Unexpected space after '{a}'.", nexttoken, token.value);
- }
- advance(',');
- nonadjacent(token, nexttoken);
- }
-
-
-// Functional constructors for making the symbols that will be inherited by
-// tokens.
-
- function symbol(s, p) {
- var x = syntax[s];
- if (!x || typeof x !== 'object') {
- syntax[s] = x = {
- id: s,
- lbp: p,
- value: s
- };
- }
- return x;
- }
-
-
- function delim(s) {
- return symbol(s, 0);
- }
-
-
- function stmt(s, f) {
- var x = delim(s);
- x.identifier = x.reserved = true;
- x.fud = f;
- return x;
- }
-
-
- function blockstmt(s, f) {
- var x = stmt(s, f);
- x.block = true;
- return x;
- }
-
-
- function reserveName(x) {
- var c = x.id.charAt(0);
- if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
- x.identifier = x.reserved = true;
- }
- return x;
- }
-
-
- function prefix(s, f) {
- var x = symbol(s, 150);
- reserveName(x);
- x.nud = (typeof f === 'function') ? f : function () {
- this.right = expression(150);
- this.arity = 'unary';
- if (this.id === '++' || this.id === '--') {
- if (option.plusplus) {
- warning("Unexpected use of '{a}'.", this, this.id);
- } else if ((!this.right.identifier || this.right.reserved) &&
- this.right.id !== '.' && this.right.id !== '[') {
- warning("Bad operand.", this);
- }
- }
- return this;
- };
- return x;
- }
-
-
- function type(s, f) {
- var x = delim(s);
- x.type = s;
- x.nud = f;
- return x;
- }
-
-
- function reserve(s, f) {
- var x = type(s, f);
- x.identifier = x.reserved = true;
- return x;
- }
-
-
- function reservevar(s, v) {
- return reserve(s, function () {
- if (typeof v === 'function') {
- v(this);
- }
- return this;
- });
- }
-
-
- function infix(s, f, p, w) {
- var x = symbol(s, p);
- reserveName(x);
- x.led = function (left) {
- if (!w) {
- nobreaknonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- }
- if (typeof f === 'function') {
- return f(left, this);
- } else {
- this.left = left;
- this.right = expression(p);
- return this;
- }
- };
- return x;
- }
-
-
- function relation(s, f) {
- var x = symbol(s, 100);
- x.led = function (left) {
- nobreaknonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- var right = expression(100);
- if ((left && left.id === 'NaN') || (right && right.id === 'NaN')) {
- warning("Use the isNaN function to compare with NaN.", this);
- } else if (f) {
- f.apply(this, [left, right]);
- }
- if (left.id === '!') {
- warning("Confusing use of '{a}'.", left, '!');
- }
- if (right.id === '!') {
- warning("Confusing use of '{a}'.", left, '!');
- }
- this.left = left;
- this.right = right;
- return this;
- };
- return x;
- }
-
-
- function isPoorRelation(node) {
- return node &&
- ((node.type === '(number)' && +node.value === 0) ||
- (node.type === '(string)' && node.value === '') ||
- (node.type === 'null' && !option.eqnull) ||
- node.type === 'true' ||
- node.type === 'false' ||
- node.type === 'undefined');
- }
-
-
- function assignop(s, f) {
- symbol(s, 20).exps = true;
- return infix(s, function (left, that) {
- var l;
- that.left = left;
- if (predefined[left.value] === false &&
- scope[left.value]['(global)'] === true) {
- warning("Read only.", left);
- } else if (left['function']) {
- warning("'{a}' is a function.", left, left.value);
- }
- if (left) {
- if (left.id === '.' || left.id === '[') {
- if (!left.left || left.left.value === 'arguments') {
- warning('Bad assignment.', that);
- }
- that.right = expression(19);
- return that;
- } else if (left.identifier && !left.reserved) {
- if (funct[left.value] === 'exception') {
- warning("Do not assign to the exception parameter.", left);
- }
- that.right = expression(19);
- return that;
- }
- if (left === syntax['function']) {
- warning(
-"Expected an identifier in an assignment and instead saw a function invocation.",
- token);
- }
- }
- error("Bad assignment.", that);
- }, 20);
- }
-
-
- function bitwise(s, f, p) {
- var x = symbol(s, p);
- reserveName(x);
- x.led = (typeof f === 'function') ? f : function (left) {
- if (option.bitwise) {
- warning("Unexpected use of '{a}'.", this, this.id);
- }
- this.left = left;
- this.right = expression(p);
- return this;
- };
- return x;
- }
-
-
- function bitwiseassignop(s) {
- symbol(s, 20).exps = true;
- return infix(s, function (left, that) {
- if (option.bitwise) {
- warning("Unexpected use of '{a}'.", that, that.id);
- }
- nonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- if (left) {
- if (left.id === '.' || left.id === '[' ||
- (left.identifier && !left.reserved)) {
- expression(19);
- return that;
- }
- if (left === syntax['function']) {
- warning(
-"Expected an identifier in an assignment, and instead saw a function invocation.",
- token);
- }
- return that;
- }
- error("Bad assignment.", that);
- }, 20);
- }
-
-
- function suffix(s, f) {
- var x = symbol(s, 150);
- x.led = function (left) {
- if (option.plusplus) {
- warning("Unexpected use of '{a}'.", this, this.id);
- } else if ((!left.identifier || left.reserved) &&
- left.id !== '.' && left.id !== '[') {
- warning("Bad operand.", this);
- }
- this.left = left;
- return this;
- };
- return x;
- }
-
-
- // fnparam means that this identifier is being defined as a function
- // argument (see identifier())
- function optionalidentifier(fnparam) {
- if (nexttoken.identifier) {
- advance();
- if (token.reserved && !option.es5) {
- // `undefined` as a function param is a common pattern to protect
- // against the case when somebody does `undefined = true` and
- // help with minification. More info: https://gist.github.com/315916
- if (!fnparam || token.value != 'undefined') {
- warning("Expected an identifier and instead saw '{a}' (a reserved word).",
- token, token.id);
- }
- }
- return token.value;
- }
- }
-
- // fnparam means that this identifier is being defined as a function
- // argument
- function identifier(fnparam) {
- var i = optionalidentifier(fnparam);
- if (i) {
- return i;
- }
- if (token.id === 'function' && nexttoken.id === '(') {
- warning("Missing name in function declaration.");
- } else {
- error("Expected an identifier and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- }
-
-
- function reachable(s) {
- var i = 0, t;
- if (nexttoken.id !== ';' || noreach) {
- return;
- }
- for (;;) {
- t = peek(i);
- if (t.reach) {
- return;
- }
- if (t.id !== '(endline)') {
- if (t.id === 'function') {
- warning(
-"Inner functions should be listed at the top of the outer function.", t);
- break;
- }
- warning("Unreachable '{a}' after '{b}'.", t, t.value, s);
- break;
- }
- i += 1;
- }
- }
-
-
- function statement(noindent) {
- var i = indent, r, s = scope, t = nexttoken;
-
-// We don't like the empty statement.
-
- if (t.id === ';') {
- warning("Unnecessary semicolon.", t);
- advance(';');
- return;
- }
-
-// Is this a labelled statement?
-
- if (t.identifier && !t.reserved && peek().id === ':') {
- advance();
- advance(':');
- scope = Object.create(s);
- addlabel(t.value, 'label');
- if (!nexttoken.labelled) {
- warning("Label '{a}' on {b} statement.",
- nexttoken, t.value, nexttoken.value);
- }
- if (jx.test(t.value + ':')) {
- warning("Label '{a}' looks like a javascript url.",
- t, t.value);
- }
- nexttoken.label = t.value;
- t = nexttoken;
- }
-
-// Parse the statement.
-
- if (!noindent) {
- indentation();
- }
- r = expression(0, true);
-
-// Look for the final semicolon.
-
- if (!t.block) {
- if (!option.expr && (!r || !r.exps)) {
- warning("Expected an assignment or function call and instead saw an expression.", token);
- } else if (option.nonew && r.id === '(' && r.left.id === 'new') {
- warning("Do not use 'new' for side effects.");
- }
- if (nexttoken.id !== ';') {
- if (!option.asi) {
- warningAt("Missing semicolon.", token.line, token.from + token.value.length);
- }
- } else {
- adjacent(token, nexttoken);
- advance(';');
- nonadjacent(token, nexttoken);
- }
- }
-
-// Restore the indentation.
-
- indent = i;
- scope = s;
- return r;
- }
-
-
- function use_strict() {
- if (nexttoken.value === 'use strict') {
- if (strict_mode) {
- warning("Unnecessary \"use strict\".");
- }
- advance();
- advance(';');
- strict_mode = true;
- option.newcap = true;
- option.undef = true;
- return true;
- } else {
- return false;
- }
- }
-
-
- function statements(begin) {
- var a = [], f, p;
-
- while (!nexttoken.reach && nexttoken.id !== '(end)') {
- if (nexttoken.id === ';') {
- warning("Unnecessary semicolon.");
- advance(';');
- } else {
- a.push(statement());
- }
- }
- return a;
- }
-
-
- /*
- * Parses a single block. A block is a sequence of statements wrapped in
- * braces.
- *
- * ordinary - true for everything but function bodies and try blocks.
- * stmt - true if block can be a single statement (e.g. in if/for/while).
- */
- function block(ordinary, stmt) {
- var a,
- b = inblock,
- old_indent = indent,
- m = strict_mode,
- s = scope,
- t;
-
- inblock = ordinary;
- scope = Object.create(scope);
- nonadjacent(token, nexttoken);
- t = nexttoken;
-
- if (nexttoken.id === '{') {
- advance('{');
- if (nexttoken.id !== '}' || token.line !== nexttoken.line) {
- indent += option.indent;
- while (!ordinary && nexttoken.from > indent) {
- indent += option.indent;
- }
- if (!ordinary && !use_strict() && !m && option.strict &&
- funct['(context)']['(global)']) {
- warning("Missing \"use strict\" statement.");
- }
- a = statements();
- strict_mode = m;
- indent -= option.indent;
- indentation();
- }
- advance('}', t);
- indent = old_indent;
- } else if (!ordinary) {
- error("Expected '{a}' and instead saw '{b}'.",
- nexttoken, '{', nexttoken.value);
- } else {
- if (!stmt || option.curly)
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, '{', nexttoken.value);
-
- noreach = true;
- a = [statement()];
- noreach = false;
- }
- funct['(verb)'] = null;
- scope = s;
- inblock = b;
- if (ordinary && option.noempty && (!a || a.length === 0)) {
- warning("Empty block.");
- }
- return a;
- }
-
-
- function countMember(m) {
- if (membersOnly && typeof membersOnly[m] !== 'boolean') {
- warning("Unexpected /*member '{a}'.", token, m);
- }
- if (typeof member[m] === 'number') {
- member[m] += 1;
- } else {
- member[m] = 1;
- }
- }
-
-
- function note_implied(token) {
- var name = token.value, line = token.line, a = implied[name];
- if (typeof a === 'function') {
- a = false;
- }
- if (!a) {
- a = [line];
- implied[name] = a;
- } else if (a[a.length - 1] !== line) {
- a.push(line);
- }
- }
-
-// Build the syntax table by declaring the syntactic elements of the language.
-
- type('(number)', function () {
- return this;
- });
- type('(string)', function () {
- return this;
- });
-
- syntax['(identifier)'] = {
- type: '(identifier)',
- lbp: 0,
- identifier: true,
- nud: function () {
- var v = this.value,
- s = scope[v],
- f;
- if (typeof s === 'function') {
-
-// Protection against accidental inheritance.
-
- s = undefined;
- } else if (typeof s === 'boolean') {
- f = funct;
- funct = functions[0];
- addlabel(v, 'var');
- s = funct;
- funct = f;
- }
-
-// The name is in scope and defined in the current function.
-
- if (funct === s) {
-
-// Change 'unused' to 'var', and reject labels.
-
- switch (funct[v]) {
- case 'unused':
- funct[v] = 'var';
- break;
- case 'unction':
- funct[v] = 'function';
- this['function'] = true;
- break;
- case 'function':
- this['function'] = true;
- break;
- case 'label':
- warning("'{a}' is a statement label.", token, v);
- break;
- }
-
-// The name is not defined in the function. If we are in the global scope,
-// then we have an undefined variable.
-//
-// Operators typeof and delete do not raise runtime errors even if the base
-// object of a reference is null so no need to display warning if we're
-// inside of typeof or delete.
-
- } else if (funct['(global)']) {
- if (anonname != 'typeof' && anonname != 'delete' &&
- option.undef && typeof predefined[v] !== 'boolean') {
- warning("'{a}' i
<TRUNCATED>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[08/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js b/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
index 11e1f0a..b4c02d3 100644
--- a/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
+++ b/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
@@ -1,480 +1,480 @@
-/*
- http://www.JSON.org/json2.js
- 2011-02-23
-
- Public Domain.
-
- NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
-
- See http://www.JSON.org/js.html
-
-
- This code should be minified before deployment.
- See http://javascript.crockford.com/jsmin.html
-
- USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
- NOT CONTROL.
-
-
- This file creates a global JSON object containing two methods: stringify
- and parse.
-
- JSON.stringify(value, replacer, space)
- value any JavaScript value, usually an object or array.
-
- replacer an optional parameter that determines how object
- values are stringified for objects. It can be a
- function or an array of strings.
-
- space an optional parameter that specifies the indentation
- of nested structures. If it is omitted, the text will
- be packed without extra whitespace. If it is a number,
- it will specify the number of spaces to indent at each
- level. If it is a string (such as '\t' or ' '),
- it contains the characters used to indent at each level.
-
- This method produces a JSON text from a JavaScript value.
-
- When an object value is found, if the object contains a toJSON
- method, its toJSON method will be called and the result will be
- stringified. A toJSON method does not serialize: it returns the
- value represented by the name/value pair that should be serialized,
- or undefined if nothing should be serialized. The toJSON method
- will be passed the key associated with the value, and this will be
- bound to the value
-
- For example, this would serialize Dates as ISO strings.
-
- Date.prototype.toJSON = function (key) {
- function f(n) {
- // Format integers to have at least two digits.
- return n < 10 ? '0' + n : n;
- }
-
- return this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z';
- };
-
- You can provide an optional replacer method. It will be passed the
- key and value of each member, with this bound to the containing
- object. The value that is returned from your method will be
- serialized. If your method returns undefined, then the member will
- be excluded from the serialization.
-
- If the replacer parameter is an array of strings, then it will be
- used to select the members to be serialized. It filters the results
- such that only members with keys listed in the replacer array are
- stringified.
-
- Values that do not have JSON representations, such as undefined or
- functions, will not be serialized. Such values in objects will be
- dropped; in arrays they will be replaced with null. You can use
- a replacer function to replace those with JSON values.
- JSON.stringify(undefined) returns undefined.
-
- The optional space parameter produces a stringification of the
- value that is filled with line breaks and indentation to make it
- easier to read.
-
- If the space parameter is a non-empty string, then that string will
- be used for indentation. If the space parameter is a number, then
- the indentation will be that many spaces.
-
- Example:
-
- text = JSON.stringify(['e', {pluribus: 'unum'}]);
- // text is '["e",{"pluribus":"unum"}]'
-
-
- text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
- // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
-
- text = JSON.stringify([new Date()], function (key, value) {
- return this[key] instanceof Date ?
- 'Date(' + this[key] + ')' : value;
- });
- // text is '["Date(---current time---)"]'
-
-
- JSON.parse(text, reviver)
- This method parses a JSON text to produce an object or array.
- It can throw a SyntaxError exception.
-
- The optional reviver parameter is a function that can filter and
- transform the results. It receives each of the keys and values,
- and its return value is used instead of the original value.
- If it returns what it received, then the structure is not modified.
- If it returns undefined then the member is deleted.
-
- Example:
-
- // Parse the text. Values that look like ISO date strings will
- // be converted to Date objects.
-
- myData = JSON.parse(text, function (key, value) {
- var a;
- if (typeof value === 'string') {
- a =
-/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
- if (a) {
- return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
- +a[5], +a[6]));
- }
- }
- return value;
- });
-
- myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
- var d;
- if (typeof value === 'string' &&
- value.slice(0, 5) === 'Date(' &&
- value.slice(-1) === ')') {
- d = new Date(value.slice(5, -1));
- if (d) {
- return d;
- }
- }
- return value;
- });
-
-
- This is a reference implementation. You are free to copy, modify, or
- redistribute.
-*/
-
-/*jslint evil: true, strict: false, regexp: false */
-
-/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
- call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
- getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
- lastIndex, length, parse, prototype, push, replace, slice, stringify,
- test, toJSON, toString, valueOf
-*/
-
-
-// Create a JSON object only if one does not already exist. We create the
-// methods in a closure to avoid creating global variables.
-
-var JSON;
-if (!JSON) {
- JSON = {};
-}
-
-(function () {
- "use strict";
-
- function f(n) {
- // Format integers to have at least two digits.
- return n < 10 ? '0' + n : n;
- }
-
- if (typeof Date.prototype.toJSON !== 'function') {
-
- Date.prototype.toJSON = function (key) {
-
- return isFinite(this.valueOf()) ?
- this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z' : null;
- };
-
- String.prototype.toJSON =
- Number.prototype.toJSON =
- Boolean.prototype.toJSON = function (key) {
- return this.valueOf();
- };
- }
-
- var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- gap,
- indent,
- meta = { // table of character substitutions
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '\\': '\\\\'
- },
- rep;
-
-
- function quote(string) {
-
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can safely slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe escape
-// sequences.
-
- escapable.lastIndex = 0;
- return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
- var c = meta[a];
- return typeof c === 'string' ? c :
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- }) + '"' : '"' + string + '"';
- }
-
-
- function str(key, holder) {
-
-// Produce a string from holder[key].
-
- var i, // The loop counter.
- k, // The member key.
- v, // The member value.
- length,
- mind = gap,
- partial,
- value = holder[key];
-
-// If the value has a toJSON method, call it to obtain a replacement value.
-
- if (value && typeof value === 'object' &&
- typeof value.toJSON === 'function') {
- value = value.toJSON(key);
- }
-
-// If we were called with a replacer function, then call the replacer to
-// obtain a replacement value.
-
- if (typeof rep === 'function') {
- value = rep.call(holder, key, value);
- }
-
-// What happens next depends on the value's type.
-
- switch (typeof value) {
- case 'string':
- return quote(value);
-
- case 'number':
-
-// JSON numbers must be finite. Encode non-finite numbers as null.
-
- return isFinite(value) ? String(value) : 'null';
-
- case 'boolean':
- case 'null':
-
-// If the value is a boolean or null, convert it to a string. Note:
-// typeof null does not produce 'null'. The case is included here in
-// the remote chance that this gets fixed someday.
-
- return String(value);
-
-// If the type is 'object', we might be dealing with an object or an array or
-// null.
-
- case 'object':
-
-// Due to a specification blunder in ECMAScript, typeof null is 'object',
-// so watch out for that case.
-
- if (!value) {
- return 'null';
- }
-
-// Make an array to hold the partial results of stringifying this object value.
-
- gap += indent;
- partial = [];
-
-// Is the value an array?
-
- if (Object.prototype.toString.apply(value) === '[object Array]') {
-
-// The value is an array. Stringify every element. Use null as a placeholder
-// for non-JSON values.
-
- length = value.length;
- for (i = 0; i < length; i += 1) {
- partial[i] = str(i, value) || 'null';
- }
-
-// Join all of the elements together, separated with commas, and wrap them in
-// brackets.
-
- v = partial.length === 0 ? '[]' : gap ?
- '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
- '[' + partial.join(',') + ']';
- gap = mind;
- return v;
- }
-
-// If the replacer is an array, use it to select the members to be stringified.
-
- if (rep && typeof rep === 'object') {
- length = rep.length;
- for (i = 0; i < length; i += 1) {
- if (typeof rep[i] === 'string') {
- k = rep[i];
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
- }
- }
- }
- } else {
-
-// Otherwise, iterate through all of the keys in the object.
-
- for (k in value) {
- if (Object.prototype.hasOwnProperty.call(value, k)) {
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
- }
- }
- }
- }
-
-// Join all of the member texts together, separated with commas,
-// and wrap them in braces.
-
- v = partial.length === 0 ? '{}' : gap ?
- '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
- '{' + partial.join(',') + '}';
- gap = mind;
- return v;
- }
- }
-
-// If the JSON object does not yet have a stringify method, give it one.
-
- if (typeof JSON.stringify !== 'function') {
- JSON.stringify = function (value, replacer, space) {
-
-// The stringify method takes a value and an optional replacer, and an optional
-// space parameter, and returns a JSON text. The replacer can be a function
-// that can replace values, or an array of strings that will select the keys.
-// A default replacer method can be provided. Use of the space parameter can
-// produce text that is more easily readable.
-
- var i;
- gap = '';
- indent = '';
-
-// If the space parameter is a number, make an indent string containing that
-// many spaces.
-
- if (typeof space === 'number') {
- for (i = 0; i < space; i += 1) {
- indent += ' ';
- }
-
-// If the space parameter is a string, it will be used as the indent string.
-
- } else if (typeof space === 'string') {
- indent = space;
- }
-
-// If there is a replacer, it must be a function or an array.
-// Otherwise, throw an error.
-
- rep = replacer;
- if (replacer && typeof replacer !== 'function' &&
- (typeof replacer !== 'object' ||
- typeof replacer.length !== 'number')) {
- throw new Error('JSON.stringify');
- }
-
-// Make a fake root object containing our value under the key of ''.
-// Return the result of stringifying the value.
-
- return str('', {'': value});
- };
- }
-
-
-// If the JSON object does not yet have a parse method, give it one.
-
- if (typeof JSON.parse !== 'function') {
- JSON.parse = function (text, reviver) {
-
-// The parse method takes a text and an optional reviver function, and returns
-// a JavaScript value if the text is a valid JSON text.
-
- var j;
-
- function walk(holder, key) {
-
-// The walk method is used to recursively walk the resulting structure so
-// that modifications can be made.
-
- var k, v, value = holder[key];
- if (value && typeof value === 'object') {
- for (k in value) {
- if (Object.prototype.hasOwnProperty.call(value, k)) {
- v = walk(value, k);
- if (v !== undefined) {
- value[k] = v;
- } else {
- delete value[k];
- }
- }
- }
- }
- return reviver.call(holder, key, value);
- }
-
-
-// Parsing happens in four stages. In the first stage, we replace certain
-// Unicode characters with escape sequences. JavaScript handles many characters
-// incorrectly, either silently deleting them, or treating them as line endings.
-
- text = String(text);
- cx.lastIndex = 0;
- if (cx.test(text)) {
- text = text.replace(cx, function (a) {
- return '\\u' +
- ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- });
- }
-
-// In the second stage, we run the text against regular expressions that look
-// for non-JSON patterns. We are especially concerned with '()' and 'new'
-// because they can cause invocation, and '=' because it can cause mutation.
-// But just to be safe, we want to reject all unexpected forms.
-
-// We split the second stage into 4 regexp operations in order to work around
-// crippling inefficiencies in IE's and Safari's regexp engines. First we
-// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
-// replace all simple value tokens with ']' characters. Third, we delete all
-// open brackets that follow a colon or comma or that begin the text. Finally,
-// we look to see that the remaining characters are only whitespace or ']' or
-// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
-
- if (/^[\],:{}\s]*$/
- .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
- .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
- .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
-
-// In the third stage we use the eval function to compile the text into a
-// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
-// in JavaScript: it can begin a block or an object literal. We wrap the text
-// in parens to eliminate the ambiguity.
-
- j = eval('(' + text + ')');
-
-// In the optional fourth stage, we recursively walk the new structure, passing
-// each name/value pair to a reviver function for possible transformation.
-
- return typeof reviver === 'function' ?
- walk({'': j}, '') : j;
- }
-
-// If the text is not JSON parseable, then a SyntaxError is thrown.
-
- throw new SyntaxError('JSON.parse');
- };
- }
-}());
+/*
+ http://www.JSON.org/json2.js
+ 2011-02-23
+
+ Public Domain.
+
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+ See http://www.JSON.org/js.html
+
+
+ This code should be minified before deployment.
+ See http://javascript.crockford.com/jsmin.html
+
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+ NOT CONTROL.
+
+
+ This file creates a global JSON object containing two methods: stringify
+ and parse.
+
+ JSON.stringify(value, replacer, space)
+ value any JavaScript value, usually an object or array.
+
+ replacer an optional parameter that determines how object
+ values are stringified for objects. It can be a
+ function or an array of strings.
+
+ space an optional parameter that specifies the indentation
+ of nested structures. If it is omitted, the text will
+ be packed without extra whitespace. If it is a number,
+ it will specify the number of spaces to indent at each
+ level. If it is a string (such as '\t' or ' '),
+ it contains the characters used to indent at each level.
+
+ This method produces a JSON text from a JavaScript value.
+
+ When an object value is found, if the object contains a toJSON
+ method, its toJSON method will be called and the result will be
+ stringified. A toJSON method does not serialize: it returns the
+ value represented by the name/value pair that should be serialized,
+ or undefined if nothing should be serialized. The toJSON method
+ will be passed the key associated with the value, and this will be
+ bound to the value
+
+ For example, this would serialize Dates as ISO strings.
+
+ Date.prototype.toJSON = function (key) {
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ return this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z';
+ };
+
+ You can provide an optional replacer method. It will be passed the
+ key and value of each member, with this bound to the containing
+ object. The value that is returned from your method will be
+ serialized. If your method returns undefined, then the member will
+ be excluded from the serialization.
+
+ If the replacer parameter is an array of strings, then it will be
+ used to select the members to be serialized. It filters the results
+ such that only members with keys listed in the replacer array are
+ stringified.
+
+ Values that do not have JSON representations, such as undefined or
+ functions, will not be serialized. Such values in objects will be
+ dropped; in arrays they will be replaced with null. You can use
+ a replacer function to replace those with JSON values.
+ JSON.stringify(undefined) returns undefined.
+
+ The optional space parameter produces a stringification of the
+ value that is filled with line breaks and indentation to make it
+ easier to read.
+
+ If the space parameter is a non-empty string, then that string will
+ be used for indentation. If the space parameter is a number, then
+ the indentation will be that many spaces.
+
+ Example:
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
+ // text is '["e",{"pluribus":"unum"}]'
+
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+ text = JSON.stringify([new Date()], function (key, value) {
+ return this[key] instanceof Date ?
+ 'Date(' + this[key] + ')' : value;
+ });
+ // text is '["Date(---current time---)"]'
+
+
+ JSON.parse(text, reviver)
+ This method parses a JSON text to produce an object or array.
+ It can throw a SyntaxError exception.
+
+ The optional reviver parameter is a function that can filter and
+ transform the results. It receives each of the keys and values,
+ and its return value is used instead of the original value.
+ If it returns what it received, then the structure is not modified.
+ If it returns undefined then the member is deleted.
+
+ Example:
+
+ // Parse the text. Values that look like ISO date strings will
+ // be converted to Date objects.
+
+ myData = JSON.parse(text, function (key, value) {
+ var a;
+ if (typeof value === 'string') {
+ a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+ if (a) {
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+ +a[5], +a[6]));
+ }
+ }
+ return value;
+ });
+
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+ var d;
+ if (typeof value === 'string' &&
+ value.slice(0, 5) === 'Date(' &&
+ value.slice(-1) === ')') {
+ d = new Date(value.slice(5, -1));
+ if (d) {
+ return d;
+ }
+ }
+ return value;
+ });
+
+
+ This is a reference implementation. You are free to copy, modify, or
+ redistribute.
+*/
+
+/*jslint evil: true, strict: false, regexp: false */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
+ test, toJSON, toString, valueOf
+*/
+
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+var JSON;
+if (!JSON) {
+ JSON = {};
+}
+
+(function () {
+ "use strict";
+
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ if (typeof Date.prototype.toJSON !== 'function') {
+
+ Date.prototype.toJSON = function (key) {
+
+ return isFinite(this.valueOf()) ?
+ this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z' : null;
+ };
+
+ String.prototype.toJSON =
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
+ }
+
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+
+ function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+ escapable.lastIndex = 0;
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string' ? c :
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' : '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+
+// Produce a string from holder[key].
+
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+ if (value && typeof value === 'object' &&
+ typeof value.toJSON === 'function') {
+ value = value.toJSON(key);
+ }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+// What happens next depends on the value's type.
+
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+ return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+ case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+ if (!value) {
+ return 'null';
+ }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+ gap += indent;
+ partial = [];
+
+// Is the value an array?
+
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+ v = partial.length === 0 ? '[]' : gap ?
+ '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
+ '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ if (typeof rep[i] === 'string') {
+ k = rep[i];
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+ v = partial.length === 0 ? '{}' : gap ?
+ '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
+ '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+ if (typeof JSON.stringify !== 'function') {
+ JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+ var i;
+ gap = '';
+ indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+ return str('', {'': value});
+ };
+ }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+ if (typeof JSON.parse !== 'function') {
+ JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+ var j;
+
+ function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+ var k, v, value = holder[key];
+ if (value && typeof value === 'object') {
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = walk(value, k);
+ if (v !== undefined) {
+ value[k] = v;
+ } else {
+ delete value[k];
+ }
+ }
+ }
+ }
+ return reviver.call(holder, key, value);
+ }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+ text = String(text);
+ cx.lastIndex = 0;
+ if (cx.test(text)) {
+ text = text.replace(cx, function (a) {
+ return '\\u' +
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ });
+ }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+ if (/^[\],:{}\s]*$/
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+ j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+ return typeof reviver === 'function' ?
+ walk({'': j}, '') : j;
+ }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+ throw new SyntaxError('JSON.parse');
+ };
+ }
+}());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[04/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/LICENSE-MIT
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/LICENSE-MIT b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/LICENSE-MIT
index 819b403..56420a6 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/LICENSE-MIT
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/LICENSE-MIT
@@ -1,22 +1,22 @@
-Copyright (c) 2014 Chris Talkington, contributors.
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+Copyright (c) 2014 Chris Talkington, contributors.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/README.md b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/README.md
index c891a0d..23c3142 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/README.md
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/README.md
@@ -1,26 +1,26 @@
-# Compress Commons v0.1.6 [](https://travis-ci.org/ctalkington/node-compress-commons)
-
-Compress Commons is a library that defines a common interface for working with archives within node.
-
-[](https://nodei.co/npm/compress-commons/)
-
-## Install
-
-```bash
-npm install compress-commons --save
-```
-
-You can also use `npm install https://github.com/ctalkington/node-compress-commons/archive/master.tar.gz` to test upcoming versions.
-
-## Things of Interest
-
-- [Source Docs (coming soon)](https://docsrc.com/compress-commons/)
-- [Changelog](https://github.com/ctalkington/node-compress-commons/releases)
-- [Contributing](https://github.com/ctalkington/node-compress-commons/blob/master/CONTRIBUTING.md)
-- [MIT License](https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT)
-
-## Credits
-
-Concept inspired by [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™.
-
+# Compress Commons v0.1.6 [](https://travis-ci.org/ctalkington/node-compress-commons)
+
+Compress Commons is a library that defines a common interface for working with archives within node.
+
+[](https://nodei.co/npm/compress-commons/)
+
+## Install
+
+```bash
+npm install compress-commons --save
+```
+
+You can also use `npm install https://github.com/ctalkington/node-compress-commons/archive/master.tar.gz` to test upcoming versions.
+
+## Things of Interest
+
+- [Source Docs (coming soon)](https://docsrc.com/compress-commons/)
+- [Changelog](https://github.com/ctalkington/node-compress-commons/releases)
+- [Contributing](https://github.com/ctalkington/node-compress-commons/blob/master/CONTRIBUTING.md)
+- [MIT License](https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT)
+
+## Credits
+
+Concept inspired by [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™.
+
Some logic derived from [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™ and [OpenJDK 7](http://openjdk.java.net/).
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-entry.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-entry.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-entry.js
index 3c6f8b8..4985e2c 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-entry.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-entry.js
@@ -1,16 +1,16 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var ArchiveEntry = module.exports = function() {};
-
-ArchiveEntry.prototype.getName = function() {};
-
-ArchiveEntry.prototype.getSize = function() {};
-
-ArchiveEntry.prototype.getLastModifiedDate = function() {};
-
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var ArchiveEntry = module.exports = function() {};
+
+ArchiveEntry.prototype.getName = function() {};
+
+ArchiveEntry.prototype.getSize = function() {};
+
+ArchiveEntry.prototype.getLastModifiedDate = function() {};
+
ArchiveEntry.prototype.isDirectory = function() {};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-output-stream.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-output-stream.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-output-stream.js
index 939629d..a3cdd91 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-output-stream.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-output-stream.js
@@ -1,113 +1,113 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-var Transform = require('readable-stream').Transform;
-
-var ArchiveEntry = require('./archive-entry');
-var util = require('../util');
-
-var ArchiveOutputStream = module.exports = function(options) {
- if (!(this instanceof ArchiveOutputStream)) {
- return new ArchiveOutputStream(options);
- }
-
- Transform.call(this, options);
-
- this.offset = 0;
-};
-
-inherits(ArchiveOutputStream, Transform);
-
-ArchiveOutputStream.prototype._appendBuffer = function(zae, source, callback) {
- // scaffold only
-};
-
-ArchiveOutputStream.prototype._appendStream = function(zae, source, callback) {
- // scaffold only
-};
-
-ArchiveOutputStream.prototype._emitErrorCallback = function(err) {
- if (err) {
- this.emit('error', err);
- }
-};
-
-ArchiveOutputStream.prototype._finish = function(ae) {
- // scaffold only
-};
-
-ArchiveOutputStream.prototype._setDefaults = function(ae) {
- // scaffold only
-};
-
-ArchiveOutputStream.prototype._transform = function(chunk, encoding, callback) {
- callback(null, chunk);
-};
-
-ArchiveOutputStream.prototype.entry = function(ae, source, callback) {
- source = source || null;
-
- if (typeof callback !== 'function') {
- callback = this._emitErrorCallback.bind(this);
- }
-
- if (!(ae instanceof ArchiveEntry)) {
- callback(new Error('not a valid instance of ArchiveEntry'));
- return;
- }
-
- if (this._archive.finish || this._archive.finished) {
- callback(new Error('unacceptable entry after finish'));
- return;
- }
-
- if (this._archive.processing) {
- callback(new Error('already processing an entry'));
- return;
- }
-
- this._archive.processing = true;
- this._setDefaults(ae);
- this._entry = ae;
-
- source = util.normalizeInputSource(source);
-
- if (Buffer.isBuffer(source)) {
- this._appendBuffer(ae, source, callback);
- } else if (util.isStream(source)) {
- source.on('error', callback);
- this._appendStream(ae, source, callback);
- } else {
- this._archive.processing = false;
- callback(new Error('input source must be valid Stream or Buffer instance'));
- return;
- }
-
- return this;
-};
-
-ArchiveOutputStream.prototype.finish = function() {
- if (this._archive.processing) {
- this._archive.finish = true;
- return;
- }
-
- this._finish();
-};
-
-ArchiveOutputStream.prototype.getBytesWritten = function() {
- return this.offset;
-};
-
-ArchiveOutputStream.prototype.write = function(chunk, cb) {
- if (chunk) {
- this.offset += chunk.length;
- }
-
- return Transform.prototype.write.call(this, chunk, cb);
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+var Transform = require('readable-stream').Transform;
+
+var ArchiveEntry = require('./archive-entry');
+var util = require('../util');
+
+var ArchiveOutputStream = module.exports = function(options) {
+ if (!(this instanceof ArchiveOutputStream)) {
+ return new ArchiveOutputStream(options);
+ }
+
+ Transform.call(this, options);
+
+ this.offset = 0;
+};
+
+inherits(ArchiveOutputStream, Transform);
+
+ArchiveOutputStream.prototype._appendBuffer = function(zae, source, callback) {
+ // scaffold only
+};
+
+ArchiveOutputStream.prototype._appendStream = function(zae, source, callback) {
+ // scaffold only
+};
+
+ArchiveOutputStream.prototype._emitErrorCallback = function(err) {
+ if (err) {
+ this.emit('error', err);
+ }
+};
+
+ArchiveOutputStream.prototype._finish = function(ae) {
+ // scaffold only
+};
+
+ArchiveOutputStream.prototype._setDefaults = function(ae) {
+ // scaffold only
+};
+
+ArchiveOutputStream.prototype._transform = function(chunk, encoding, callback) {
+ callback(null, chunk);
+};
+
+ArchiveOutputStream.prototype.entry = function(ae, source, callback) {
+ source = source || null;
+
+ if (typeof callback !== 'function') {
+ callback = this._emitErrorCallback.bind(this);
+ }
+
+ if (!(ae instanceof ArchiveEntry)) {
+ callback(new Error('not a valid instance of ArchiveEntry'));
+ return;
+ }
+
+ if (this._archive.finish || this._archive.finished) {
+ callback(new Error('unacceptable entry after finish'));
+ return;
+ }
+
+ if (this._archive.processing) {
+ callback(new Error('already processing an entry'));
+ return;
+ }
+
+ this._archive.processing = true;
+ this._setDefaults(ae);
+ this._entry = ae;
+
+ source = util.normalizeInputSource(source);
+
+ if (Buffer.isBuffer(source)) {
+ this._appendBuffer(ae, source, callback);
+ } else if (util.isStream(source)) {
+ source.on('error', callback);
+ this._appendStream(ae, source, callback);
+ } else {
+ this._archive.processing = false;
+ callback(new Error('input source must be valid Stream or Buffer instance'));
+ return;
+ }
+
+ return this;
+};
+
+ArchiveOutputStream.prototype.finish = function() {
+ if (this._archive.processing) {
+ this._archive.finish = true;
+ return;
+ }
+
+ this._finish();
+};
+
+ArchiveOutputStream.prototype.getBytesWritten = function() {
+ return this.offset;
+};
+
+ArchiveOutputStream.prototype.write = function(chunk, cb) {
+ if (chunk) {
+ this.offset += chunk.length;
+ }
+
+ return Transform.prototype.write.call(this, chunk, cb);
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/constants.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/constants.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/constants.js
index 47d837e..918c6e1 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/constants.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/constants.js
@@ -1,67 +1,67 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-module.exports = {
- WORD: 4,
- DWORD: 8,
- EMPTY: new Buffer(0),
-
- SHORT: 2,
- SHORT_MASK: 0xffff,
- SHORT_SHIFT: 16,
- SHORT_ZERO: new Buffer(Array(2)),
- LONG_ZERO: new Buffer(Array(4)),
-
- DATA_DESCRIPTOR_MIN_VERSION: 20,
- INITIAL_VERSION: 10,
-
- METHOD_STORED: 0,
- METHOD_DEFLATED: 8,
-
- PLATFORM_UNIX: 3,
- PLATFORM_FAT: 0,
-
- SIG_LFH: 0x04034b50,
- SIG_DD: 0x08074b50,
- SIG_CFH: 0x02014b50,
- SIG_EOCD: 0x06054b50,
- SIG_ZIP64_EOCD: 0x06064B50,
- SIG_ZIP64_EOCD_LOC: 0x07064B50,
-
- ZIP64_MIN_VERSION: 45,
- ZIP64_MAGIC_SHORT: 0xffff,
- ZIP64_MAGIC: 0xffffffff,
-
- ZLIB_NO_COMPRESSION: 0,
- ZLIB_BEST_SPEED: 1,
- ZLIB_BEST_COMPRESSION: 9,
- ZLIB_DEFAULT_COMPRESSION: -1,
-
- MODE_MASK: 0xFFF,
- DEFAULT_FILE_MODE: 0100644, // 644 -rw-r--r-- = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
- DEFAULT_DIR_MODE: 040755, // 755 drwxr-xr-x = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
-
- EXT_FILE_ATTR_DIR: 010173200020, // 755 drwxr-xr-x = (((S_IFDIR | 0755) << 16) | S_DOS_D)
- EXT_FILE_ATTR_FILE: 020151000040, // 644 -rw-r--r-- = (((S_IFREG | 0644) << 16) | S_DOS_A) >>> 0
-
- // Unix file types
- S_IFIFO: 010000, // named pipe (fifo)
- S_IFCHR: 020000, // character special
- S_IFDIR: 040000, // directory
- S_IFBLK: 060000, // block special
- S_IFREG: 0100000, // regular
- S_IFLNK: 0120000, // symbolic link
- S_IFSOCK: 0140000, // socket
-
- // DOS file type flags
- S_DOS_A: 040, // Archive
- S_DOS_D: 020, // Directory
- S_DOS_V: 010, // Volume
- S_DOS_S: 04, // System
- S_DOS_H: 02, // Hidden
- S_DOS_R: 01 // Read Only
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+module.exports = {
+ WORD: 4,
+ DWORD: 8,
+ EMPTY: new Buffer(0),
+
+ SHORT: 2,
+ SHORT_MASK: 0xffff,
+ SHORT_SHIFT: 16,
+ SHORT_ZERO: new Buffer(Array(2)),
+ LONG_ZERO: new Buffer(Array(4)),
+
+ DATA_DESCRIPTOR_MIN_VERSION: 20,
+ INITIAL_VERSION: 10,
+
+ METHOD_STORED: 0,
+ METHOD_DEFLATED: 8,
+
+ PLATFORM_UNIX: 3,
+ PLATFORM_FAT: 0,
+
+ SIG_LFH: 0x04034b50,
+ SIG_DD: 0x08074b50,
+ SIG_CFH: 0x02014b50,
+ SIG_EOCD: 0x06054b50,
+ SIG_ZIP64_EOCD: 0x06064B50,
+ SIG_ZIP64_EOCD_LOC: 0x07064B50,
+
+ ZIP64_MIN_VERSION: 45,
+ ZIP64_MAGIC_SHORT: 0xffff,
+ ZIP64_MAGIC: 0xffffffff,
+
+ ZLIB_NO_COMPRESSION: 0,
+ ZLIB_BEST_SPEED: 1,
+ ZLIB_BEST_COMPRESSION: 9,
+ ZLIB_DEFAULT_COMPRESSION: -1,
+
+ MODE_MASK: 0xFFF,
+ DEFAULT_FILE_MODE: 0100644, // 644 -rw-r--r-- = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
+ DEFAULT_DIR_MODE: 040755, // 755 drwxr-xr-x = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
+
+ EXT_FILE_ATTR_DIR: 010173200020, // 755 drwxr-xr-x = (((S_IFDIR | 0755) << 16) | S_DOS_D)
+ EXT_FILE_ATTR_FILE: 020151000040, // 644 -rw-r--r-- = (((S_IFREG | 0644) << 16) | S_DOS_A) >>> 0
+
+ // Unix file types
+ S_IFIFO: 010000, // named pipe (fifo)
+ S_IFCHR: 020000, // character special
+ S_IFDIR: 040000, // directory
+ S_IFBLK: 060000, // block special
+ S_IFREG: 0100000, // regular
+ S_IFLNK: 0120000, // symbolic link
+ S_IFSOCK: 0140000, // socket
+
+ // DOS file type flags
+ S_DOS_A: 040, // Archive
+ S_DOS_D: 020, // Directory
+ S_DOS_V: 010, // Volume
+ S_DOS_S: 04, // System
+ S_DOS_H: 02, // Hidden
+ S_DOS_R: 01 // Read Only
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/general-purpose-bit.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/general-purpose-bit.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/general-purpose-bit.js
index dc21073..96f3702 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/general-purpose-bit.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/general-purpose-bit.js
@@ -1,101 +1,101 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var zipUtil = require('./util');
-
-var DATA_DESCRIPTOR_FLAG = 1 << 3;
-var ENCRYPTION_FLAG = 1 << 0;
-var NUMBER_OF_SHANNON_FANO_TREES_FLAG = 1 << 2;
-var SLIDING_DICTIONARY_SIZE_FLAG = 1 << 1;
-var STRONG_ENCRYPTION_FLAG = 1 << 6;
-var UFT8_NAMES_FLAG = 1 << 11;
-
-var GeneralPurposeBit = module.exports = function() {
- if (!(this instanceof GeneralPurposeBit)) {
- return new GeneralPurposeBit();
- }
-
- this.descriptor = false;
- this.encryption = false;
- this.utf8 = false;
- this.numberOfShannonFanoTrees = 0;
- this.strongEncryption = false;
- this.slidingDictionarySize = 0;
-
- return this;
-};
-
-GeneralPurposeBit.prototype.encode = function() {
- return zipUtil.getShortBytes(
- (this.descriptor ? DATA_DESCRIPTOR_FLAG : 0) |
- (this.utf8 ? UFT8_NAMES_FLAG : 0) |
- (this.encryption ? ENCRYPTION_FLAG : 0) |
- (this.strongEncryption ? STRONG_ENCRYPTION_FLAG : 0)
- );
-};
-
-GeneralPurposeBit.prototype.parse = function(buf, offset) {
- var flag = zipUtil.getShortBytesValue(buf, offset);
- var gbp = new GeneralPurposeBit();
-
- gbp.useDataDescriptor((flag & DATA_DESCRIPTOR_FLAG) !== 0);
- gbp.useUTF8ForNames((flag & UFT8_NAMES_FLAG) !== 0);
- gbp.useStrongEncryption((flag & STRONG_ENCRYPTION_FLAG) !== 0);
- gbp.useEncryption((flag & ENCRYPTION_FLAG) !== 0);
- gbp.setSlidingDictionarySize((flag & SLIDING_DICTIONARY_SIZE_FLAG) !== 0 ? 8192 : 4096);
- gbp.setNumberOfShannonFanoTrees((flag & NUMBER_OF_SHANNON_FANO_TREES_FLAG) !== 0 ? 3 : 2);
-
- return gbp;
-};
-
-GeneralPurposeBit.prototype.setNumberOfShannonFanoTrees = function(n) {
- this.numberOfShannonFanoTrees = n;
-};
-
-GeneralPurposeBit.prototype.getNumberOfShannonFanoTrees = function() {
- return this.numberOfShannonFanoTrees;
-};
-
-GeneralPurposeBit.prototype.setSlidingDictionarySize = function(n) {
- this.slidingDictionarySize = n;
-};
-
-GeneralPurposeBit.prototype.getSlidingDictionarySize = function() {
- return this.slidingDictionarySize;
-};
-
-GeneralPurposeBit.prototype.useDataDescriptor = function(b) {
- this.descriptor = b;
-};
-
-GeneralPurposeBit.prototype.usesDataDescriptor = function() {
- return this.descriptor;
-};
-
-GeneralPurposeBit.prototype.useEncryption = function(b) {
- this.encryption = b;
-};
-
-GeneralPurposeBit.prototype.usesEncryption = function() {
- return this.encryption;
-};
-
-GeneralPurposeBit.prototype.useStrongEncryption = function(b) {
- this.strongEncryption = b;
-};
-
-GeneralPurposeBit.prototype.usesStrongEncryption = function() {
- return this.strongEncryption;
-};
-
-GeneralPurposeBit.prototype.useUTF8ForNames = function(b) {
- this.utf8 = b;
-};
-
-GeneralPurposeBit.prototype.usesUTF8ForNames = function() {
- return this.utf8;
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var zipUtil = require('./util');
+
+var DATA_DESCRIPTOR_FLAG = 1 << 3;
+var ENCRYPTION_FLAG = 1 << 0;
+var NUMBER_OF_SHANNON_FANO_TREES_FLAG = 1 << 2;
+var SLIDING_DICTIONARY_SIZE_FLAG = 1 << 1;
+var STRONG_ENCRYPTION_FLAG = 1 << 6;
+var UFT8_NAMES_FLAG = 1 << 11;
+
+var GeneralPurposeBit = module.exports = function() {
+ if (!(this instanceof GeneralPurposeBit)) {
+ return new GeneralPurposeBit();
+ }
+
+ this.descriptor = false;
+ this.encryption = false;
+ this.utf8 = false;
+ this.numberOfShannonFanoTrees = 0;
+ this.strongEncryption = false;
+ this.slidingDictionarySize = 0;
+
+ return this;
+};
+
+GeneralPurposeBit.prototype.encode = function() {
+ return zipUtil.getShortBytes(
+ (this.descriptor ? DATA_DESCRIPTOR_FLAG : 0) |
+ (this.utf8 ? UFT8_NAMES_FLAG : 0) |
+ (this.encryption ? ENCRYPTION_FLAG : 0) |
+ (this.strongEncryption ? STRONG_ENCRYPTION_FLAG : 0)
+ );
+};
+
+GeneralPurposeBit.prototype.parse = function(buf, offset) {
+ var flag = zipUtil.getShortBytesValue(buf, offset);
+ var gbp = new GeneralPurposeBit();
+
+ gbp.useDataDescriptor((flag & DATA_DESCRIPTOR_FLAG) !== 0);
+ gbp.useUTF8ForNames((flag & UFT8_NAMES_FLAG) !== 0);
+ gbp.useStrongEncryption((flag & STRONG_ENCRYPTION_FLAG) !== 0);
+ gbp.useEncryption((flag & ENCRYPTION_FLAG) !== 0);
+ gbp.setSlidingDictionarySize((flag & SLIDING_DICTIONARY_SIZE_FLAG) !== 0 ? 8192 : 4096);
+ gbp.setNumberOfShannonFanoTrees((flag & NUMBER_OF_SHANNON_FANO_TREES_FLAG) !== 0 ? 3 : 2);
+
+ return gbp;
+};
+
+GeneralPurposeBit.prototype.setNumberOfShannonFanoTrees = function(n) {
+ this.numberOfShannonFanoTrees = n;
+};
+
+GeneralPurposeBit.prototype.getNumberOfShannonFanoTrees = function() {
+ return this.numberOfShannonFanoTrees;
+};
+
+GeneralPurposeBit.prototype.setSlidingDictionarySize = function(n) {
+ this.slidingDictionarySize = n;
+};
+
+GeneralPurposeBit.prototype.getSlidingDictionarySize = function() {
+ return this.slidingDictionarySize;
+};
+
+GeneralPurposeBit.prototype.useDataDescriptor = function(b) {
+ this.descriptor = b;
+};
+
+GeneralPurposeBit.prototype.usesDataDescriptor = function() {
+ return this.descriptor;
+};
+
+GeneralPurposeBit.prototype.useEncryption = function(b) {
+ this.encryption = b;
+};
+
+GeneralPurposeBit.prototype.usesEncryption = function() {
+ return this.encryption;
+};
+
+GeneralPurposeBit.prototype.useStrongEncryption = function(b) {
+ this.strongEncryption = b;
+};
+
+GeneralPurposeBit.prototype.usesStrongEncryption = function() {
+ return this.strongEncryption;
+};
+
+GeneralPurposeBit.prototype.useUTF8ForNames = function(b) {
+ this.utf8 = b;
+};
+
+GeneralPurposeBit.prototype.usesUTF8ForNames = function() {
+ return this.utf8;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/util.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/util.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/util.js
index 14a6107..2303a72 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/util.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/util.js
@@ -1,71 +1,71 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var util = module.exports = {};
-
-util.dateToDos = function(d) {
- var year = d.getFullYear();
-
- if (year < 1980) {
- return 2162688; // 1980-1-1 00:00:00
- } else if (year >= 2044) {
- return 2141175677; // 2043-12-31 23:59:58
- }
-
- var val = {
- year: year,
- month: d.getMonth(),
- date: d.getDate(),
- hours: d.getHours(),
- minutes: d.getMinutes(),
- seconds: d.getSeconds()
- };
-
- return ((val.year - 1980) << 25) | ((val.month + 1) << 21) | (val.date << 16) |
- (val.hours << 11) | (val.minutes << 5) | (val.seconds / 2);
-};
-
-util.dosToDate = function(dos) {
- return new Date(
- ((dos >> 25) & 0x7f) + 1980,
- ((dos >> 21) & 0x0f) - 1,
- (dos >> 16) & 0x1f,
- (dos >> 11) & 0x1f,
- (dos >> 5) & 0x3f,
- (dos & 0x1f) << 1
- );
-};
-
-util.fromDosTime = function(buf) {
- return util.dosToDate(buf.readUInt32LE());
-};
-
-util.getShortBytes = function(v) {
- var buf = new Buffer(2);
- buf.writeUInt16LE(v, 0);
-
- return buf;
-};
-
-util.getShortBytesValue = function(buf, offset) {
- return buf.readUInt16LE(offset);
-};
-
-util.getLongBytes = function(v) {
- var buf = new Buffer(4);
- buf.writeUInt32LE(v, 0);
-
- return buf;
-};
-
-util.getLongBytesValue = function(buf, offset) {
- return buf.readUInt32LE(offset);
-};
-
-util.toDosTime = function(d) {
- return util.getLongBytes(util.dateToDos(d));
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var util = module.exports = {};
+
+util.dateToDos = function(d) {
+ var year = d.getFullYear();
+
+ if (year < 1980) {
+ return 2162688; // 1980-1-1 00:00:00
+ } else if (year >= 2044) {
+ return 2141175677; // 2043-12-31 23:59:58
+ }
+
+ var val = {
+ year: year,
+ month: d.getMonth(),
+ date: d.getDate(),
+ hours: d.getHours(),
+ minutes: d.getMinutes(),
+ seconds: d.getSeconds()
+ };
+
+ return ((val.year - 1980) << 25) | ((val.month + 1) << 21) | (val.date << 16) |
+ (val.hours << 11) | (val.minutes << 5) | (val.seconds / 2);
+};
+
+util.dosToDate = function(dos) {
+ return new Date(
+ ((dos >> 25) & 0x7f) + 1980,
+ ((dos >> 21) & 0x0f) - 1,
+ (dos >> 16) & 0x1f,
+ (dos >> 11) & 0x1f,
+ (dos >> 5) & 0x3f,
+ (dos & 0x1f) << 1
+ );
+};
+
+util.fromDosTime = function(buf) {
+ return util.dosToDate(buf.readUInt32LE());
+};
+
+util.getShortBytes = function(v) {
+ var buf = new Buffer(2);
+ buf.writeUInt16LE(v, 0);
+
+ return buf;
+};
+
+util.getShortBytesValue = function(buf, offset) {
+ return buf.readUInt16LE(offset);
+};
+
+util.getLongBytes = function(v) {
+ var buf = new Buffer(4);
+ buf.writeUInt32LE(v, 0);
+
+ return buf;
+};
+
+util.getLongBytesValue = function(buf, offset) {
+ return buf.readUInt32LE(offset);
+};
+
+util.toDosTime = function(d) {
+ return util.getLongBytes(util.dateToDos(d));
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-entry.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-entry.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-entry.js
index 1883eb5..07c95e3 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-entry.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-entry.js
@@ -1,223 +1,223 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-
-var ArchiveEntry = require('../archive-entry');
-var GeneralPurposeBit = require('./general-purpose-bit');
-
-var constants = require('./constants');
-var zipUtil = require('./util');
-
-var ZipArchiveEntry = module.exports = function(name) {
- if (!(this instanceof ZipArchiveEntry)) {
- return new ZipArchiveEntry(name);
- }
-
- ArchiveEntry.call(this);
-
- this.platform = constants.PLATFORM_FAT;
- this.method = -1;
-
- this.name = null;
- this.size = -1;
- this.csize = -1;
- this.gpb = new GeneralPurposeBit();
- this.crc = 0;
- this.time = -1;
-
- this.minver = constants.INITIAL_VERSION;
- this.mode = -1;
- this.extra = null;
- this.exattr = 0;
- this.inattr = 0;
- this.comment = null;
-
- if (name) {
- this.setName(name);
- }
-};
-
-inherits(ZipArchiveEntry, ArchiveEntry);
-
-ZipArchiveEntry.prototype.getCentralDirectoryExtra = function() {
- return this.getExtra();
-};
-
-ZipArchiveEntry.prototype.getComment = function() {
- return this.comment !== null ? this.comment : '';
-};
-
-ZipArchiveEntry.prototype.getCompressedSize = function() {
- return this.csize;
-};
-
-ZipArchiveEntry.prototype.getCrc = function() {
- return this.crc;
-};
-
-ZipArchiveEntry.prototype.getExternalAttributes = function() {
- return this.exattr;
-};
-
-ZipArchiveEntry.prototype.getExtra = function() {
- return this.extra !== null ? this.extra : constants.EMPTY;
-};
-
-ZipArchiveEntry.prototype.getGeneralPurposeBit = function() {
- return this.gpb;
-};
-
-ZipArchiveEntry.prototype.getInternalAttributes = function() {
- return this.inattr;
-};
-
-ZipArchiveEntry.prototype.getLastModifiedDate = function() {
- return this.getTime();
-};
-
-ZipArchiveEntry.prototype.getLocalFileDataExtra = function() {
- return this.getExtra();
-};
-
-ZipArchiveEntry.prototype.getMethod = function() {
- return this.method;
-};
-
-ZipArchiveEntry.prototype.getName = function() {
- return this.name;
-};
-
-ZipArchiveEntry.prototype.getPlatform = function() {
- return this.platform;
-};
-
-ZipArchiveEntry.prototype.getSize = function() {
- return this.size;
-};
-
-ZipArchiveEntry.prototype.getTime = function() {
- return this.time !== -1 ? zipUtil.dosToDate(this.time) : -1;
-};
-
-ZipArchiveEntry.prototype.getTimeDos = function() {
- return this.time !== -1 ? this.time : 0;
-};
-
-ZipArchiveEntry.prototype.getUnixMode = function() {
- return this.platform !== constants.PLATFORM_UNIX ? 0 : ((this.getExternalAttributes() >> constants.SHORT_SHIFT) & constants.SHORT_MASK) & constants.MODE_MASK;
-};
-
-ZipArchiveEntry.prototype.getVersionNeededToExtract = function() {
- return this.minver;
-};
-
-ZipArchiveEntry.prototype.setComment = function(comment) {
- if (Buffer.byteLength(comment) !== comment.length) {
- this.getGeneralPurposeBit().useUTF8ForNames(true);
- }
-
- this.comment = comment;
-};
-
-ZipArchiveEntry.prototype.setCompressedSize = function(size) {
- if (size < 0) {
- throw new Error('invalid entry compressed size');
- }
-
- this.csize = size;
-};
-
-ZipArchiveEntry.prototype.setCrc = function(crc) {
- if (crc < 0) {
- throw new Error('invalid entry crc32');
- }
-
- this.crc = crc;
-};
-
-ZipArchiveEntry.prototype.setExternalAttributes = function(attr) {
- this.exattr = attr >>> 0;
-};
-
-ZipArchiveEntry.prototype.setExtra = function(extra) {
- this.extra = extra;
-};
-
-ZipArchiveEntry.prototype.setGeneralPurposeBit = function(gpb) {
- if (!(gpb instanceof GeneralPurposeBit)) {
- throw new Error('invalid entry GeneralPurposeBit');
- }
-
- this.gpb = gpb;
-};
-
-ZipArchiveEntry.prototype.setInternalAttributes = function(attr) {
- this.inattr = attr;
-};
-
-ZipArchiveEntry.prototype.setMethod = function(method) {
- if (method < 0) {
- throw new Error('invalid entry compression method');
- }
-
- this.method = method;
-};
-
-ZipArchiveEntry.prototype.setName = function(name) {
- name = name.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
-
- if (Buffer.byteLength(name) !== name.length) {
- this.getGeneralPurposeBit().useUTF8ForNames(true);
- }
-
- this.name = name;
-};
-
-ZipArchiveEntry.prototype.setPlatform = function(platform) {
- this.platform = platform;
-};
-
-ZipArchiveEntry.prototype.setSize = function(size) {
- if (size < 0) {
- throw new Error('invalid entry size');
- }
-
- this.size = size;
-};
-
-ZipArchiveEntry.prototype.setTime = function(time) {
- if (!(time instanceof Date)) {
- throw new Error('invalid entry time');
- }
-
- this.time = zipUtil.dateToDos(time);
-};
-
-ZipArchiveEntry.prototype.setUnixMode = function(mode) {
- mode &= ~constants.S_IFDIR;
- var extattr = 0;
-
- if (!this.isDirectory()) {
- mode |= constants.S_IFREG;
- }
-
- extattr &= ~this.getExternalAttributes();
- extattr |= (mode << constants.SHORT_SHIFT) | (this.isDirectory() ? constants.S_DOS_D : constants.S_DOS_A);
-
- this.setExternalAttributes(extattr);
- this.mode = mode & constants.MODE_MASK;
- this.platform = constants.PLATFORM_UNIX;
-};
-
-ZipArchiveEntry.prototype.setVersionNeededToExtract = function(minver) {
- this.minver = minver;
-};
-
-ZipArchiveEntry.prototype.isDirectory = function() {
- return this.getName().slice(-1) === '/';
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+
+var ArchiveEntry = require('../archive-entry');
+var GeneralPurposeBit = require('./general-purpose-bit');
+
+var constants = require('./constants');
+var zipUtil = require('./util');
+
+var ZipArchiveEntry = module.exports = function(name) {
+ if (!(this instanceof ZipArchiveEntry)) {
+ return new ZipArchiveEntry(name);
+ }
+
+ ArchiveEntry.call(this);
+
+ this.platform = constants.PLATFORM_FAT;
+ this.method = -1;
+
+ this.name = null;
+ this.size = -1;
+ this.csize = -1;
+ this.gpb = new GeneralPurposeBit();
+ this.crc = 0;
+ this.time = -1;
+
+ this.minver = constants.INITIAL_VERSION;
+ this.mode = -1;
+ this.extra = null;
+ this.exattr = 0;
+ this.inattr = 0;
+ this.comment = null;
+
+ if (name) {
+ this.setName(name);
+ }
+};
+
+inherits(ZipArchiveEntry, ArchiveEntry);
+
+ZipArchiveEntry.prototype.getCentralDirectoryExtra = function() {
+ return this.getExtra();
+};
+
+ZipArchiveEntry.prototype.getComment = function() {
+ return this.comment !== null ? this.comment : '';
+};
+
+ZipArchiveEntry.prototype.getCompressedSize = function() {
+ return this.csize;
+};
+
+ZipArchiveEntry.prototype.getCrc = function() {
+ return this.crc;
+};
+
+ZipArchiveEntry.prototype.getExternalAttributes = function() {
+ return this.exattr;
+};
+
+ZipArchiveEntry.prototype.getExtra = function() {
+ return this.extra !== null ? this.extra : constants.EMPTY;
+};
+
+ZipArchiveEntry.prototype.getGeneralPurposeBit = function() {
+ return this.gpb;
+};
+
+ZipArchiveEntry.prototype.getInternalAttributes = function() {
+ return this.inattr;
+};
+
+ZipArchiveEntry.prototype.getLastModifiedDate = function() {
+ return this.getTime();
+};
+
+ZipArchiveEntry.prototype.getLocalFileDataExtra = function() {
+ return this.getExtra();
+};
+
+ZipArchiveEntry.prototype.getMethod = function() {
+ return this.method;
+};
+
+ZipArchiveEntry.prototype.getName = function() {
+ return this.name;
+};
+
+ZipArchiveEntry.prototype.getPlatform = function() {
+ return this.platform;
+};
+
+ZipArchiveEntry.prototype.getSize = function() {
+ return this.size;
+};
+
+ZipArchiveEntry.prototype.getTime = function() {
+ return this.time !== -1 ? zipUtil.dosToDate(this.time) : -1;
+};
+
+ZipArchiveEntry.prototype.getTimeDos = function() {
+ return this.time !== -1 ? this.time : 0;
+};
+
+ZipArchiveEntry.prototype.getUnixMode = function() {
+ return this.platform !== constants.PLATFORM_UNIX ? 0 : ((this.getExternalAttributes() >> constants.SHORT_SHIFT) & constants.SHORT_MASK) & constants.MODE_MASK;
+};
+
+ZipArchiveEntry.prototype.getVersionNeededToExtract = function() {
+ return this.minver;
+};
+
+ZipArchiveEntry.prototype.setComment = function(comment) {
+ if (Buffer.byteLength(comment) !== comment.length) {
+ this.getGeneralPurposeBit().useUTF8ForNames(true);
+ }
+
+ this.comment = comment;
+};
+
+ZipArchiveEntry.prototype.setCompressedSize = function(size) {
+ if (size < 0) {
+ throw new Error('invalid entry compressed size');
+ }
+
+ this.csize = size;
+};
+
+ZipArchiveEntry.prototype.setCrc = function(crc) {
+ if (crc < 0) {
+ throw new Error('invalid entry crc32');
+ }
+
+ this.crc = crc;
+};
+
+ZipArchiveEntry.prototype.setExternalAttributes = function(attr) {
+ this.exattr = attr >>> 0;
+};
+
+ZipArchiveEntry.prototype.setExtra = function(extra) {
+ this.extra = extra;
+};
+
+ZipArchiveEntry.prototype.setGeneralPurposeBit = function(gpb) {
+ if (!(gpb instanceof GeneralPurposeBit)) {
+ throw new Error('invalid entry GeneralPurposeBit');
+ }
+
+ this.gpb = gpb;
+};
+
+ZipArchiveEntry.prototype.setInternalAttributes = function(attr) {
+ this.inattr = attr;
+};
+
+ZipArchiveEntry.prototype.setMethod = function(method) {
+ if (method < 0) {
+ throw new Error('invalid entry compression method');
+ }
+
+ this.method = method;
+};
+
+ZipArchiveEntry.prototype.setName = function(name) {
+ name = name.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
+
+ if (Buffer.byteLength(name) !== name.length) {
+ this.getGeneralPurposeBit().useUTF8ForNames(true);
+ }
+
+ this.name = name;
+};
+
+ZipArchiveEntry.prototype.setPlatform = function(platform) {
+ this.platform = platform;
+};
+
+ZipArchiveEntry.prototype.setSize = function(size) {
+ if (size < 0) {
+ throw new Error('invalid entry size');
+ }
+
+ this.size = size;
+};
+
+ZipArchiveEntry.prototype.setTime = function(time) {
+ if (!(time instanceof Date)) {
+ throw new Error('invalid entry time');
+ }
+
+ this.time = zipUtil.dateToDos(time);
+};
+
+ZipArchiveEntry.prototype.setUnixMode = function(mode) {
+ mode &= ~constants.S_IFDIR;
+ var extattr = 0;
+
+ if (!this.isDirectory()) {
+ mode |= constants.S_IFREG;
+ }
+
+ extattr &= ~this.getExternalAttributes();
+ extattr |= (mode << constants.SHORT_SHIFT) | (this.isDirectory() ? constants.S_DOS_D : constants.S_DOS_A);
+
+ this.setExternalAttributes(extattr);
+ this.mode = mode & constants.MODE_MASK;
+ this.platform = constants.PLATFORM_UNIX;
+};
+
+ZipArchiveEntry.prototype.setVersionNeededToExtract = function(minver) {
+ this.minver = minver;
+};
+
+ZipArchiveEntry.prototype.isDirectory = function() {
+ return this.getName().slice(-1) === '/';
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js
index a1c5e03..024bfd9 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js
@@ -1,337 +1,337 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-var crc32 = require('buffer-crc32');
-var CRC32Stream = require('crc32-stream');
-var DeflateCRC32Stream = CRC32Stream.DeflateCRC32Stream;
-
-var ArchiveOutputStream = require('../archive-output-stream');
-var ZipArchiveEntry = require('./zip-archive-entry');
-var GeneralPurposeBit = require('./general-purpose-bit');
-
-var constants = require('./constants');
-var util = require('../../util');
-var zipUtil = require('./util');
-
-var ZipArchiveOutputStream = module.exports = function(options) {
- if (!(this instanceof ZipArchiveOutputStream)) {
- return new ZipArchiveOutputStream(options);
- }
-
- options = this.options = options || {};
- options.zlib = this._zlibDefaults(options.zlib);
-
- ArchiveOutputStream.call(this, options);
-
- this._entry = null;
- this._entries = [];
- this._archive = {
- centralLength: 0,
- centralOffset: 0,
- comment: '',
- finish: false,
- finished: false,
- processing: false
- };
-};
-
-inherits(ZipArchiveOutputStream, ArchiveOutputStream);
-
-ZipArchiveOutputStream.prototype._afterAppend = function(zae) {
- this._entries.push(zae);
- this._writeDataDescriptor(zae);
-
- this._archive.processing = false;
- this._entry = null;
-
- if (this._archive.finish && !this._archive.finished) {
- this._finish();
- }
-};
-
-ZipArchiveOutputStream.prototype._appendBuffer = function(ae, source, callback) {
- if (source.length === 0) {
- ae.setMethod(constants.METHOD_STORED);
- }
-
- var method = ae.getMethod();
-
- if (method === constants.METHOD_STORED) {
- ae.setSize(source.length);
- ae.setCompressedSize(source.length);
- ae.setCrc(crc32.unsigned(source));
- }
-
- this._writeLocalFileHeader(ae);
-
- if (method === constants.METHOD_STORED) {
- this.write(source);
- this._afterAppend(ae);
- callback(null, ae);
- return;
- } else if (method === constants.METHOD_DEFLATED) {
- this._smartStream(ae, callback).end(source);
- return;
- } else {
- callback(new Error('compression method ' + method + ' not implemented'));
- return;
- }
-};
-
-ZipArchiveOutputStream.prototype._appendStream = function(ae, source, callback) {
- ae.getGeneralPurposeBit().useDataDescriptor(true);
-
- this._writeLocalFileHeader(ae);
-
- var smart = this._smartStream(ae, callback);
- source.pipe(smart);
-};
-
-ZipArchiveOutputStream.prototype._finish = function() {
- this._archive.centralOffset = this.offset;
-
- this._entries.forEach(function(ae) {
- this._writeCentralFileHeader(ae);
- }.bind(this));
-
- this._archive.centralLength = this.offset - this._archive.centralOffset;
-
- this._writeCentralDirectoryEnd();
-
- this._archive.processing = false;
- this._archive.finish = true;
- this._archive.finished = true;
- this.end();
-};
-
-ZipArchiveOutputStream.prototype._setDefaults = function(ae) {
- if (ae.getMethod() === -1) {
- ae.setMethod(constants.METHOD_DEFLATED);
- }
-
- if (ae.getMethod() === constants.METHOD_DEFLATED) {
- ae.getGeneralPurposeBit().useDataDescriptor(true);
- ae.setVersionNeededToExtract(constants.DATA_DESCRIPTOR_MIN_VERSION);
- }
-
- if (ae.getTime() === -1) {
- ae.setTime(new Date());
- }
-
- ae._offsets = {
- file: 0,
- data: 0,
- contents: 0,
- };
-};
-
-ZipArchiveOutputStream.prototype._smartStream = function(ae, callback) {
- var deflate = ae.getMethod() === constants.METHOD_DEFLATED;
- var process = deflate ? new DeflateCRC32Stream(this.options.zlib) : new CRC32Stream();
-
- function handleStuff(err) {
- ae.setCrc(process.digest());
- ae.setSize(process.size());
- ae.setCompressedSize(process.size(true));
- this._afterAppend(ae);
- callback(null, ae);
- }
-
- process.once('error', callback);
- process.once('end', handleStuff.bind(this));
-
- process.pipe(this, { end: false });
-
- return process;
-};
-
-ZipArchiveOutputStream.prototype._writeCentralDirectoryEnd = function() {
- // signature
- this.write(zipUtil.getLongBytes(constants.SIG_EOCD));
-
- // disk numbers
- this.write(constants.SHORT_ZERO);
- this.write(constants.SHORT_ZERO);
-
- // number of entries
- this.write(zipUtil.getShortBytes(this._entries.length));
- this.write(zipUtil.getShortBytes(this._entries.length));
-
- // length and location of CD
- this.write(zipUtil.getLongBytes(this._archive.centralLength));
- this.write(zipUtil.getLongBytes(this._archive.centralOffset));
-
- // archive comment
- var comment = this.getComment();
- var commentLength = Buffer.byteLength(comment);
- this.write(zipUtil.getShortBytes(commentLength));
- this.write(comment);
-};
-
-ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(ae) {
- var gpb = ae.getGeneralPurposeBit();
- var method = ae.getMethod();
- var offsets = ae._offsets;
-
- // signature
- this.write(zipUtil.getLongBytes(constants.SIG_CFH));
-
- // version made by
- this.write(zipUtil.getShortBytes(
- (ae.getPlatform() << 8) | constants.DATA_DESCRIPTOR_MIN_VERSION
- ));
-
- // version to extract and general bit flag
- this._writeVersionGeneral(ae);
-
- // compression method
- this.write(zipUtil.getShortBytes(method));
-
- // datetime
- this.write(zipUtil.getLongBytes(ae.getTimeDos()));
-
- // crc32 checksum
- this.write(zipUtil.getLongBytes(ae.getCrc()));
-
- // sizes
- this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
- this.write(zipUtil.getLongBytes(ae.getSize()));
-
- var name = ae.getName();
- var comment = ae.getComment();
- var extra = ae.getCentralDirectoryExtra();
-
- if (gpb.usesUTF8ForNames()) {
- name = new Buffer(name);
- comment = new Buffer(comment);
- }
-
- // name length
- this.write(zipUtil.getShortBytes(name.length));
-
- // extra length
- this.write(zipUtil.getShortBytes(extra.length));
-
- // comments length
- this.write(zipUtil.getShortBytes(comment.length));
-
- // disk number start
- this.write(constants.SHORT_ZERO);
-
- // internal attributes
- this.write(zipUtil.getShortBytes(ae.getInternalAttributes()));
-
- // external attributes
- this.write(zipUtil.getLongBytes(ae.getExternalAttributes()));
-
- // relative offset of LFH
- this.write(zipUtil.getLongBytes(offsets.file));
-
- // name
- this.write(name);
-
- // extra
- this.write(extra);
-
- // comment
- this.write(comment);
-};
-
-ZipArchiveOutputStream.prototype._writeDataDescriptor = function(ae) {
- if (!ae.getGeneralPurposeBit().usesDataDescriptor()) {
- return;
- }
-
- // signature
- this.write(zipUtil.getLongBytes(constants.SIG_DD));
-
- // crc32 checksum
- this.write(zipUtil.getLongBytes(ae.getCrc()));
-
- // sizes
- this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
- this.write(zipUtil.getLongBytes(ae.getSize()));
-};
-
-ZipArchiveOutputStream.prototype._writeLocalFileHeader = function(ae) {
- var gpb = ae.getGeneralPurposeBit();
- var method = ae.getMethod();
- var name = ae.getName();
- var extra = ae.getLocalFileDataExtra();
-
- if (gpb.usesUTF8ForNames()) {
- name = new Buffer(name);
- }
-
- ae._offsets.file = this.offset;
-
- // signature
- this.write(zipUtil.getLongBytes(constants.SIG_LFH));
-
- // version to extract and general bit flag
- this._writeVersionGeneral(ae);
-
- // compression method
- this.write(zipUtil.getShortBytes(method));
-
- // datetime
- this.write(zipUtil.getLongBytes(ae.getTimeDos()));
-
- ae._offsets.data = this.offset;
-
- if (ae.getGeneralPurposeBit().usesDataDescriptor()) {
- // zero fill and set later
- this.write(constants.LONG_ZERO);
- this.write(constants.LONG_ZERO);
- this.write(constants.LONG_ZERO);
- } else {
- // crc32 checksum and sizes
- this.write(zipUtil.getLongBytes(ae.getCrc()));
- this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
- this.write(zipUtil.getLongBytes(ae.getSize()));
- }
-
- // name length
- this.write(zipUtil.getShortBytes(name.length));
-
- // extra length
- this.write(zipUtil.getShortBytes(extra.length));
-
- // name
- this.write(name);
-
- // extra
- this.write(extra);
-
- ae._offsets.contents = this.offset;
-};
-
-ZipArchiveOutputStream.prototype._writeVersionGeneral = function(ae) {
- this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract()));
- this.write(ae.getGeneralPurposeBit().encode());
-};
-
-ZipArchiveOutputStream.prototype._zlibDefaults = function(o) {
- if (typeof o !== 'object') {
- o = {};
- }
-
- if (typeof o.level !== 'number') {
- o.level = constants.ZLIB_BEST_SPEED;
- }
-
- return o;
-};
-
-ZipArchiveOutputStream.prototype.getComment = function(comment) {
- return this._archive.comment !== null ? this._archive.comment : '';
-};
-
-ZipArchiveOutputStream.prototype.setComment = function(comment) {
- this._archive.comment = comment;
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+var crc32 = require('buffer-crc32');
+var CRC32Stream = require('crc32-stream');
+var DeflateCRC32Stream = CRC32Stream.DeflateCRC32Stream;
+
+var ArchiveOutputStream = require('../archive-output-stream');
+var ZipArchiveEntry = require('./zip-archive-entry');
+var GeneralPurposeBit = require('./general-purpose-bit');
+
+var constants = require('./constants');
+var util = require('../../util');
+var zipUtil = require('./util');
+
+var ZipArchiveOutputStream = module.exports = function(options) {
+ if (!(this instanceof ZipArchiveOutputStream)) {
+ return new ZipArchiveOutputStream(options);
+ }
+
+ options = this.options = options || {};
+ options.zlib = this._zlibDefaults(options.zlib);
+
+ ArchiveOutputStream.call(this, options);
+
+ this._entry = null;
+ this._entries = [];
+ this._archive = {
+ centralLength: 0,
+ centralOffset: 0,
+ comment: '',
+ finish: false,
+ finished: false,
+ processing: false
+ };
+};
+
+inherits(ZipArchiveOutputStream, ArchiveOutputStream);
+
+ZipArchiveOutputStream.prototype._afterAppend = function(zae) {
+ this._entries.push(zae);
+ this._writeDataDescriptor(zae);
+
+ this._archive.processing = false;
+ this._entry = null;
+
+ if (this._archive.finish && !this._archive.finished) {
+ this._finish();
+ }
+};
+
+ZipArchiveOutputStream.prototype._appendBuffer = function(ae, source, callback) {
+ if (source.length === 0) {
+ ae.setMethod(constants.METHOD_STORED);
+ }
+
+ var method = ae.getMethod();
+
+ if (method === constants.METHOD_STORED) {
+ ae.setSize(source.length);
+ ae.setCompressedSize(source.length);
+ ae.setCrc(crc32.unsigned(source));
+ }
+
+ this._writeLocalFileHeader(ae);
+
+ if (method === constants.METHOD_STORED) {
+ this.write(source);
+ this._afterAppend(ae);
+ callback(null, ae);
+ return;
+ } else if (method === constants.METHOD_DEFLATED) {
+ this._smartStream(ae, callback).end(source);
+ return;
+ } else {
+ callback(new Error('compression method ' + method + ' not implemented'));
+ return;
+ }
+};
+
+ZipArchiveOutputStream.prototype._appendStream = function(ae, source, callback) {
+ ae.getGeneralPurposeBit().useDataDescriptor(true);
+
+ this._writeLocalFileHeader(ae);
+
+ var smart = this._smartStream(ae, callback);
+ source.pipe(smart);
+};
+
+ZipArchiveOutputStream.prototype._finish = function() {
+ this._archive.centralOffset = this.offset;
+
+ this._entries.forEach(function(ae) {
+ this._writeCentralFileHeader(ae);
+ }.bind(this));
+
+ this._archive.centralLength = this.offset - this._archive.centralOffset;
+
+ this._writeCentralDirectoryEnd();
+
+ this._archive.processing = false;
+ this._archive.finish = true;
+ this._archive.finished = true;
+ this.end();
+};
+
+ZipArchiveOutputStream.prototype._setDefaults = function(ae) {
+ if (ae.getMethod() === -1) {
+ ae.setMethod(constants.METHOD_DEFLATED);
+ }
+
+ if (ae.getMethod() === constants.METHOD_DEFLATED) {
+ ae.getGeneralPurposeBit().useDataDescriptor(true);
+ ae.setVersionNeededToExtract(constants.DATA_DESCRIPTOR_MIN_VERSION);
+ }
+
+ if (ae.getTime() === -1) {
+ ae.setTime(new Date());
+ }
+
+ ae._offsets = {
+ file: 0,
+ data: 0,
+ contents: 0,
+ };
+};
+
+ZipArchiveOutputStream.prototype._smartStream = function(ae, callback) {
+ var deflate = ae.getMethod() === constants.METHOD_DEFLATED;
+ var process = deflate ? new DeflateCRC32Stream(this.options.zlib) : new CRC32Stream();
+
+ function handleStuff(err) {
+ ae.setCrc(process.digest());
+ ae.setSize(process.size());
+ ae.setCompressedSize(process.size(true));
+ this._afterAppend(ae);
+ callback(null, ae);
+ }
+
+ process.once('error', callback);
+ process.once('end', handleStuff.bind(this));
+
+ process.pipe(this, { end: false });
+
+ return process;
+};
+
+ZipArchiveOutputStream.prototype._writeCentralDirectoryEnd = function() {
+ // signature
+ this.write(zipUtil.getLongBytes(constants.SIG_EOCD));
+
+ // disk numbers
+ this.write(constants.SHORT_ZERO);
+ this.write(constants.SHORT_ZERO);
+
+ // number of entries
+ this.write(zipUtil.getShortBytes(this._entries.length));
+ this.write(zipUtil.getShortBytes(this._entries.length));
+
+ // length and location of CD
+ this.write(zipUtil.getLongBytes(this._archive.centralLength));
+ this.write(zipUtil.getLongBytes(this._archive.centralOffset));
+
+ // archive comment
+ var comment = this.getComment();
+ var commentLength = Buffer.byteLength(comment);
+ this.write(zipUtil.getShortBytes(commentLength));
+ this.write(comment);
+};
+
+ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(ae) {
+ var gpb = ae.getGeneralPurposeBit();
+ var method = ae.getMethod();
+ var offsets = ae._offsets;
+
+ // signature
+ this.write(zipUtil.getLongBytes(constants.SIG_CFH));
+
+ // version made by
+ this.write(zipUtil.getShortBytes(
+ (ae.getPlatform() << 8) | constants.DATA_DESCRIPTOR_MIN_VERSION
+ ));
+
+ // version to extract and general bit flag
+ this._writeVersionGeneral(ae);
+
+ // compression method
+ this.write(zipUtil.getShortBytes(method));
+
+ // datetime
+ this.write(zipUtil.getLongBytes(ae.getTimeDos()));
+
+ // crc32 checksum
+ this.write(zipUtil.getLongBytes(ae.getCrc()));
+
+ // sizes
+ this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
+ this.write(zipUtil.getLongBytes(ae.getSize()));
+
+ var name = ae.getName();
+ var comment = ae.getComment();
+ var extra = ae.getCentralDirectoryExtra();
+
+ if (gpb.usesUTF8ForNames()) {
+ name = new Buffer(name);
+ comment = new Buffer(comment);
+ }
+
+ // name length
+ this.write(zipUtil.getShortBytes(name.length));
+
+ // extra length
+ this.write(zipUtil.getShortBytes(extra.length));
+
+ // comments length
+ this.write(zipUtil.getShortBytes(comment.length));
+
+ // disk number start
+ this.write(constants.SHORT_ZERO);
+
+ // internal attributes
+ this.write(zipUtil.getShortBytes(ae.getInternalAttributes()));
+
+ // external attributes
+ this.write(zipUtil.getLongBytes(ae.getExternalAttributes()));
+
+ // relative offset of LFH
+ this.write(zipUtil.getLongBytes(offsets.file));
+
+ // name
+ this.write(name);
+
+ // extra
+ this.write(extra);
+
+ // comment
+ this.write(comment);
+};
+
+ZipArchiveOutputStream.prototype._writeDataDescriptor = function(ae) {
+ if (!ae.getGeneralPurposeBit().usesDataDescriptor()) {
+ return;
+ }
+
+ // signature
+ this.write(zipUtil.getLongBytes(constants.SIG_DD));
+
+ // crc32 checksum
+ this.write(zipUtil.getLongBytes(ae.getCrc()));
+
+ // sizes
+ this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
+ this.write(zipUtil.getLongBytes(ae.getSize()));
+};
+
+ZipArchiveOutputStream.prototype._writeLocalFileHeader = function(ae) {
+ var gpb = ae.getGeneralPurposeBit();
+ var method = ae.getMethod();
+ var name = ae.getName();
+ var extra = ae.getLocalFileDataExtra();
+
+ if (gpb.usesUTF8ForNames()) {
+ name = new Buffer(name);
+ }
+
+ ae._offsets.file = this.offset;
+
+ // signature
+ this.write(zipUtil.getLongBytes(constants.SIG_LFH));
+
+ // version to extract and general bit flag
+ this._writeVersionGeneral(ae);
+
+ // compression method
+ this.write(zipUtil.getShortBytes(method));
+
+ // datetime
+ this.write(zipUtil.getLongBytes(ae.getTimeDos()));
+
+ ae._offsets.data = this.offset;
+
+ if (ae.getGeneralPurposeBit().usesDataDescriptor()) {
+ // zero fill and set later
+ this.write(constants.LONG_ZERO);
+ this.write(constants.LONG_ZERO);
+ this.write(constants.LONG_ZERO);
+ } else {
+ // crc32 checksum and sizes
+ this.write(zipUtil.getLongBytes(ae.getCrc()));
+ this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
+ this.write(zipUtil.getLongBytes(ae.getSize()));
+ }
+
+ // name length
+ this.write(zipUtil.getShortBytes(name.length));
+
+ // extra length
+ this.write(zipUtil.getShortBytes(extra.length));
+
+ // name
+ this.write(name);
+
+ // extra
+ this.write(extra);
+
+ ae._offsets.contents = this.offset;
+};
+
+ZipArchiveOutputStream.prototype._writeVersionGeneral = function(ae) {
+ this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract()));
+ this.write(ae.getGeneralPurposeBit().encode());
+};
+
+ZipArchiveOutputStream.prototype._zlibDefaults = function(o) {
+ if (typeof o !== 'object') {
+ o = {};
+ }
+
+ if (typeof o.level !== 'number') {
+ o.level = constants.ZLIB_BEST_SPEED;
+ }
+
+ return o;
+};
+
+ZipArchiveOutputStream.prototype.getComment = function(comment) {
+ return this._archive.comment !== null ? this._archive.comment : '';
+};
+
+ZipArchiveOutputStream.prototype.setComment = function(comment) {
+ this._archive.comment = comment;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/compress-commons.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/compress-commons.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/compress-commons.js
index fe3a581..0113bbb 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/compress-commons.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/compress-commons.js
@@ -1,13 +1,13 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-module.exports = {
- ArchiveEntry: require('./archivers/archive-entry'),
- ZipArchiveEntry: require('./archivers/zip/zip-archive-entry'),
- ArchiveOutputStream: require('./archivers/archive-output-stream'),
- ZipArchiveOutputStream: require('./archivers/zip/zip-archive-output-stream')
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+module.exports = {
+ ArchiveEntry: require('./archivers/archive-entry'),
+ ZipArchiveEntry: require('./archivers/zip/zip-archive-entry'),
+ ArchiveOutputStream: require('./archivers/archive-output-stream'),
+ ZipArchiveOutputStream: require('./archivers/zip/zip-archive-output-stream')
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/util/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/util/index.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/util/index.js
index 6e89f0e..fab87a0 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/util/index.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/util/index.js
@@ -1,30 +1,30 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var Stream = require('stream').Stream;
-var PassThrough = require('readable-stream').PassThrough;
-
-var util = module.exports = {};
-
-util.isStream = function(source) {
- return source instanceof Stream;
-};
-
-util.normalizeInputSource = function(source) {
- if (source === null) {
- return new Buffer(0);
- } else if (typeof source === 'string') {
- return new Buffer(source);
- } else if (util.isStream(source) && !source._readableState) {
- var normalized = new PassThrough();
- source.pipe(normalized);
-
- return normalized;
- }
-
- return source;
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var Stream = require('stream').Stream;
+var PassThrough = require('readable-stream').PassThrough;
+
+var util = module.exports = {};
+
+util.isStream = function(source) {
+ return source instanceof Stream;
+};
+
+util.normalizeInputSource = function(source) {
+ if (source === null) {
+ return new Buffer(0);
+ } else if (typeof source === 'string') {
+ return new Buffer(source);
+ } else if (util.isStream(source) && !source._readableState) {
+ var normalized = new PassThrough();
+ source.pipe(normalized);
+
+ return normalized;
+ }
+
+ return source;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/CHANGELOG
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/CHANGELOG b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/CHANGELOG
index 983c20b..b87f161 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/CHANGELOG
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/CHANGELOG
@@ -1,18 +1,18 @@
-v0.2.0:
- date: 2014-05-03
- changes:
- - add size method to return raw size of data passed-through.
-v0.1.2:
- date: 2014-04-18
- changes:
- - always use readable-stream for consistency.
- - use crc32.unsigned to get digest.
-v0.1.1:
- date: 2014-03-30
- changes:
- - gracefully handle "no data" scenario.
- - trim down deps.
-v0.1.0:
- date: 2014-03-30
- changes:
+v0.2.0:
+ date: 2014-05-03
+ changes:
+ - add size method to return raw size of data passed-through.
+v0.1.2:
+ date: 2014-04-18
+ changes:
+ - always use readable-stream for consistency.
+ - use crc32.unsigned to get digest.
+v0.1.1:
+ date: 2014-03-30
+ changes:
+ - gracefully handle "no data" scenario.
+ - trim down deps.
+v0.1.0:
+ date: 2014-03-30
+ changes:
- initial release.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/LICENSE-MIT
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/LICENSE-MIT b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/LICENSE-MIT
index 819b403..56420a6 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/LICENSE-MIT
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/LICENSE-MIT
@@ -1,22 +1,22 @@
-Copyright (c) 2014 Chris Talkington, contributors.
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+Copyright (c) 2014 Chris Talkington, contributors.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/README.md b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/README.md
index 040224f..4e697da 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/README.md
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/README.md
@@ -1,81 +1,81 @@
-# crc32-stream v0.3.2 [](https://travis-ci.org/archiverjs/node-crc32-stream)
-
-crc32-stream is a streaming CRC32 checksumer. It uses [buffer-crc32](https://www.npmjs.org/package/buffer-crc32) behind the scenes to reliably handle binary data and fancy character sets. Data is passed through untouched.
-
-[](https://nodei.co/npm/crc32-stream/)
-
-### Install
-
-```bash
-npm install crc32-stream --save
-```
-
-You can also use `npm install https://github.com/archiverjs/node-crc32-stream/archive/master.tar.gz` to test upcoming versions.
-
-### Usage
-
-#### CRC32Stream
-
-Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) options and methods.
-
-```js
-var CRC32Stream = require('crc32-stream');
-
-var source = fs.createReadStream('file.txt');
-var checksum = new CRC32Stream();
-
-checksum.on('end', function(err) {
- // do something with checksum.digest() here
-});
-
-// either pipe it
-source.pipe(checksum);
-
-// or write it
-checksum.write('string');
-checksum.end();
-```
-
-#### DeflateCRC32Stream
-
-Inherits [zlib.DeflateRaw](http://nodejs.org/api/zlib.html#zlib_class_zlib_deflateraw) options and methods.
-
-```js
-var DeflateCRC32Stream = require('crc32-stream').DeflateCRC32Stream;
-
-var source = fs.createReadStream('file.txt');
-var checksum = new DeflateCRC32Stream();
-
-checksum.on('end', function(err) {
- // do something with checksum.digest() here
-});
-
-// either pipe it
-source.pipe(checksum);
-
-// or write it
-checksum.write('string');
-checksum.end();
-```
-
-### Instance API
-
-#### digest()
-
-Returns the checksum digest in unsigned form.
-
-#### hex()
-
-Returns the hexadecimal representation of the checksum digest. (ie E81722F0)
-
-#### size(compressed)
-
-Returns the raw size/length of passed-through data.
-
-If `compressed` is `true`, it returns compressed length instead. (DeflateCRC32Stream)
-
-## Things of Interest
-
-- [Changelog](https://github.com/archiverjs/node-crc32-stream/releases)
-- [Contributing](https://github.com/archiverjs/node-crc32-stream/blob/master/CONTRIBUTING.md)
+# crc32-stream v0.3.2 [](https://travis-ci.org/archiverjs/node-crc32-stream)
+
+crc32-stream is a streaming CRC32 checksumer. It uses [buffer-crc32](https://www.npmjs.org/package/buffer-crc32) behind the scenes to reliably handle binary data and fancy character sets. Data is passed through untouched.
+
+[](https://nodei.co/npm/crc32-stream/)
+
+### Install
+
+```bash
+npm install crc32-stream --save
+```
+
+You can also use `npm install https://github.com/archiverjs/node-crc32-stream/archive/master.tar.gz` to test upcoming versions.
+
+### Usage
+
+#### CRC32Stream
+
+Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) options and methods.
+
+```js
+var CRC32Stream = require('crc32-stream');
+
+var source = fs.createReadStream('file.txt');
+var checksum = new CRC32Stream();
+
+checksum.on('end', function(err) {
+ // do something with checksum.digest() here
+});
+
+// either pipe it
+source.pipe(checksum);
+
+// or write it
+checksum.write('string');
+checksum.end();
+```
+
+#### DeflateCRC32Stream
+
+Inherits [zlib.DeflateRaw](http://nodejs.org/api/zlib.html#zlib_class_zlib_deflateraw) options and methods.
+
+```js
+var DeflateCRC32Stream = require('crc32-stream').DeflateCRC32Stream;
+
+var source = fs.createReadStream('file.txt');
+var checksum = new DeflateCRC32Stream();
+
+checksum.on('end', function(err) {
+ // do something with checksum.digest() here
+});
+
+// either pipe it
+source.pipe(checksum);
+
+// or write it
+checksum.write('string');
+checksum.end();
+```
+
+### Instance API
+
+#### digest()
+
+Returns the checksum digest in unsigned form.
+
+#### hex()
+
+Returns the hexadecimal representation of the checksum digest. (ie E81722F0)
+
+#### size(compressed)
+
+Returns the raw size/length of passed-through data.
+
+If `compressed` is `true`, it returns compressed length instead. (DeflateCRC32Stream)
+
+## Things of Interest
+
+- [Changelog](https://github.com/archiverjs/node-crc32-stream/releases)
+- [Contributing](https://github.com/archiverjs/node-crc32-stream/blob/master/CONTRIBUTING.md)
- [MIT License](https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/crc32-stream.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/crc32-stream.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/crc32-stream.js
index 42cb454..3cec9cc 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/crc32-stream.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/crc32-stream.js
@@ -1,42 +1,42 @@
-/**
- * node-crc32-stream
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-var Transform = require('readable-stream').Transform;
-
-var crc32 = require('buffer-crc32');
-
-var CRC32Stream = module.exports = function CRC32Stream(options) {
- Transform.call(this, options);
- this.checksum = new Buffer(4);
- this.checksum.writeInt32BE(0, 0);
-
- this.rawSize = 0;
-};
-
-inherits(CRC32Stream, Transform);
-
-CRC32Stream.prototype._transform = function(chunk, encoding, callback) {
- if (chunk) {
- this.checksum = crc32(chunk, this.checksum);
- this.rawSize += chunk.length;
- }
-
- callback(null, chunk);
-};
-
-CRC32Stream.prototype.digest = function() {
- return crc32.unsigned(0, this.checksum);
-};
-
-CRC32Stream.prototype.hex = function() {
- return this.digest().toString(16).toUpperCase();
-};
-
-CRC32Stream.prototype.size = function() {
- return this.rawSize;
+/**
+ * node-crc32-stream
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+var Transform = require('readable-stream').Transform;
+
+var crc32 = require('buffer-crc32');
+
+var CRC32Stream = module.exports = function CRC32Stream(options) {
+ Transform.call(this, options);
+ this.checksum = new Buffer(4);
+ this.checksum.writeInt32BE(0, 0);
+
+ this.rawSize = 0;
+};
+
+inherits(CRC32Stream, Transform);
+
+CRC32Stream.prototype._transform = function(chunk, encoding, callback) {
+ if (chunk) {
+ this.checksum = crc32(chunk, this.checksum);
+ this.rawSize += chunk.length;
+ }
+
+ callback(null, chunk);
+};
+
+CRC32Stream.prototype.digest = function() {
+ return crc32.unsigned(0, this.checksum);
+};
+
+CRC32Stream.prototype.hex = function() {
+ return this.digest().toString(16).toUpperCase();
+};
+
+CRC32Stream.prototype.size = function() {
+ return this.rawSize;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/deflate-crc32-stream.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/deflate-crc32-stream.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/deflate-crc32-stream.js
index ba31dd1..82fe1c8 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/deflate-crc32-stream.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/deflate-crc32-stream.js
@@ -1,67 +1,67 @@
-/**
- * node-crc32-stream
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
- */
-var zlib = require('zlib');
-var inherits = require('util').inherits;
-
-var crc32 = require('buffer-crc32');
-
-var DeflateCRC32Stream = module.exports = function (options) {
- zlib.DeflateRaw.call(this, options);
-
- this.checksum = new Buffer(4);
- this.checksum.writeInt32BE(0, 0);
-
- this.rawSize = 0;
- this.compressedSize = 0;
-
- // BC v0.8
- if (typeof zlib.DeflateRaw.prototype.push !== 'function') {
- this.on('data', function(chunk) {
- if (chunk) {
- this.compressedSize += chunk.length;
- }
- });
- }
-};
-
-inherits(DeflateCRC32Stream, zlib.DeflateRaw);
-
-DeflateCRC32Stream.prototype.push = function(chunk, encoding) {
- if (chunk) {
- this.compressedSize += chunk.length;
- }
-
- return zlib.DeflateRaw.prototype.push.call(this, chunk, encoding);
-};
-
-DeflateCRC32Stream.prototype.write = function(chunk, cb) {
- if (chunk) {
- this.checksum = crc32(chunk, this.checksum);
- this.rawSize += chunk.length;
- }
-
- return zlib.DeflateRaw.prototype.write.call(this, chunk, cb);
-};
-
-DeflateCRC32Stream.prototype.digest = function() {
- return crc32.unsigned(0, this.checksum);
-};
-
-DeflateCRC32Stream.prototype.hex = function() {
- return this.digest().toString(16).toUpperCase();
-};
-
-DeflateCRC32Stream.prototype.size = function(compressed) {
- compressed = compressed || false;
-
- if (compressed) {
- return this.compressedSize;
- } else {
- return this.rawSize;
- }
+/**
+ * node-crc32-stream
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
+ */
+var zlib = require('zlib');
+var inherits = require('util').inherits;
+
+var crc32 = require('buffer-crc32');
+
+var DeflateCRC32Stream = module.exports = function (options) {
+ zlib.DeflateRaw.call(this, options);
+
+ this.checksum = new Buffer(4);
+ this.checksum.writeInt32BE(0, 0);
+
+ this.rawSize = 0;
+ this.compressedSize = 0;
+
+ // BC v0.8
+ if (typeof zlib.DeflateRaw.prototype.push !== 'function') {
+ this.on('data', function(chunk) {
+ if (chunk) {
+ this.compressedSize += chunk.length;
+ }
+ });
+ }
+};
+
+inherits(DeflateCRC32Stream, zlib.DeflateRaw);
+
+DeflateCRC32Stream.prototype.push = function(chunk, encoding) {
+ if (chunk) {
+ this.compressedSize += chunk.length;
+ }
+
+ return zlib.DeflateRaw.prototype.push.call(this, chunk, encoding);
+};
+
+DeflateCRC32Stream.prototype.write = function(chunk, cb) {
+ if (chunk) {
+ this.checksum = crc32(chunk, this.checksum);
+ this.rawSize += chunk.length;
+ }
+
+ return zlib.DeflateRaw.prototype.write.call(this, chunk, cb);
+};
+
+DeflateCRC32Stream.prototype.digest = function() {
+ return crc32.unsigned(0, this.checksum);
+};
+
+DeflateCRC32Stream.prototype.hex = function() {
+ return this.digest().toString(16).toUpperCase();
+};
+
+DeflateCRC32Stream.prototype.size = function(compressed) {
+ compressed = compressed || false;
+
+ if (compressed) {
+ return this.compressedSize;
+ } else {
+ return this.rawSize;
+ }
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/index.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/index.js
index 31187e3..e26ea25 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/index.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/index.js
@@ -1,10 +1,10 @@
-/**
- * node-crc32-stream
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
- */
-exports = module.exports = require('./crc32-stream');
-exports.CRC32Stream = exports;
+/**
+ * node-crc32-stream
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
+ */
+exports = module.exports = require('./crc32-stream');
+exports.CRC32Stream = exports;
exports.DeflateCRC32Stream = require('./deflate-crc32-stream');
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[11/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/util/index.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/util/index.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/util/index.js
index 6e89f0e..fab87a0 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/util/index.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/util/index.js
@@ -1,30 +1,30 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var Stream = require('stream').Stream;
-var PassThrough = require('readable-stream').PassThrough;
-
-var util = module.exports = {};
-
-util.isStream = function(source) {
- return source instanceof Stream;
-};
-
-util.normalizeInputSource = function(source) {
- if (source === null) {
- return new Buffer(0);
- } else if (typeof source === 'string') {
- return new Buffer(source);
- } else if (util.isStream(source) && !source._readableState) {
- var normalized = new PassThrough();
- source.pipe(normalized);
-
- return normalized;
- }
-
- return source;
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var Stream = require('stream').Stream;
+var PassThrough = require('readable-stream').PassThrough;
+
+var util = module.exports = {};
+
+util.isStream = function(source) {
+ return source instanceof Stream;
+};
+
+util.normalizeInputSource = function(source) {
+ if (source === null) {
+ return new Buffer(0);
+ } else if (typeof source === 'string') {
+ return new Buffer(source);
+ } else if (util.isStream(source) && !source._readableState) {
+ var normalized = new PassThrough();
+ source.pipe(normalized);
+
+ return normalized;
+ }
+
+ return source;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/CHANGELOG
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/CHANGELOG b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/CHANGELOG
index 983c20b..b87f161 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/CHANGELOG
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/CHANGELOG
@@ -1,18 +1,18 @@
-v0.2.0:
- date: 2014-05-03
- changes:
- - add size method to return raw size of data passed-through.
-v0.1.2:
- date: 2014-04-18
- changes:
- - always use readable-stream for consistency.
- - use crc32.unsigned to get digest.
-v0.1.1:
- date: 2014-03-30
- changes:
- - gracefully handle "no data" scenario.
- - trim down deps.
-v0.1.0:
- date: 2014-03-30
- changes:
+v0.2.0:
+ date: 2014-05-03
+ changes:
+ - add size method to return raw size of data passed-through.
+v0.1.2:
+ date: 2014-04-18
+ changes:
+ - always use readable-stream for consistency.
+ - use crc32.unsigned to get digest.
+v0.1.1:
+ date: 2014-03-30
+ changes:
+ - gracefully handle "no data" scenario.
+ - trim down deps.
+v0.1.0:
+ date: 2014-03-30
+ changes:
- initial release.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/LICENSE-MIT
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/LICENSE-MIT b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/LICENSE-MIT
index 819b403..56420a6 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/LICENSE-MIT
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/LICENSE-MIT
@@ -1,22 +1,22 @@
-Copyright (c) 2014 Chris Talkington, contributors.
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+Copyright (c) 2014 Chris Talkington, contributors.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/README.md
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/README.md b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/README.md
index 040224f..4e697da 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/README.md
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/README.md
@@ -1,81 +1,81 @@
-# crc32-stream v0.3.2 [](https://travis-ci.org/archiverjs/node-crc32-stream)
-
-crc32-stream is a streaming CRC32 checksumer. It uses [buffer-crc32](https://www.npmjs.org/package/buffer-crc32) behind the scenes to reliably handle binary data and fancy character sets. Data is passed through untouched.
-
-[](https://nodei.co/npm/crc32-stream/)
-
-### Install
-
-```bash
-npm install crc32-stream --save
-```
-
-You can also use `npm install https://github.com/archiverjs/node-crc32-stream/archive/master.tar.gz` to test upcoming versions.
-
-### Usage
-
-#### CRC32Stream
-
-Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) options and methods.
-
-```js
-var CRC32Stream = require('crc32-stream');
-
-var source = fs.createReadStream('file.txt');
-var checksum = new CRC32Stream();
-
-checksum.on('end', function(err) {
- // do something with checksum.digest() here
-});
-
-// either pipe it
-source.pipe(checksum);
-
-// or write it
-checksum.write('string');
-checksum.end();
-```
-
-#### DeflateCRC32Stream
-
-Inherits [zlib.DeflateRaw](http://nodejs.org/api/zlib.html#zlib_class_zlib_deflateraw) options and methods.
-
-```js
-var DeflateCRC32Stream = require('crc32-stream').DeflateCRC32Stream;
-
-var source = fs.createReadStream('file.txt');
-var checksum = new DeflateCRC32Stream();
-
-checksum.on('end', function(err) {
- // do something with checksum.digest() here
-});
-
-// either pipe it
-source.pipe(checksum);
-
-// or write it
-checksum.write('string');
-checksum.end();
-```
-
-### Instance API
-
-#### digest()
-
-Returns the checksum digest in unsigned form.
-
-#### hex()
-
-Returns the hexadecimal representation of the checksum digest. (ie E81722F0)
-
-#### size(compressed)
-
-Returns the raw size/length of passed-through data.
-
-If `compressed` is `true`, it returns compressed length instead. (DeflateCRC32Stream)
-
-## Things of Interest
-
-- [Changelog](https://github.com/archiverjs/node-crc32-stream/releases)
-- [Contributing](https://github.com/archiverjs/node-crc32-stream/blob/master/CONTRIBUTING.md)
+# crc32-stream v0.3.2 [](https://travis-ci.org/archiverjs/node-crc32-stream)
+
+crc32-stream is a streaming CRC32 checksumer. It uses [buffer-crc32](https://www.npmjs.org/package/buffer-crc32) behind the scenes to reliably handle binary data and fancy character sets. Data is passed through untouched.
+
+[](https://nodei.co/npm/crc32-stream/)
+
+### Install
+
+```bash
+npm install crc32-stream --save
+```
+
+You can also use `npm install https://github.com/archiverjs/node-crc32-stream/archive/master.tar.gz` to test upcoming versions.
+
+### Usage
+
+#### CRC32Stream
+
+Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) options and methods.
+
+```js
+var CRC32Stream = require('crc32-stream');
+
+var source = fs.createReadStream('file.txt');
+var checksum = new CRC32Stream();
+
+checksum.on('end', function(err) {
+ // do something with checksum.digest() here
+});
+
+// either pipe it
+source.pipe(checksum);
+
+// or write it
+checksum.write('string');
+checksum.end();
+```
+
+#### DeflateCRC32Stream
+
+Inherits [zlib.DeflateRaw](http://nodejs.org/api/zlib.html#zlib_class_zlib_deflateraw) options and methods.
+
+```js
+var DeflateCRC32Stream = require('crc32-stream').DeflateCRC32Stream;
+
+var source = fs.createReadStream('file.txt');
+var checksum = new DeflateCRC32Stream();
+
+checksum.on('end', function(err) {
+ // do something with checksum.digest() here
+});
+
+// either pipe it
+source.pipe(checksum);
+
+// or write it
+checksum.write('string');
+checksum.end();
+```
+
+### Instance API
+
+#### digest()
+
+Returns the checksum digest in unsigned form.
+
+#### hex()
+
+Returns the hexadecimal representation of the checksum digest. (ie E81722F0)
+
+#### size(compressed)
+
+Returns the raw size/length of passed-through data.
+
+If `compressed` is `true`, it returns compressed length instead. (DeflateCRC32Stream)
+
+## Things of Interest
+
+- [Changelog](https://github.com/archiverjs/node-crc32-stream/releases)
+- [Contributing](https://github.com/archiverjs/node-crc32-stream/blob/master/CONTRIBUTING.md)
- [MIT License](https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/crc32-stream.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/crc32-stream.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/crc32-stream.js
index 42cb454..3cec9cc 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/crc32-stream.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/crc32-stream.js
@@ -1,42 +1,42 @@
-/**
- * node-crc32-stream
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-var Transform = require('readable-stream').Transform;
-
-var crc32 = require('buffer-crc32');
-
-var CRC32Stream = module.exports = function CRC32Stream(options) {
- Transform.call(this, options);
- this.checksum = new Buffer(4);
- this.checksum.writeInt32BE(0, 0);
-
- this.rawSize = 0;
-};
-
-inherits(CRC32Stream, Transform);
-
-CRC32Stream.prototype._transform = function(chunk, encoding, callback) {
- if (chunk) {
- this.checksum = crc32(chunk, this.checksum);
- this.rawSize += chunk.length;
- }
-
- callback(null, chunk);
-};
-
-CRC32Stream.prototype.digest = function() {
- return crc32.unsigned(0, this.checksum);
-};
-
-CRC32Stream.prototype.hex = function() {
- return this.digest().toString(16).toUpperCase();
-};
-
-CRC32Stream.prototype.size = function() {
- return this.rawSize;
+/**
+ * node-crc32-stream
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+var Transform = require('readable-stream').Transform;
+
+var crc32 = require('buffer-crc32');
+
+var CRC32Stream = module.exports = function CRC32Stream(options) {
+ Transform.call(this, options);
+ this.checksum = new Buffer(4);
+ this.checksum.writeInt32BE(0, 0);
+
+ this.rawSize = 0;
+};
+
+inherits(CRC32Stream, Transform);
+
+CRC32Stream.prototype._transform = function(chunk, encoding, callback) {
+ if (chunk) {
+ this.checksum = crc32(chunk, this.checksum);
+ this.rawSize += chunk.length;
+ }
+
+ callback(null, chunk);
+};
+
+CRC32Stream.prototype.digest = function() {
+ return crc32.unsigned(0, this.checksum);
+};
+
+CRC32Stream.prototype.hex = function() {
+ return this.digest().toString(16).toUpperCase();
+};
+
+CRC32Stream.prototype.size = function() {
+ return this.rawSize;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/deflate-crc32-stream.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/deflate-crc32-stream.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/deflate-crc32-stream.js
index ba31dd1..82fe1c8 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/deflate-crc32-stream.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/deflate-crc32-stream.js
@@ -1,67 +1,67 @@
-/**
- * node-crc32-stream
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
- */
-var zlib = require('zlib');
-var inherits = require('util').inherits;
-
-var crc32 = require('buffer-crc32');
-
-var DeflateCRC32Stream = module.exports = function (options) {
- zlib.DeflateRaw.call(this, options);
-
- this.checksum = new Buffer(4);
- this.checksum.writeInt32BE(0, 0);
-
- this.rawSize = 0;
- this.compressedSize = 0;
-
- // BC v0.8
- if (typeof zlib.DeflateRaw.prototype.push !== 'function') {
- this.on('data', function(chunk) {
- if (chunk) {
- this.compressedSize += chunk.length;
- }
- });
- }
-};
-
-inherits(DeflateCRC32Stream, zlib.DeflateRaw);
-
-DeflateCRC32Stream.prototype.push = function(chunk, encoding) {
- if (chunk) {
- this.compressedSize += chunk.length;
- }
-
- return zlib.DeflateRaw.prototype.push.call(this, chunk, encoding);
-};
-
-DeflateCRC32Stream.prototype.write = function(chunk, cb) {
- if (chunk) {
- this.checksum = crc32(chunk, this.checksum);
- this.rawSize += chunk.length;
- }
-
- return zlib.DeflateRaw.prototype.write.call(this, chunk, cb);
-};
-
-DeflateCRC32Stream.prototype.digest = function() {
- return crc32.unsigned(0, this.checksum);
-};
-
-DeflateCRC32Stream.prototype.hex = function() {
- return this.digest().toString(16).toUpperCase();
-};
-
-DeflateCRC32Stream.prototype.size = function(compressed) {
- compressed = compressed || false;
-
- if (compressed) {
- return this.compressedSize;
- } else {
- return this.rawSize;
- }
+/**
+ * node-crc32-stream
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
+ */
+var zlib = require('zlib');
+var inherits = require('util').inherits;
+
+var crc32 = require('buffer-crc32');
+
+var DeflateCRC32Stream = module.exports = function (options) {
+ zlib.DeflateRaw.call(this, options);
+
+ this.checksum = new Buffer(4);
+ this.checksum.writeInt32BE(0, 0);
+
+ this.rawSize = 0;
+ this.compressedSize = 0;
+
+ // BC v0.8
+ if (typeof zlib.DeflateRaw.prototype.push !== 'function') {
+ this.on('data', function(chunk) {
+ if (chunk) {
+ this.compressedSize += chunk.length;
+ }
+ });
+ }
+};
+
+inherits(DeflateCRC32Stream, zlib.DeflateRaw);
+
+DeflateCRC32Stream.prototype.push = function(chunk, encoding) {
+ if (chunk) {
+ this.compressedSize += chunk.length;
+ }
+
+ return zlib.DeflateRaw.prototype.push.call(this, chunk, encoding);
+};
+
+DeflateCRC32Stream.prototype.write = function(chunk, cb) {
+ if (chunk) {
+ this.checksum = crc32(chunk, this.checksum);
+ this.rawSize += chunk.length;
+ }
+
+ return zlib.DeflateRaw.prototype.write.call(this, chunk, cb);
+};
+
+DeflateCRC32Stream.prototype.digest = function() {
+ return crc32.unsigned(0, this.checksum);
+};
+
+DeflateCRC32Stream.prototype.hex = function() {
+ return this.digest().toString(16).toUpperCase();
+};
+
+DeflateCRC32Stream.prototype.size = function(compressed) {
+ compressed = compressed || false;
+
+ if (compressed) {
+ return this.compressedSize;
+ } else {
+ return this.rawSize;
+ }
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/index.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/index.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/index.js
index 31187e3..e26ea25 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/index.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/node_modules/crc32-stream/lib/index.js
@@ -1,10 +1,10 @@
-/**
- * node-crc32-stream
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
- */
-exports = module.exports = require('./crc32-stream');
-exports.CRC32Stream = exports;
+/**
+ * node-crc32-stream
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT
+ */
+exports = module.exports = require('./crc32-stream');
+exports.CRC32Stream = exports;
exports.DeflateCRC32Stream = require('./deflate-crc32-stream');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
index 11e1f0a..b4c02d3 100644
--- a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
@@ -1,480 +1,480 @@
-/*
- http://www.JSON.org/json2.js
- 2011-02-23
-
- Public Domain.
-
- NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
-
- See http://www.JSON.org/js.html
-
-
- This code should be minified before deployment.
- See http://javascript.crockford.com/jsmin.html
-
- USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
- NOT CONTROL.
-
-
- This file creates a global JSON object containing two methods: stringify
- and parse.
-
- JSON.stringify(value, replacer, space)
- value any JavaScript value, usually an object or array.
-
- replacer an optional parameter that determines how object
- values are stringified for objects. It can be a
- function or an array of strings.
-
- space an optional parameter that specifies the indentation
- of nested structures. If it is omitted, the text will
- be packed without extra whitespace. If it is a number,
- it will specify the number of spaces to indent at each
- level. If it is a string (such as '\t' or ' '),
- it contains the characters used to indent at each level.
-
- This method produces a JSON text from a JavaScript value.
-
- When an object value is found, if the object contains a toJSON
- method, its toJSON method will be called and the result will be
- stringified. A toJSON method does not serialize: it returns the
- value represented by the name/value pair that should be serialized,
- or undefined if nothing should be serialized. The toJSON method
- will be passed the key associated with the value, and this will be
- bound to the value
-
- For example, this would serialize Dates as ISO strings.
-
- Date.prototype.toJSON = function (key) {
- function f(n) {
- // Format integers to have at least two digits.
- return n < 10 ? '0' + n : n;
- }
-
- return this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z';
- };
-
- You can provide an optional replacer method. It will be passed the
- key and value of each member, with this bound to the containing
- object. The value that is returned from your method will be
- serialized. If your method returns undefined, then the member will
- be excluded from the serialization.
-
- If the replacer parameter is an array of strings, then it will be
- used to select the members to be serialized. It filters the results
- such that only members with keys listed in the replacer array are
- stringified.
-
- Values that do not have JSON representations, such as undefined or
- functions, will not be serialized. Such values in objects will be
- dropped; in arrays they will be replaced with null. You can use
- a replacer function to replace those with JSON values.
- JSON.stringify(undefined) returns undefined.
-
- The optional space parameter produces a stringification of the
- value that is filled with line breaks and indentation to make it
- easier to read.
-
- If the space parameter is a non-empty string, then that string will
- be used for indentation. If the space parameter is a number, then
- the indentation will be that many spaces.
-
- Example:
-
- text = JSON.stringify(['e', {pluribus: 'unum'}]);
- // text is '["e",{"pluribus":"unum"}]'
-
-
- text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
- // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
-
- text = JSON.stringify([new Date()], function (key, value) {
- return this[key] instanceof Date ?
- 'Date(' + this[key] + ')' : value;
- });
- // text is '["Date(---current time---)"]'
-
-
- JSON.parse(text, reviver)
- This method parses a JSON text to produce an object or array.
- It can throw a SyntaxError exception.
-
- The optional reviver parameter is a function that can filter and
- transform the results. It receives each of the keys and values,
- and its return value is used instead of the original value.
- If it returns what it received, then the structure is not modified.
- If it returns undefined then the member is deleted.
-
- Example:
-
- // Parse the text. Values that look like ISO date strings will
- // be converted to Date objects.
-
- myData = JSON.parse(text, function (key, value) {
- var a;
- if (typeof value === 'string') {
- a =
-/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
- if (a) {
- return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
- +a[5], +a[6]));
- }
- }
- return value;
- });
-
- myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
- var d;
- if (typeof value === 'string' &&
- value.slice(0, 5) === 'Date(' &&
- value.slice(-1) === ')') {
- d = new Date(value.slice(5, -1));
- if (d) {
- return d;
- }
- }
- return value;
- });
-
-
- This is a reference implementation. You are free to copy, modify, or
- redistribute.
-*/
-
-/*jslint evil: true, strict: false, regexp: false */
-
-/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
- call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
- getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
- lastIndex, length, parse, prototype, push, replace, slice, stringify,
- test, toJSON, toString, valueOf
-*/
-
-
-// Create a JSON object only if one does not already exist. We create the
-// methods in a closure to avoid creating global variables.
-
-var JSON;
-if (!JSON) {
- JSON = {};
-}
-
-(function () {
- "use strict";
-
- function f(n) {
- // Format integers to have at least two digits.
- return n < 10 ? '0' + n : n;
- }
-
- if (typeof Date.prototype.toJSON !== 'function') {
-
- Date.prototype.toJSON = function (key) {
-
- return isFinite(this.valueOf()) ?
- this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z' : null;
- };
-
- String.prototype.toJSON =
- Number.prototype.toJSON =
- Boolean.prototype.toJSON = function (key) {
- return this.valueOf();
- };
- }
-
- var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- gap,
- indent,
- meta = { // table of character substitutions
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '\\': '\\\\'
- },
- rep;
-
-
- function quote(string) {
-
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can safely slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe escape
-// sequences.
-
- escapable.lastIndex = 0;
- return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
- var c = meta[a];
- return typeof c === 'string' ? c :
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- }) + '"' : '"' + string + '"';
- }
-
-
- function str(key, holder) {
-
-// Produce a string from holder[key].
-
- var i, // The loop counter.
- k, // The member key.
- v, // The member value.
- length,
- mind = gap,
- partial,
- value = holder[key];
-
-// If the value has a toJSON method, call it to obtain a replacement value.
-
- if (value && typeof value === 'object' &&
- typeof value.toJSON === 'function') {
- value = value.toJSON(key);
- }
-
-// If we were called with a replacer function, then call the replacer to
-// obtain a replacement value.
-
- if (typeof rep === 'function') {
- value = rep.call(holder, key, value);
- }
-
-// What happens next depends on the value's type.
-
- switch (typeof value) {
- case 'string':
- return quote(value);
-
- case 'number':
-
-// JSON numbers must be finite. Encode non-finite numbers as null.
-
- return isFinite(value) ? String(value) : 'null';
-
- case 'boolean':
- case 'null':
-
-// If the value is a boolean or null, convert it to a string. Note:
-// typeof null does not produce 'null'. The case is included here in
-// the remote chance that this gets fixed someday.
-
- return String(value);
-
-// If the type is 'object', we might be dealing with an object or an array or
-// null.
-
- case 'object':
-
-// Due to a specification blunder in ECMAScript, typeof null is 'object',
-// so watch out for that case.
-
- if (!value) {
- return 'null';
- }
-
-// Make an array to hold the partial results of stringifying this object value.
-
- gap += indent;
- partial = [];
-
-// Is the value an array?
-
- if (Object.prototype.toString.apply(value) === '[object Array]') {
-
-// The value is an array. Stringify every element. Use null as a placeholder
-// for non-JSON values.
-
- length = value.length;
- for (i = 0; i < length; i += 1) {
- partial[i] = str(i, value) || 'null';
- }
-
-// Join all of the elements together, separated with commas, and wrap them in
-// brackets.
-
- v = partial.length === 0 ? '[]' : gap ?
- '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
- '[' + partial.join(',') + ']';
- gap = mind;
- return v;
- }
-
-// If the replacer is an array, use it to select the members to be stringified.
-
- if (rep && typeof rep === 'object') {
- length = rep.length;
- for (i = 0; i < length; i += 1) {
- if (typeof rep[i] === 'string') {
- k = rep[i];
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
- }
- }
- }
- } else {
-
-// Otherwise, iterate through all of the keys in the object.
-
- for (k in value) {
- if (Object.prototype.hasOwnProperty.call(value, k)) {
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
- }
- }
- }
- }
-
-// Join all of the member texts together, separated with commas,
-// and wrap them in braces.
-
- v = partial.length === 0 ? '{}' : gap ?
- '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
- '{' + partial.join(',') + '}';
- gap = mind;
- return v;
- }
- }
-
-// If the JSON object does not yet have a stringify method, give it one.
-
- if (typeof JSON.stringify !== 'function') {
- JSON.stringify = function (value, replacer, space) {
-
-// The stringify method takes a value and an optional replacer, and an optional
-// space parameter, and returns a JSON text. The replacer can be a function
-// that can replace values, or an array of strings that will select the keys.
-// A default replacer method can be provided. Use of the space parameter can
-// produce text that is more easily readable.
-
- var i;
- gap = '';
- indent = '';
-
-// If the space parameter is a number, make an indent string containing that
-// many spaces.
-
- if (typeof space === 'number') {
- for (i = 0; i < space; i += 1) {
- indent += ' ';
- }
-
-// If the space parameter is a string, it will be used as the indent string.
-
- } else if (typeof space === 'string') {
- indent = space;
- }
-
-// If there is a replacer, it must be a function or an array.
-// Otherwise, throw an error.
-
- rep = replacer;
- if (replacer && typeof replacer !== 'function' &&
- (typeof replacer !== 'object' ||
- typeof replacer.length !== 'number')) {
- throw new Error('JSON.stringify');
- }
-
-// Make a fake root object containing our value under the key of ''.
-// Return the result of stringifying the value.
-
- return str('', {'': value});
- };
- }
-
-
-// If the JSON object does not yet have a parse method, give it one.
-
- if (typeof JSON.parse !== 'function') {
- JSON.parse = function (text, reviver) {
-
-// The parse method takes a text and an optional reviver function, and returns
-// a JavaScript value if the text is a valid JSON text.
-
- var j;
-
- function walk(holder, key) {
-
-// The walk method is used to recursively walk the resulting structure so
-// that modifications can be made.
-
- var k, v, value = holder[key];
- if (value && typeof value === 'object') {
- for (k in value) {
- if (Object.prototype.hasOwnProperty.call(value, k)) {
- v = walk(value, k);
- if (v !== undefined) {
- value[k] = v;
- } else {
- delete value[k];
- }
- }
- }
- }
- return reviver.call(holder, key, value);
- }
-
-
-// Parsing happens in four stages. In the first stage, we replace certain
-// Unicode characters with escape sequences. JavaScript handles many characters
-// incorrectly, either silently deleting them, or treating them as line endings.
-
- text = String(text);
- cx.lastIndex = 0;
- if (cx.test(text)) {
- text = text.replace(cx, function (a) {
- return '\\u' +
- ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- });
- }
-
-// In the second stage, we run the text against regular expressions that look
-// for non-JSON patterns. We are especially concerned with '()' and 'new'
-// because they can cause invocation, and '=' because it can cause mutation.
-// But just to be safe, we want to reject all unexpected forms.
-
-// We split the second stage into 4 regexp operations in order to work around
-// crippling inefficiencies in IE's and Safari's regexp engines. First we
-// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
-// replace all simple value tokens with ']' characters. Third, we delete all
-// open brackets that follow a colon or comma or that begin the text. Finally,
-// we look to see that the remaining characters are only whitespace or ']' or
-// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
-
- if (/^[\],:{}\s]*$/
- .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
- .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
- .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
-
-// In the third stage we use the eval function to compile the text into a
-// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
-// in JavaScript: it can begin a block or an object literal. We wrap the text
-// in parens to eliminate the ambiguity.
-
- j = eval('(' + text + ')');
-
-// In the optional fourth stage, we recursively walk the new structure, passing
-// each name/value pair to a reviver function for possible transformation.
-
- return typeof reviver === 'function' ?
- walk({'': j}, '') : j;
- }
-
-// If the text is not JSON parseable, then a SyntaxError is thrown.
-
- throw new SyntaxError('JSON.parse');
- };
- }
-}());
+/*
+ http://www.JSON.org/json2.js
+ 2011-02-23
+
+ Public Domain.
+
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+ See http://www.JSON.org/js.html
+
+
+ This code should be minified before deployment.
+ See http://javascript.crockford.com/jsmin.html
+
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+ NOT CONTROL.
+
+
+ This file creates a global JSON object containing two methods: stringify
+ and parse.
+
+ JSON.stringify(value, replacer, space)
+ value any JavaScript value, usually an object or array.
+
+ replacer an optional parameter that determines how object
+ values are stringified for objects. It can be a
+ function or an array of strings.
+
+ space an optional parameter that specifies the indentation
+ of nested structures. If it is omitted, the text will
+ be packed without extra whitespace. If it is a number,
+ it will specify the number of spaces to indent at each
+ level. If it is a string (such as '\t' or ' '),
+ it contains the characters used to indent at each level.
+
+ This method produces a JSON text from a JavaScript value.
+
+ When an object value is found, if the object contains a toJSON
+ method, its toJSON method will be called and the result will be
+ stringified. A toJSON method does not serialize: it returns the
+ value represented by the name/value pair that should be serialized,
+ or undefined if nothing should be serialized. The toJSON method
+ will be passed the key associated with the value, and this will be
+ bound to the value
+
+ For example, this would serialize Dates as ISO strings.
+
+ Date.prototype.toJSON = function (key) {
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ return this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z';
+ };
+
+ You can provide an optional replacer method. It will be passed the
+ key and value of each member, with this bound to the containing
+ object. The value that is returned from your method will be
+ serialized. If your method returns undefined, then the member will
+ be excluded from the serialization.
+
+ If the replacer parameter is an array of strings, then it will be
+ used to select the members to be serialized. It filters the results
+ such that only members with keys listed in the replacer array are
+ stringified.
+
+ Values that do not have JSON representations, such as undefined or
+ functions, will not be serialized. Such values in objects will be
+ dropped; in arrays they will be replaced with null. You can use
+ a replacer function to replace those with JSON values.
+ JSON.stringify(undefined) returns undefined.
+
+ The optional space parameter produces a stringification of the
+ value that is filled with line breaks and indentation to make it
+ easier to read.
+
+ If the space parameter is a non-empty string, then that string will
+ be used for indentation. If the space parameter is a number, then
+ the indentation will be that many spaces.
+
+ Example:
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
+ // text is '["e",{"pluribus":"unum"}]'
+
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+ text = JSON.stringify([new Date()], function (key, value) {
+ return this[key] instanceof Date ?
+ 'Date(' + this[key] + ')' : value;
+ });
+ // text is '["Date(---current time---)"]'
+
+
+ JSON.parse(text, reviver)
+ This method parses a JSON text to produce an object or array.
+ It can throw a SyntaxError exception.
+
+ The optional reviver parameter is a function that can filter and
+ transform the results. It receives each of the keys and values,
+ and its return value is used instead of the original value.
+ If it returns what it received, then the structure is not modified.
+ If it returns undefined then the member is deleted.
+
+ Example:
+
+ // Parse the text. Values that look like ISO date strings will
+ // be converted to Date objects.
+
+ myData = JSON.parse(text, function (key, value) {
+ var a;
+ if (typeof value === 'string') {
+ a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+ if (a) {
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+ +a[5], +a[6]));
+ }
+ }
+ return value;
+ });
+
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+ var d;
+ if (typeof value === 'string' &&
+ value.slice(0, 5) === 'Date(' &&
+ value.slice(-1) === ')') {
+ d = new Date(value.slice(5, -1));
+ if (d) {
+ return d;
+ }
+ }
+ return value;
+ });
+
+
+ This is a reference implementation. You are free to copy, modify, or
+ redistribute.
+*/
+
+/*jslint evil: true, strict: false, regexp: false */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
+ test, toJSON, toString, valueOf
+*/
+
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+var JSON;
+if (!JSON) {
+ JSON = {};
+}
+
+(function () {
+ "use strict";
+
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ if (typeof Date.prototype.toJSON !== 'function') {
+
+ Date.prototype.toJSON = function (key) {
+
+ return isFinite(this.valueOf()) ?
+ this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z' : null;
+ };
+
+ String.prototype.toJSON =
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
+ }
+
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+
+ function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+ escapable.lastIndex = 0;
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string' ? c :
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' : '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+
+// Produce a string from holder[key].
+
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+ if (value && typeof value === 'object' &&
+ typeof value.toJSON === 'function') {
+ value = value.toJSON(key);
+ }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+// What happens next depends on the value's type.
+
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+ return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+ case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+ if (!value) {
+ return 'null';
+ }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+ gap += indent;
+ partial = [];
+
+// Is the value an array?
+
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+ v = partial.length === 0 ? '[]' : gap ?
+ '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
+ '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ if (typeof rep[i] === 'string') {
+ k = rep[i];
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+ v = partial.length === 0 ? '{}' : gap ?
+ '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
+ '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+ if (typeof JSON.stringify !== 'function') {
+ JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+ var i;
+ gap = '';
+ indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+ return str('', {'': value});
+ };
+ }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+ if (typeof JSON.parse !== 'function') {
+ JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+ var j;
+
+ function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+ var k, v, value = holder[key];
+ if (value && typeof value === 'object') {
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = walk(value, k);
+ if (v !== undefined) {
+ value[k] = v;
+ } else {
+ delete value[k];
+ }
+ }
+ }
+ }
+ return reviver.call(holder, key, value);
+ }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+ text = String(text);
+ cx.lastIndex = 0;
+ if (cx.test(text)) {
+ text = text.replace(cx, function (a) {
+ return '\\u' +
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ });
+ }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+ if (/^[\],:{}\s]*$/
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+ j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+ return typeof reviver === 'function' ?
+ walk({'': j}, '') : j;
+ }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+ throw new SyntaxError('JSON.parse');
+ };
+ }
+}());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[07/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js b/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
index 43920d9..0d58db0 100644
--- a/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
+++ b/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
@@ -1,1302 +1,1302 @@
-//
-// showdown.js -- A javascript port of Markdown.
-//
-// Copyright (c) 2007 John Fraser.
-//
-// Original Markdown Copyright (c) 2004-2005 John Gruber
-// <http://daringfireball.net/projects/markdown/>
-//
-// Redistributable under a BSD-style open source license.
-// See license.txt for more information.
-//
-// The full source distribution is at:
-//
-// A A L
-// T C A
-// T K B
-//
-// <http://www.attacklab.net/>
-//
-
-//
-// Wherever possible, Showdown is a straight, line-by-line port
-// of the Perl version of Markdown.
-//
-// This is not a normal parser design; it's basically just a
-// series of string substitutions. It's hard to read and
-// maintain this way, but keeping Showdown close to the original
-// design makes it easier to port new features.
-//
-// More importantly, Showdown behaves like markdown.pl in most
-// edge cases. So web applications can do client-side preview
-// in Javascript, and then build identical HTML on the server.
-//
-// This port needs the new RegExp functionality of ECMA 262,
-// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers
-// should do fine. Even with the new regular expression features,
-// We do a lot of work to emulate Perl's regex functionality.
-// The tricky changes in this file mostly have the "attacklab:"
-// label. Major or self-explanatory changes don't.
-//
-// Smart diff tools like Araxis Merge will be able to match up
-// this file with markdown.pl in a useful way. A little tweaking
-// helps: in a copy of markdown.pl, replace "#" with "//" and
-// replace "$text" with "text". Be sure to ignore whitespace
-// and line endings.
-//
-
-
-//
-// Showdown usage:
-//
-// var text = "Markdown *rocks*.";
-//
-// var converter = new Showdown.converter();
-// var html = converter.makeHtml(text);
-//
-// alert(html);
-//
-// Note: move the sample code to the bottom of this
-// file before uncommenting it.
-//
-
-
-//
-// Showdown namespace
-//
-var Showdown = {};
-
-//
-// converter
-//
-// Wraps all "globals" so that the only thing
-// exposed is makeHtml().
-//
-Showdown.converter = function() {
-
-//
-// Globals:
-//
-
-// Global hashes, used by various utility routines
-var g_urls;
-var g_titles;
-var g_html_blocks;
-
-// Used to track when we're inside an ordered or unordered list
-// (see _ProcessListItems() for details):
-var g_list_level = 0;
-
-
-this.makeHtml = function(text) {
-//
-// Main function. The order in which other subs are called here is
-// essential. Link and image substitutions need to happen before
-// _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the <a>
-// and <img> tags get encoded.
-//
-
- // Clear the global hashes. If we don't clear these, you get conflicts
- // from other articles when generating a page which contains more than
- // one article (e.g. an index page that shows the N most recent
- // articles):
- g_urls = new Array();
- g_titles = new Array();
- g_html_blocks = new Array();
-
- // attacklab: Replace ~ with ~T
- // This lets us use tilde as an escape char to avoid md5 hashes
- // The choice of character is arbitray; anything that isn't
- // magic in Markdown will work.
- text = text.replace(/~/g,"~T");
-
- // attacklab: Replace $ with ~D
- // RegExp interprets $ as a special character
- // when it's in a replacement string
- text = text.replace(/\$/g,"~D");
-
- // Standardize line endings
- text = text.replace(/\r\n/g,"\n"); // DOS to Unix
- text = text.replace(/\r/g,"\n"); // Mac to Unix
-
- // Make sure text begins and ends with a couple of newlines:
- text = "\n\n" + text + "\n\n";
-
- // Convert all tabs to spaces.
- text = _Detab(text);
-
- // Strip any lines consisting only of spaces and tabs.
- // This makes subsequent regexen easier to write, because we can
- // match consecutive blank lines with /\n+/ instead of something
- // contorted like /[ \t]*\n+/ .
- text = text.replace(/^[ \t]+$/mg,"");
-
- // Turn block-level HTML blocks into hash entries
- text = _HashHTMLBlocks(text);
-
- // Strip link definitions, store in hashes.
- text = _StripLinkDefinitions(text);
-
- text = _RunBlockGamut(text);
-
- text = _UnescapeSpecialChars(text);
-
- // attacklab: Restore dollar signs
- text = text.replace(/~D/g,"$$");
-
- // attacklab: Restore tildes
- text = text.replace(/~T/g,"~");
-
- return text;
-}
-
-
-var _StripLinkDefinitions = function(text) {
-//
-// Strips link definitions from text, stores the URLs and titles in
-// hash references.
-//
-
- // Link defs are in the form: ^[id]: url "optional title"
-
- /*
- var text = text.replace(/
- ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1
- [ \t]*
- \n? // maybe *one* newline
- [ \t]*
- <?(\S+?)>? // url = $2
- [ \t]*
- \n? // maybe one newline
- [ \t]*
- (?:
- (\n*) // any lines skipped = $3 attacklab: lookbehind removed
- ["(]
- (.+?) // title = $4
- [")]
- [ \t]*
- )? // title is optional
- (?:\n+|$)
- /gm,
- function(){...});
- */
- var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,
- function (wholeMatch,m1,m2,m3,m4) {
- m1 = m1.toLowerCase();
- g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive
- if (m3) {
- // Oops, found blank lines, so it's not a title.
- // Put back the parenthetical statement we stole.
- return m3+m4;
- } else if (m4) {
- g_titles[m1] = m4.replace(/"/g,""");
- }
-
- // Completely remove the definition from the text
- return "";
- }
- );
-
- return text;
-}
-
-
-var _HashHTMLBlocks = function(text) {
- // attacklab: Double up blank lines to reduce lookaround
- text = text.replace(/\n/g,"\n\n");
-
- // Hashify HTML blocks:
- // We only want to do this for block-level HTML tags, such as headers,
- // lists, and tables. That's because we still want to wrap <p>s around
- // "paragraphs" that are wrapped in non-block-level tags, such as anchors,
- // phrase emphasis, and spans. The list of tags we're looking for is
- // hard-coded:
- var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del"
- var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math"
-
- // First, look for nested blocks, e.g.:
- // <div>
- // <div>
- // tags for inner block must be indented.
- // </div>
- // </div>
- //
- // The outermost tags must start at the left margin for this to match, and
- // the inner nested divs must be indented.
- // We need to do this before the next, more liberal match, because the next
- // match will start at the first `<div>` and stop at the first `</div>`.
-
- // attacklab: This regex can be expensive when it fails.
- /*
- var text = text.replace(/
- ( // save in $1
- ^ // start of line (with /m)
- <($block_tags_a) // start tag = $2
- \b // word break
- // attacklab: hack around khtml/pcre bug...
- [^\r]*?\n // any number of lines, minimally matching
- </\2> // the matching end tag
- [ \t]* // trailing spaces/tabs
- (?=\n+) // followed by a newline
- ) // attacklab: there are sentinel newlines at end of document
- /gm,function(){...}};
- */
- text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement);
-
- //
- // Now match more liberally, simply from `\n<tag>` to `</tag>\n`
- //
-
- /*
- var text = text.replace(/
- ( // save in $1
- ^ // start of line (with /m)
- <($block_tags_b) // start tag = $2
- \b // word break
- // attacklab: hack around khtml/pcre bug...
- [^\r]*? // any number of lines, minimally matching
- .*</\2> // the matching end tag
- [ \t]* // trailing spaces/tabs
- (?=\n+) // followed by a newline
- ) // attacklab: there are sentinel newlines at end of document
- /gm,function(){...}};
- */
- text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);
-
- // Special case just for <hr />. It was easier to make a special case than
- // to make the other regex more complicated.
-
- /*
- text = text.replace(/
- ( // save in $1
- \n\n // Starting after a blank line
- [ ]{0,3}
- (<(hr) // start tag = $2
- \b // word break
- ([^<>])*? //
- \/?>) // the matching end tag
- [ \t]*
- (?=\n{2,}) // followed by a blank line
- )
- /g,hashElement);
- */
- text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement);
-
- // Special case for standalone HTML comments:
-
- /*
- text = text.replace(/
- ( // save in $1
- \n\n // Starting after a blank line
- [ ]{0,3} // attacklab: g_tab_width - 1
- <!
- (--[^\r]*?--\s*)+
- >
- [ \t]*
- (?=\n{2,}) // followed by a blank line
- )
- /g,hashElement);
- */
- text = text.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,hashElement);
-
- // PHP and ASP-style processor instructions (<?...?> and <%...%>)
-
- /*
- text = text.replace(/
- (?:
- \n\n // Starting after a blank line
- )
- ( // save in $1
- [ ]{0,3} // attacklab: g_tab_width - 1
- (?:
- <([?%]) // $2
- [^\r]*?
- \2>
- )
- [ \t]*
- (?=\n{2,}) // followed by a blank line
- )
- /g,hashElement);
- */
- text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement);
-
- // attacklab: Undo double lines (see comment at top of this function)
- text = text.replace(/\n\n/g,"\n");
- return text;
-}
-
-var hashElement = function(wholeMatch,m1) {
- var blockText = m1;
-
- // Undo double lines
- blockText = blockText.replace(/\n\n/g,"\n");
- blockText = blockText.replace(/^\n/,"");
-
- // strip trailing blank lines
- blockText = blockText.replace(/\n+$/g,"");
-
- // Replace the element text with a marker ("~KxK" where x is its key)
- blockText = "\n\n~K" + (g_html_blocks.push(blockText)-1) + "K\n\n";
-
- return blockText;
-};
-
-var _RunBlockGamut = function(text) {
-//
-// These are all the transformations that form block-level
-// tags like paragraphs, headers, and list items.
-//
- text = _DoHeaders(text);
-
- // Do Horizontal Rules:
- var key = hashBlock("<hr />");
- text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key);
- text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key);
- text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
-
- text = _DoLists(text);
- text = _DoCodeBlocks(text);
- text = _DoBlockQuotes(text);
-
- // We already ran _HashHTMLBlocks() before, in Markdown(), but that
- // was to escape raw HTML in the original Markdown source. This time,
- // we're escaping the markup we've just created, so that we don't wrap
- // <p> tags around block-level tags.
- text = _HashHTMLBlocks(text);
- text = _FormParagraphs(text);
-
- return text;
-}
-
-
-var _RunSpanGamut = function(text) {
-//
-// These are all the transformations that occur *within* block-level
-// tags like paragraphs, headers, and list items.
-//
-
- text = _DoCodeSpans(text);
- text = _EscapeSpecialCharsWithinTagAttributes(text);
- text = _EncodeBackslashEscapes(text);
-
- // Process anchor and image tags. Images must come first,
- // because ![foo][f] looks like an anchor.
- text = _DoImages(text);
- text = _DoAnchors(text);
-
- // Make links out of things like `<http://example.com/>`
- // Must come after _DoAnchors(), because you can use < and >
- // delimiters in inline links like [this](<url>).
- text = _DoAutoLinks(text);
- text = _EncodeAmpsAndAngles(text);
- text = _DoItalicsAndBold(text);
-
- // Do hard breaks:
- text = text.replace(/ +\n/g," <br />\n");
-
- return text;
-}
-
-var _EscapeSpecialCharsWithinTagAttributes = function(text) {
-//
-// Within tags -- meaning between < and > -- encode [\ ` * _] so they
-// don't conflict with their use in Markdown for code, italics and strong.
-//
-
- // Build a regex to find HTML tags and comments. See Friedl's
- // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
- var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;
-
- text = text.replace(regex, function(wholeMatch) {
- var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`");
- tag = escapeCharacters(tag,"\\`*_");
- return tag;
- });
-
- return text;
-}
-
-var _DoAnchors = function(text) {
-//
-// Turn Markdown link shortcuts into XHTML <a> tags.
-//
- //
- // First, handle reference-style links: [link text] [id]
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- (
- (?:
- \[[^\]]*\] // allow brackets nested one level
- |
- [^\[] // or anything else
- )*
- )
- \]
-
- [ ]? // one optional space
- (?:\n[ ]*)? // one optional newline followed by spaces
-
- \[
- (.*?) // id = $3
- \]
- )()()()() // pad remaining backreferences
- /g,_DoAnchors_callback);
- */
- text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag);
-
- //
- // Next, inline-style links: [link text](url "optional title")
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- (
- (?:
- \[[^\]]*\] // allow brackets nested one level
- |
- [^\[\]] // or anything else
- )
- )
- \]
- \( // literal paren
- [ \t]*
- () // no id, so leave $3 empty
- <?(.*?)>? // href = $4
- [ \t]*
- ( // $5
- (['"]) // quote char = $6
- (.*?) // Title = $7
- \6 // matching quote
- [ \t]* // ignore any spaces/tabs between closing quote and )
- )? // title is optional
- \)
- )
- /g,writeAnchorTag);
- */
- text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag);
-
- //
- // Last, handle reference-style shortcuts: [link text]
- // These must come last in case you've also got [link test][1]
- // or [link test](/foo)
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- ([^\[\]]+) // link text = $2; can't contain '[' or ']'
- \]
- )()()()()() // pad rest of backreferences
- /g, writeAnchorTag);
- */
- text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
-
- return text;
-}
-
-var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
- if (m7 == undefined) m7 = "";
- var whole_match = m1;
- var link_text = m2;
- var link_id = m3.toLowerCase();
- var url = m4;
- var title = m7;
-
- if (url == "") {
- if (link_id == "") {
- // lower-case and turn embedded newlines into spaces
- link_id = link_text.toLowerCase().replace(/ ?\n/g," ");
- }
- url = "#"+link_id;
-
- if (g_urls[link_id] != undefined) {
- url = g_urls[link_id];
- if (g_titles[link_id] != undefined) {
- title = g_titles[link_id];
- }
- }
- else {
- if (whole_match.search(/\(\s*\)$/m)>-1) {
- // Special case for explicit empty url
- url = "";
- } else {
- return whole_match;
- }
- }
- }
-
- url = escapeCharacters(url,"*_");
- var result = "<a href=\"" + url + "\"";
-
- if (title != "") {
- title = title.replace(/"/g,""");
- title = escapeCharacters(title,"*_");
- result += " title=\"" + title + "\"";
- }
-
- result += ">" + link_text + "</a>";
-
- return result;
-}
-
-
-var _DoImages = function(text) {
-//
-// Turn Markdown image shortcuts into <img> tags.
-//
-
- //
- // First, handle reference-style labeled images: ![alt text][id]
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- !\[
- (.*?) // alt text = $2
- \]
-
- [ ]? // one optional space
- (?:\n[ ]*)? // one optional newline followed by spaces
-
- \[
- (.*?) // id = $3
- \]
- )()()()() // pad rest of backreferences
- /g,writeImageTag);
- */
- text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag);
-
- //
- // Next, handle inline images: 
- // Don't forget: encode * and _
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- !\[
- (.*?) // alt text = $2
- \]
- \s? // One optional whitespace character
- \( // literal paren
- [ \t]*
- () // no id, so leave $3 empty
- <?(\S+?)>? // src url = $4
- [ \t]*
- ( // $5
- (['"]) // quote char = $6
- (.*?) // title = $7
- \6 // matching quote
- [ \t]*
- )? // title is optional
- \)
- )
- /g,writeImageTag);
- */
- text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag);
-
- return text;
-}
-
-var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
- var whole_match = m1;
- var alt_text = m2;
- var link_id = m3.toLowerCase();
- var url = m4;
- var title = m7;
-
- if (!title) title = "";
-
- if (url == "") {
- if (link_id == "") {
- // lower-case and turn embedded newlines into spaces
- link_id = alt_text.toLowerCase().replace(/ ?\n/g," ");
- }
- url = "#"+link_id;
-
- if (g_urls[link_id] != undefined) {
- url = g_urls[link_id];
- if (g_titles[link_id] != undefined) {
- title = g_titles[link_id];
- }
- }
- else {
- return whole_match;
- }
- }
-
- alt_text = alt_text.replace(/"/g,""");
- url = escapeCharacters(url,"*_");
- var result = "<img src=\"" + url + "\" alt=\"" + alt_text + "\"";
-
- // attacklab: Markdown.pl adds empty title attributes to images.
- // Replicate this bug.
-
- //if (title != "") {
- title = title.replace(/"/g,""");
- title = escapeCharacters(title,"*_");
- result += " title=\"" + title + "\"";
- //}
-
- result += " />";
-
- return result;
-}
-
-
-var _DoHeaders = function(text) {
-
- // Setext-style headers:
- // Header 1
- // ========
- //
- // Header 2
- // --------
- //
- text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,
- function(wholeMatch,m1){return hashBlock('<h1 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h1>");});
-
- text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,
- function(matchFound,m1){return hashBlock('<h2 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h2>");});
-
- // atx-style headers:
- // # Header 1
- // ## Header 2
- // ## Header 2 with closing hashes ##
- // ...
- // ###### Header 6
- //
-
- /*
- text = text.replace(/
- ^(\#{1,6}) // $1 = string of #'s
- [ \t]*
- (.+?) // $2 = Header text
- [ \t]*
- \#* // optional closing #'s (not counted)
- \n+
- /gm, function() {...});
- */
-
- text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
- function(wholeMatch,m1,m2) {
- var h_level = m1.length;
- return hashBlock("<h" + h_level + ' id="' + headerId(m2) + '">' + _RunSpanGamut(m2) + "</h" + h_level + ">");
- });
-
- function headerId(m) {
- return m.replace(/[^\w]/g, '').toLowerCase();
- }
- return text;
-}
-
-// This declaration keeps Dojo compressor from outputting garbage:
-var _ProcessListItems;
-
-var _DoLists = function(text) {
-//
-// Form HTML ordered (numbered) and unordered (bulleted) lists.
-//
-
- // attacklab: add sentinel to hack around khtml/safari bug:
- // http://bugs.webkit.org/show_bug.cgi?id=11231
- text += "~0";
-
- // Re-usable pattern to match any entirel ul or ol list:
-
- /*
- var whole_list = /
- ( // $1 = whole list
- ( // $2
- [ ]{0,3} // attacklab: g_tab_width - 1
- ([*+-]|\d+[.]) // $3 = first list item marker
- [ \t]+
- )
- [^\r]+?
- ( // $4
- ~0 // sentinel for workaround; should be $
- |
- \n{2,}
- (?=\S)
- (?! // Negative lookahead for another list item marker
- [ \t]*
- (?:[*+-]|\d+[.])[ \t]+
- )
- )
- )/g
- */
- var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
-
- if (g_list_level) {
- text = text.replace(whole_list,function(wholeMatch,m1,m2) {
- var list = m1;
- var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol";
-
- // Turn double returns into triple returns, so that we can make a
- // paragraph for the last item in a list, if necessary:
- list = list.replace(/\n{2,}/g,"\n\n\n");;
- var result = _ProcessListItems(list);
-
- // Trim any trailing whitespace, to put the closing `</$list_type>`
- // up on the preceding line, to get it past the current stupid
- // HTML block parser. This is a hack to work around the terrible
- // hack that is the HTML block parser.
- result = result.replace(/\s+$/,"");
- result = "<"+list_type+">" + result + "</"+list_type+">\n";
- return result;
- });
- } else {
- whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
- text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) {
- var runup = m1;
- var list = m2;
-
- var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol";
- // Turn double returns into triple returns, so that we can make a
- // paragraph for the last item in a list, if necessary:
- var list = list.replace(/\n{2,}/g,"\n\n\n");;
- var result = _ProcessListItems(list);
- result = runup + "<"+list_type+">\n" + result + "</"+list_type+">\n";
- return result;
- });
- }
-
- // attacklab: strip sentinel
- text = text.replace(/~0/,"");
-
- return text;
-}
-
-_ProcessListItems = function(list_str) {
-//
-// Process the contents of a single ordered or unordered list, splitting it
-// into individual list items.
-//
- // The $g_list_level global keeps track of when we're inside a list.
- // Each time we enter a list, we increment it; when we leave a list,
- // we decrement. If it's zero, we're not in a list anymore.
- //
- // We do this because when we're not inside a list, we want to treat
- // something like this:
- //
- // I recommend upgrading to version
- // 8. Oops, now this line is treated
- // as a sub-list.
- //
- // As a single paragraph, despite the fact that the second line starts
- // with a digit-period-space sequence.
- //
- // Whereas when we're inside a list (or sub-list), that line will be
- // treated as the start of a sub-list. What a kludge, huh? This is
- // an aspect of Markdown's syntax that's hard to parse perfectly
- // without resorting to mind-reading. Perhaps the solution is to
- // change the syntax rules such that sub-lists must start with a
- // starting cardinal number; e.g. "1." or "a.".
-
- g_list_level++;
-
- // trim trailing blank lines:
- list_str = list_str.replace(/\n{2,}$/,"\n");
-
- // attacklab: add sentinel to emulate \z
- list_str += "~0";
-
- /*
- list_str = list_str.replace(/
- (\n)? // leading line = $1
- (^[ \t]*) // leading whitespace = $2
- ([*+-]|\d+[.]) [ \t]+ // list marker = $3
- ([^\r]+? // list item text = $4
- (\n{1,2}))
- (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+))
- /gm, function(){...});
- */
- list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
- function(wholeMatch,m1,m2,m3,m4){
- var item = m4;
- var leading_line = m1;
- var leading_space = m2;
-
- if (leading_line || (item.search(/\n{2,}/)>-1)) {
- item = _RunBlockGamut(_Outdent(item));
- }
- else {
- // Recursion for sub-lists:
- item = _DoLists(_Outdent(item));
- item = item.replace(/\n$/,""); // chomp(item)
- item = _RunSpanGamut(item);
- }
-
- return "<li>" + item + "</li>\n";
- }
- );
-
- // attacklab: strip sentinel
- list_str = list_str.replace(/~0/g,"");
-
- g_list_level--;
- return list_str;
-}
-
-
-var _DoCodeBlocks = function(text) {
-//
-// Process Markdown `<pre><code>` blocks.
-//
-
- /*
- text = text.replace(text,
- /(?:\n\n|^)
- ( // $1 = the code block -- one or more lines, starting with a space/tab
- (?:
- (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
- .*\n+
- )+
- )
- (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
- /g,function(){...});
- */
-
- // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
- text += "~0";
-
- text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
- function(wholeMatch,m1,m2) {
- var codeblock = m1;
- var nextChar = m2;
-
- codeblock = _EncodeCode( _Outdent(codeblock));
- codeblock = _Detab(codeblock);
- codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
- codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
-
- codeblock = "<pre><code>" + codeblock + "\n</code></pre>";
-
- return hashBlock(codeblock) + nextChar;
- }
- );
-
- // attacklab: strip sentinel
- text = text.replace(/~0/,"");
-
- return text;
-}
-
-var hashBlock = function(text) {
- text = text.replace(/(^\n+|\n+$)/g,"");
- return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n";
-}
-
-
-var _DoCodeSpans = function(text) {
-//
-// * Backtick quotes are used for <code></code> spans.
-//
-// * You can use multiple backticks as the delimiters if you want to
-// include literal backticks in the code span. So, this input:
-//
-// Just type ``foo `bar` baz`` at the prompt.
-//
-// Will translate to:
-//
-// <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
-//
-// There's no arbitrary limit to the number of backticks you
-// can use as delimters. If you need three consecutive backticks
-// in your code, use four for delimiters, etc.
-//
-// * You can use spaces to get literal backticks at the edges:
-//
-// ... type `` `bar` `` ...
-//
-// Turns to:
-//
-// ... type <code>`bar`</code> ...
-//
-
- /*
- text = text.replace(/
- (^|[^\\]) // Character before opening ` can't be a backslash
- (`+) // $2 = Opening run of `
- ( // $3 = The code block
- [^\r]*?
- [^`] // attacklab: work around lack of lookbehind
- )
- \2 // Matching closer
- (?!`)
- /gm, function(){...});
- */
-
- text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
- function(wholeMatch,m1,m2,m3,m4) {
- var c = m3;
- c = c.replace(/^([ \t]*)/g,""); // leading whitespace
- c = c.replace(/[ \t]*$/g,""); // trailing whitespace
- c = _EncodeCode(c);
- return m1+"<code>"+c+"</code>";
- });
-
- return text;
-}
-
-
-var _EncodeCode = function(text) {
-//
-// Encode/escape certain characters inside Markdown code runs.
-// The point is that in code, these characters are literals,
-// and lose their special Markdown meanings.
-//
- // Encode all ampersands; HTML entities are not
- // entities within a Markdown code span.
- text = text.replace(/&/g,"&");
-
- // Do the angle bracket song and dance:
- text = text.replace(/</g,"<");
- text = text.replace(/>/g,">");
-
- // Now, escape characters that are magic in Markdown:
- text = escapeCharacters(text,"\*_{}[]\\",false);
-
-// jj the line above breaks this:
-//---
-
-//* Item
-
-// 1. Subitem
-
-// special char: *
-//---
-
- return text;
-}
-
-
-var _DoItalicsAndBold = function(text) {
-
- // <strong> must go first:
- text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
- "<strong>$2</strong>");
-
- text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,
- "<em>$2</em>");
-
- return text;
-}
-
-
-var _DoBlockQuotes = function(text) {
-
- /*
- text = text.replace(/
- ( // Wrap whole match in $1
- (
- ^[ \t]*>[ \t]? // '>' at the start of a line
- .+\n // rest of the first line
- (.+\n)* // subsequent consecutive lines
- \n* // blanks
- )+
- )
- /gm, function(){...});
- */
-
- text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
- function(wholeMatch,m1) {
- var bq = m1;
-
- // attacklab: hack around Konqueror 3.5.4 bug:
- // "----------bug".replace(/^-/g,"") == "bug"
-
- bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting
-
- // attacklab: clean up hack
- bq = bq.replace(/~0/g,"");
-
- bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines
- bq = _RunBlockGamut(bq); // recurse
-
- bq = bq.replace(/(^|\n)/g,"$1 ");
- // These leading spaces screw with <pre> content, so we need to fix that:
- bq = bq.replace(
- /(\s*<pre>[^\r]+?<\/pre>)/gm,
- function(wholeMatch,m1) {
- var pre = m1;
- // attacklab: hack around Konqueror 3.5.4 bug:
- pre = pre.replace(/^ /mg,"~0");
- pre = pre.replace(/~0/g,"");
- return pre;
- });
-
- return hashBlock("<blockquote>\n" + bq + "\n</blockquote>");
- });
- return text;
-}
-
-
-var _FormParagraphs = function(text) {
-//
-// Params:
-// $text - string to process with html <p> tags
-//
-
- // Strip leading and trailing lines:
- text = text.replace(/^\n+/g,"");
- text = text.replace(/\n+$/g,"");
-
- var grafs = text.split(/\n{2,}/g);
- var grafsOut = new Array();
-
- //
- // Wrap <p> tags.
- //
- var end = grafs.length;
- for (var i=0; i<end; i++) {
- var str = grafs[i];
-
- // if this is an HTML marker, copy it
- if (str.search(/~K(\d+)K/g) >= 0) {
- grafsOut.push(str);
- }
- else if (str.search(/\S/) >= 0) {
- str = _RunSpanGamut(str);
- str = str.replace(/^([ \t]*)/g,"<p>");
- str += "</p>"
- grafsOut.push(str);
- }
-
- }
-
- //
- // Unhashify HTML blocks
- //
- end = grafsOut.length;
- for (var i=0; i<end; i++) {
- // if this is a marker for an html block...
- while (grafsOut[i].search(/~K(\d+)K/) >= 0) {
- var blockText = g_html_blocks[RegExp.$1];
- blockText = blockText.replace(/\$/g,"$$$$"); // Escape any dollar signs
- grafsOut[i] = grafsOut[i].replace(/~K\d+K/,blockText);
- }
- }
-
- return grafsOut.join("\n\n");
-}
-
-
-var _EncodeAmpsAndAngles = function(text) {
-// Smart processing for ampersands and angle brackets that need to be encoded.
-
- // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
- // http://bumppo.net/projects/amputator/
- text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&");
-
- // Encode naked <'s
- text = text.replace(/<(?![a-z\/?\$!])/gi,"<");
-
- return text;
-}
-
-
-var _EncodeBackslashEscapes = function(text) {
-//
-// Parameter: String.
-// Returns: The string, with after processing the following backslash
-// escape sequences.
-//
-
- // attacklab: The polite way to do this is with the new
- // escapeCharacters() function:
- //
- // text = escapeCharacters(text,"\\",true);
- // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
- //
- // ...but we're sidestepping its use of the (slow) RegExp constructor
- // as an optimization for Firefox. This function gets called a LOT.
-
- text = text.replace(/\\(\\)/g,escapeCharacters_callback);
- text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback);
- return text;
-}
-
-
-var _DoAutoLinks = function(text) {
-
- text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"<a href=\"$1\">$1</a>");
-
- // Email addresses: <ad...@domain.foo>
-
- /*
- text = text.replace(/
- <
- (?:mailto:)?
- (
- [-.\w]+
- \@
- [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
- )
- >
- /gi, _DoAutoLinks_callback());
- */
- text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
- function(wholeMatch,m1) {
- return _EncodeEmailAddress( _UnescapeSpecialChars(m1) );
- }
- );
-
- return text;
-}
-
-
-var _EncodeEmailAddress = function(addr) {
-//
-// Input: an email address, e.g. "foo@example.com"
-//
-// Output: the email address as a mailto link, with each character
-// of the address encoded as either a decimal or hex entity, in
-// the hopes of foiling most address harvesting spam bots. E.g.:
-//
-// <a href="mailto:foo@e
-// xample.com">foo
-// @example.com</a>
-//
-// Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
-// mailing list: <http://tinyurl.com/yu7ue>
-//
-
- // attacklab: why can't javascript speak hex?
- function char2hex(ch) {
- var hexDigits = '0123456789ABCDEF';
- var dec = ch.charCodeAt(0);
- return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15));
- }
-
- var encode = [
- function(ch){return "&#"+ch.charCodeAt(0)+";";},
- function(ch){return "&#x"+char2hex(ch)+";";},
- function(ch){return ch;}
- ];
-
- addr = "mailto:" + addr;
-
- addr = addr.replace(/./g, function(ch) {
- if (ch == "@") {
- // this *must* be encoded. I insist.
- ch = encode[Math.floor(Math.random()*2)](ch);
- } else if (ch !=":") {
- // leave ':' alone (to spot mailto: later)
- var r = Math.random();
- // roughly 10% raw, 45% hex, 45% dec
- ch = (
- r > .9 ? encode[2](ch) :
- r > .45 ? encode[1](ch) :
- encode[0](ch)
- );
- }
- return ch;
- });
-
- addr = "<a href=\"" + addr + "\">" + addr + "</a>";
- addr = addr.replace(/">.+:/g,"\">"); // strip the mailto: from the visible part
-
- return addr;
-}
-
-
-var _UnescapeSpecialChars = function(text) {
-//
-// Swap back in all the special characters we've hidden.
-//
- text = text.replace(/~E(\d+)E/g,
- function(wholeMatch,m1) {
- var charCodeToReplace = parseInt(m1);
- return String.fromCharCode(charCodeToReplace);
- }
- );
- return text;
-}
-
-
-var _Outdent = function(text) {
-//
-// Remove one level of line-leading tabs or spaces
-//
-
- // attacklab: hack around Konqueror 3.5.4 bug:
- // "----------bug".replace(/^-/g,"") == "bug"
-
- text = text.replace(/^(\t|[ ]{1,4})/gm,"~0"); // attacklab: g_tab_width
-
- // attacklab: clean up hack
- text = text.replace(/~0/g,"")
-
- return text;
-}
-
-var _Detab = function(text) {
-// attacklab: Detab's completely rewritten for speed.
-// In perl we could fix it by anchoring the regexp with \G.
-// In javascript we're less fortunate.
-
- // expand first n-1 tabs
- text = text.replace(/\t(?=\t)/g," "); // attacklab: g_tab_width
-
- // replace the nth with two sentinels
- text = text.replace(/\t/g,"~A~B");
-
- // use the sentinel to anchor our regex so it doesn't explode
- text = text.replace(/~B(.+?)~A/g,
- function(wholeMatch,m1,m2) {
- var leadingText = m1;
- var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width
-
- // there *must* be a better way to do this:
- for (var i=0; i<numSpaces; i++) leadingText+=" ";
-
- return leadingText;
- }
- );
-
- // clean up sentinels
- text = text.replace(/~A/g," "); // attacklab: g_tab_width
- text = text.replace(/~B/g,"");
-
- return text;
-}
-
-
-//
-// attacklab: Utility functions
-//
-
-
-var escapeCharacters = function(text, charsToEscape, afterBackslash) {
- // First we have to escape the escape characters so that
- // we can build a character class out of them
- var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g,"\\$1") + "])";
-
- if (afterBackslash) {
- regexString = "\\\\" + regexString;
- }
-
- var regex = new RegExp(regexString,"g");
- text = text.replace(regex,escapeCharacters_callback);
-
- return text;
-}
-
-
-var escapeCharacters_callback = function(wholeMatch,m1) {
- var charCodeToEscape = m1.charCodeAt(0);
- return "~E"+charCodeToEscape+"E";
-}
-
-} // end of Showdown.converter
-
-// export
+//
+// showdown.js -- A javascript port of Markdown.
+//
+// Copyright (c) 2007 John Fraser.
+//
+// Original Markdown Copyright (c) 2004-2005 John Gruber
+// <http://daringfireball.net/projects/markdown/>
+//
+// Redistributable under a BSD-style open source license.
+// See license.txt for more information.
+//
+// The full source distribution is at:
+//
+// A A L
+// T C A
+// T K B
+//
+// <http://www.attacklab.net/>
+//
+
+//
+// Wherever possible, Showdown is a straight, line-by-line port
+// of the Perl version of Markdown.
+//
+// This is not a normal parser design; it's basically just a
+// series of string substitutions. It's hard to read and
+// maintain this way, but keeping Showdown close to the original
+// design makes it easier to port new features.
+//
+// More importantly, Showdown behaves like markdown.pl in most
+// edge cases. So web applications can do client-side preview
+// in Javascript, and then build identical HTML on the server.
+//
+// This port needs the new RegExp functionality of ECMA 262,
+// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers
+// should do fine. Even with the new regular expression features,
+// We do a lot of work to emulate Perl's regex functionality.
+// The tricky changes in this file mostly have the "attacklab:"
+// label. Major or self-explanatory changes don't.
+//
+// Smart diff tools like Araxis Merge will be able to match up
+// this file with markdown.pl in a useful way. A little tweaking
+// helps: in a copy of markdown.pl, replace "#" with "//" and
+// replace "$text" with "text". Be sure to ignore whitespace
+// and line endings.
+//
+
+
+//
+// Showdown usage:
+//
+// var text = "Markdown *rocks*.";
+//
+// var converter = new Showdown.converter();
+// var html = converter.makeHtml(text);
+//
+// alert(html);
+//
+// Note: move the sample code to the bottom of this
+// file before uncommenting it.
+//
+
+
+//
+// Showdown namespace
+//
+var Showdown = {};
+
+//
+// converter
+//
+// Wraps all "globals" so that the only thing
+// exposed is makeHtml().
+//
+Showdown.converter = function() {
+
+//
+// Globals:
+//
+
+// Global hashes, used by various utility routines
+var g_urls;
+var g_titles;
+var g_html_blocks;
+
+// Used to track when we're inside an ordered or unordered list
+// (see _ProcessListItems() for details):
+var g_list_level = 0;
+
+
+this.makeHtml = function(text) {
+//
+// Main function. The order in which other subs are called here is
+// essential. Link and image substitutions need to happen before
+// _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the <a>
+// and <img> tags get encoded.
+//
+
+ // Clear the global hashes. If we don't clear these, you get conflicts
+ // from other articles when generating a page which contains more than
+ // one article (e.g. an index page that shows the N most recent
+ // articles):
+ g_urls = new Array();
+ g_titles = new Array();
+ g_html_blocks = new Array();
+
+ // attacklab: Replace ~ with ~T
+ // This lets us use tilde as an escape char to avoid md5 hashes
+ // The choice of character is arbitray; anything that isn't
+ // magic in Markdown will work.
+ text = text.replace(/~/g,"~T");
+
+ // attacklab: Replace $ with ~D
+ // RegExp interprets $ as a special character
+ // when it's in a replacement string
+ text = text.replace(/\$/g,"~D");
+
+ // Standardize line endings
+ text = text.replace(/\r\n/g,"\n"); // DOS to Unix
+ text = text.replace(/\r/g,"\n"); // Mac to Unix
+
+ // Make sure text begins and ends with a couple of newlines:
+ text = "\n\n" + text + "\n\n";
+
+ // Convert all tabs to spaces.
+ text = _Detab(text);
+
+ // Strip any lines consisting only of spaces and tabs.
+ // This makes subsequent regexen easier to write, because we can
+ // match consecutive blank lines with /\n+/ instead of something
+ // contorted like /[ \t]*\n+/ .
+ text = text.replace(/^[ \t]+$/mg,"");
+
+ // Turn block-level HTML blocks into hash entries
+ text = _HashHTMLBlocks(text);
+
+ // Strip link definitions, store in hashes.
+ text = _StripLinkDefinitions(text);
+
+ text = _RunBlockGamut(text);
+
+ text = _UnescapeSpecialChars(text);
+
+ // attacklab: Restore dollar signs
+ text = text.replace(/~D/g,"$$");
+
+ // attacklab: Restore tildes
+ text = text.replace(/~T/g,"~");
+
+ return text;
+}
+
+
+var _StripLinkDefinitions = function(text) {
+//
+// Strips link definitions from text, stores the URLs and titles in
+// hash references.
+//
+
+ // Link defs are in the form: ^[id]: url "optional title"
+
+ /*
+ var text = text.replace(/
+ ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1
+ [ \t]*
+ \n? // maybe *one* newline
+ [ \t]*
+ <?(\S+?)>? // url = $2
+ [ \t]*
+ \n? // maybe one newline
+ [ \t]*
+ (?:
+ (\n*) // any lines skipped = $3 attacklab: lookbehind removed
+ ["(]
+ (.+?) // title = $4
+ [")]
+ [ \t]*
+ )? // title is optional
+ (?:\n+|$)
+ /gm,
+ function(){...});
+ */
+ var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,
+ function (wholeMatch,m1,m2,m3,m4) {
+ m1 = m1.toLowerCase();
+ g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive
+ if (m3) {
+ // Oops, found blank lines, so it's not a title.
+ // Put back the parenthetical statement we stole.
+ return m3+m4;
+ } else if (m4) {
+ g_titles[m1] = m4.replace(/"/g,""");
+ }
+
+ // Completely remove the definition from the text
+ return "";
+ }
+ );
+
+ return text;
+}
+
+
+var _HashHTMLBlocks = function(text) {
+ // attacklab: Double up blank lines to reduce lookaround
+ text = text.replace(/\n/g,"\n\n");
+
+ // Hashify HTML blocks:
+ // We only want to do this for block-level HTML tags, such as headers,
+ // lists, and tables. That's because we still want to wrap <p>s around
+ // "paragraphs" that are wrapped in non-block-level tags, such as anchors,
+ // phrase emphasis, and spans. The list of tags we're looking for is
+ // hard-coded:
+ var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del"
+ var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math"
+
+ // First, look for nested blocks, e.g.:
+ // <div>
+ // <div>
+ // tags for inner block must be indented.
+ // </div>
+ // </div>
+ //
+ // The outermost tags must start at the left margin for this to match, and
+ // the inner nested divs must be indented.
+ // We need to do this before the next, more liberal match, because the next
+ // match will start at the first `<div>` and stop at the first `</div>`.
+
+ // attacklab: This regex can be expensive when it fails.
+ /*
+ var text = text.replace(/
+ ( // save in $1
+ ^ // start of line (with /m)
+ <($block_tags_a) // start tag = $2
+ \b // word break
+ // attacklab: hack around khtml/pcre bug...
+ [^\r]*?\n // any number of lines, minimally matching
+ </\2> // the matching end tag
+ [ \t]* // trailing spaces/tabs
+ (?=\n+) // followed by a newline
+ ) // attacklab: there are sentinel newlines at end of document
+ /gm,function(){...}};
+ */
+ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement);
+
+ //
+ // Now match more liberally, simply from `\n<tag>` to `</tag>\n`
+ //
+
+ /*
+ var text = text.replace(/
+ ( // save in $1
+ ^ // start of line (with /m)
+ <($block_tags_b) // start tag = $2
+ \b // word break
+ // attacklab: hack around khtml/pcre bug...
+ [^\r]*? // any number of lines, minimally matching
+ .*</\2> // the matching end tag
+ [ \t]* // trailing spaces/tabs
+ (?=\n+) // followed by a newline
+ ) // attacklab: there are sentinel newlines at end of document
+ /gm,function(){...}};
+ */
+ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);
+
+ // Special case just for <hr />. It was easier to make a special case than
+ // to make the other regex more complicated.
+
+ /*
+ text = text.replace(/
+ ( // save in $1
+ \n\n // Starting after a blank line
+ [ ]{0,3}
+ (<(hr) // start tag = $2
+ \b // word break
+ ([^<>])*? //
+ \/?>) // the matching end tag
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // Special case for standalone HTML comments:
+
+ /*
+ text = text.replace(/
+ ( // save in $1
+ \n\n // Starting after a blank line
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ <!
+ (--[^\r]*?--\s*)+
+ >
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // PHP and ASP-style processor instructions (<?...?> and <%...%>)
+
+ /*
+ text = text.replace(/
+ (?:
+ \n\n // Starting after a blank line
+ )
+ ( // save in $1
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ (?:
+ <([?%]) // $2
+ [^\r]*?
+ \2>
+ )
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // attacklab: Undo double lines (see comment at top of this function)
+ text = text.replace(/\n\n/g,"\n");
+ return text;
+}
+
+var hashElement = function(wholeMatch,m1) {
+ var blockText = m1;
+
+ // Undo double lines
+ blockText = blockText.replace(/\n\n/g,"\n");
+ blockText = blockText.replace(/^\n/,"");
+
+ // strip trailing blank lines
+ blockText = blockText.replace(/\n+$/g,"");
+
+ // Replace the element text with a marker ("~KxK" where x is its key)
+ blockText = "\n\n~K" + (g_html_blocks.push(blockText)-1) + "K\n\n";
+
+ return blockText;
+};
+
+var _RunBlockGamut = function(text) {
+//
+// These are all the transformations that form block-level
+// tags like paragraphs, headers, and list items.
+//
+ text = _DoHeaders(text);
+
+ // Do Horizontal Rules:
+ var key = hashBlock("<hr />");
+ text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key);
+ text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key);
+ text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
+
+ text = _DoLists(text);
+ text = _DoCodeBlocks(text);
+ text = _DoBlockQuotes(text);
+
+ // We already ran _HashHTMLBlocks() before, in Markdown(), but that
+ // was to escape raw HTML in the original Markdown source. This time,
+ // we're escaping the markup we've just created, so that we don't wrap
+ // <p> tags around block-level tags.
+ text = _HashHTMLBlocks(text);
+ text = _FormParagraphs(text);
+
+ return text;
+}
+
+
+var _RunSpanGamut = function(text) {
+//
+// These are all the transformations that occur *within* block-level
+// tags like paragraphs, headers, and list items.
+//
+
+ text = _DoCodeSpans(text);
+ text = _EscapeSpecialCharsWithinTagAttributes(text);
+ text = _EncodeBackslashEscapes(text);
+
+ // Process anchor and image tags. Images must come first,
+ // because ![foo][f] looks like an anchor.
+ text = _DoImages(text);
+ text = _DoAnchors(text);
+
+ // Make links out of things like `<http://example.com/>`
+ // Must come after _DoAnchors(), because you can use < and >
+ // delimiters in inline links like [this](<url>).
+ text = _DoAutoLinks(text);
+ text = _EncodeAmpsAndAngles(text);
+ text = _DoItalicsAndBold(text);
+
+ // Do hard breaks:
+ text = text.replace(/ +\n/g," <br />\n");
+
+ return text;
+}
+
+var _EscapeSpecialCharsWithinTagAttributes = function(text) {
+//
+// Within tags -- meaning between < and > -- encode [\ ` * _] so they
+// don't conflict with their use in Markdown for code, italics and strong.
+//
+
+ // Build a regex to find HTML tags and comments. See Friedl's
+ // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
+ var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;
+
+ text = text.replace(regex, function(wholeMatch) {
+ var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`");
+ tag = escapeCharacters(tag,"\\`*_");
+ return tag;
+ });
+
+ return text;
+}
+
+var _DoAnchors = function(text) {
+//
+// Turn Markdown link shortcuts into XHTML <a> tags.
+//
+ //
+ // First, handle reference-style links: [link text] [id]
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ (
+ (?:
+ \[[^\]]*\] // allow brackets nested one level
+ |
+ [^\[] // or anything else
+ )*
+ )
+ \]
+
+ [ ]? // one optional space
+ (?:\n[ ]*)? // one optional newline followed by spaces
+
+ \[
+ (.*?) // id = $3
+ \]
+ )()()()() // pad remaining backreferences
+ /g,_DoAnchors_callback);
+ */
+ text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag);
+
+ //
+ // Next, inline-style links: [link text](url "optional title")
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ (
+ (?:
+ \[[^\]]*\] // allow brackets nested one level
+ |
+ [^\[\]] // or anything else
+ )
+ )
+ \]
+ \( // literal paren
+ [ \t]*
+ () // no id, so leave $3 empty
+ <?(.*?)>? // href = $4
+ [ \t]*
+ ( // $5
+ (['"]) // quote char = $6
+ (.*?) // Title = $7
+ \6 // matching quote
+ [ \t]* // ignore any spaces/tabs between closing quote and )
+ )? // title is optional
+ \)
+ )
+ /g,writeAnchorTag);
+ */
+ text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag);
+
+ //
+ // Last, handle reference-style shortcuts: [link text]
+ // These must come last in case you've also got [link test][1]
+ // or [link test](/foo)
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ ([^\[\]]+) // link text = $2; can't contain '[' or ']'
+ \]
+ )()()()()() // pad rest of backreferences
+ /g, writeAnchorTag);
+ */
+ text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
+
+ return text;
+}
+
+var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
+ if (m7 == undefined) m7 = "";
+ var whole_match = m1;
+ var link_text = m2;
+ var link_id = m3.toLowerCase();
+ var url = m4;
+ var title = m7;
+
+ if (url == "") {
+ if (link_id == "") {
+ // lower-case and turn embedded newlines into spaces
+ link_id = link_text.toLowerCase().replace(/ ?\n/g," ");
+ }
+ url = "#"+link_id;
+
+ if (g_urls[link_id] != undefined) {
+ url = g_urls[link_id];
+ if (g_titles[link_id] != undefined) {
+ title = g_titles[link_id];
+ }
+ }
+ else {
+ if (whole_match.search(/\(\s*\)$/m)>-1) {
+ // Special case for explicit empty url
+ url = "";
+ } else {
+ return whole_match;
+ }
+ }
+ }
+
+ url = escapeCharacters(url,"*_");
+ var result = "<a href=\"" + url + "\"";
+
+ if (title != "") {
+ title = title.replace(/"/g,""");
+ title = escapeCharacters(title,"*_");
+ result += " title=\"" + title + "\"";
+ }
+
+ result += ">" + link_text + "</a>";
+
+ return result;
+}
+
+
+var _DoImages = function(text) {
+//
+// Turn Markdown image shortcuts into <img> tags.
+//
+
+ //
+ // First, handle reference-style labeled images: ![alt text][id]
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ !\[
+ (.*?) // alt text = $2
+ \]
+
+ [ ]? // one optional space
+ (?:\n[ ]*)? // one optional newline followed by spaces
+
+ \[
+ (.*?) // id = $3
+ \]
+ )()()()() // pad rest of backreferences
+ /g,writeImageTag);
+ */
+ text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag);
+
+ //
+ // Next, handle inline images: 
+ // Don't forget: encode * and _
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ !\[
+ (.*?) // alt text = $2
+ \]
+ \s? // One optional whitespace character
+ \( // literal paren
+ [ \t]*
+ () // no id, so leave $3 empty
+ <?(\S+?)>? // src url = $4
+ [ \t]*
+ ( // $5
+ (['"]) // quote char = $6
+ (.*?) // title = $7
+ \6 // matching quote
+ [ \t]*
+ )? // title is optional
+ \)
+ )
+ /g,writeImageTag);
+ */
+ text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag);
+
+ return text;
+}
+
+var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
+ var whole_match = m1;
+ var alt_text = m2;
+ var link_id = m3.toLowerCase();
+ var url = m4;
+ var title = m7;
+
+ if (!title) title = "";
+
+ if (url == "") {
+ if (link_id == "") {
+ // lower-case and turn embedded newlines into spaces
+ link_id = alt_text.toLowerCase().replace(/ ?\n/g," ");
+ }
+ url = "#"+link_id;
+
+ if (g_urls[link_id] != undefined) {
+ url = g_urls[link_id];
+ if (g_titles[link_id] != undefined) {
+ title = g_titles[link_id];
+ }
+ }
+ else {
+ return whole_match;
+ }
+ }
+
+ alt_text = alt_text.replace(/"/g,""");
+ url = escapeCharacters(url,"*_");
+ var result = "<img src=\"" + url + "\" alt=\"" + alt_text + "\"";
+
+ // attacklab: Markdown.pl adds empty title attributes to images.
+ // Replicate this bug.
+
+ //if (title != "") {
+ title = title.replace(/"/g,""");
+ title = escapeCharacters(title,"*_");
+ result += " title=\"" + title + "\"";
+ //}
+
+ result += " />";
+
+ return result;
+}
+
+
+var _DoHeaders = function(text) {
+
+ // Setext-style headers:
+ // Header 1
+ // ========
+ //
+ // Header 2
+ // --------
+ //
+ text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,
+ function(wholeMatch,m1){return hashBlock('<h1 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h1>");});
+
+ text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,
+ function(matchFound,m1){return hashBlock('<h2 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h2>");});
+
+ // atx-style headers:
+ // # Header 1
+ // ## Header 2
+ // ## Header 2 with closing hashes ##
+ // ...
+ // ###### Header 6
+ //
+
+ /*
+ text = text.replace(/
+ ^(\#{1,6}) // $1 = string of #'s
+ [ \t]*
+ (.+?) // $2 = Header text
+ [ \t]*
+ \#* // optional closing #'s (not counted)
+ \n+
+ /gm, function() {...});
+ */
+
+ text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
+ function(wholeMatch,m1,m2) {
+ var h_level = m1.length;
+ return hashBlock("<h" + h_level + ' id="' + headerId(m2) + '">' + _RunSpanGamut(m2) + "</h" + h_level + ">");
+ });
+
+ function headerId(m) {
+ return m.replace(/[^\w]/g, '').toLowerCase();
+ }
+ return text;
+}
+
+// This declaration keeps Dojo compressor from outputting garbage:
+var _ProcessListItems;
+
+var _DoLists = function(text) {
+//
+// Form HTML ordered (numbered) and unordered (bulleted) lists.
+//
+
+ // attacklab: add sentinel to hack around khtml/safari bug:
+ // http://bugs.webkit.org/show_bug.cgi?id=11231
+ text += "~0";
+
+ // Re-usable pattern to match any entirel ul or ol list:
+
+ /*
+ var whole_list = /
+ ( // $1 = whole list
+ ( // $2
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ ([*+-]|\d+[.]) // $3 = first list item marker
+ [ \t]+
+ )
+ [^\r]+?
+ ( // $4
+ ~0 // sentinel for workaround; should be $
+ |
+ \n{2,}
+ (?=\S)
+ (?! // Negative lookahead for another list item marker
+ [ \t]*
+ (?:[*+-]|\d+[.])[ \t]+
+ )
+ )
+ )/g
+ */
+ var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
+
+ if (g_list_level) {
+ text = text.replace(whole_list,function(wholeMatch,m1,m2) {
+ var list = m1;
+ var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol";
+
+ // Turn double returns into triple returns, so that we can make a
+ // paragraph for the last item in a list, if necessary:
+ list = list.replace(/\n{2,}/g,"\n\n\n");;
+ var result = _ProcessListItems(list);
+
+ // Trim any trailing whitespace, to put the closing `</$list_type>`
+ // up on the preceding line, to get it past the current stupid
+ // HTML block parser. This is a hack to work around the terrible
+ // hack that is the HTML block parser.
+ result = result.replace(/\s+$/,"");
+ result = "<"+list_type+">" + result + "</"+list_type+">\n";
+ return result;
+ });
+ } else {
+ whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
+ text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) {
+ var runup = m1;
+ var list = m2;
+
+ var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol";
+ // Turn double returns into triple returns, so that we can make a
+ // paragraph for the last item in a list, if necessary:
+ var list = list.replace(/\n{2,}/g,"\n\n\n");;
+ var result = _ProcessListItems(list);
+ result = runup + "<"+list_type+">\n" + result + "</"+list_type+">\n";
+ return result;
+ });
+ }
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/,"");
+
+ return text;
+}
+
+_ProcessListItems = function(list_str) {
+//
+// Process the contents of a single ordered or unordered list, splitting it
+// into individual list items.
+//
+ // The $g_list_level global keeps track of when we're inside a list.
+ // Each time we enter a list, we increment it; when we leave a list,
+ // we decrement. If it's zero, we're not in a list anymore.
+ //
+ // We do this because when we're not inside a list, we want to treat
+ // something like this:
+ //
+ // I recommend upgrading to version
+ // 8. Oops, now this line is treated
+ // as a sub-list.
+ //
+ // As a single paragraph, despite the fact that the second line starts
+ // with a digit-period-space sequence.
+ //
+ // Whereas when we're inside a list (or sub-list), that line will be
+ // treated as the start of a sub-list. What a kludge, huh? This is
+ // an aspect of Markdown's syntax that's hard to parse perfectly
+ // without resorting to mind-reading. Perhaps the solution is to
+ // change the syntax rules such that sub-lists must start with a
+ // starting cardinal number; e.g. "1." or "a.".
+
+ g_list_level++;
+
+ // trim trailing blank lines:
+ list_str = list_str.replace(/\n{2,}$/,"\n");
+
+ // attacklab: add sentinel to emulate \z
+ list_str += "~0";
+
+ /*
+ list_str = list_str.replace(/
+ (\n)? // leading line = $1
+ (^[ \t]*) // leading whitespace = $2
+ ([*+-]|\d+[.]) [ \t]+ // list marker = $3
+ ([^\r]+? // list item text = $4
+ (\n{1,2}))
+ (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+))
+ /gm, function(){...});
+ */
+ list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
+ function(wholeMatch,m1,m2,m3,m4){
+ var item = m4;
+ var leading_line = m1;
+ var leading_space = m2;
+
+ if (leading_line || (item.search(/\n{2,}/)>-1)) {
+ item = _RunBlockGamut(_Outdent(item));
+ }
+ else {
+ // Recursion for sub-lists:
+ item = _DoLists(_Outdent(item));
+ item = item.replace(/\n$/,""); // chomp(item)
+ item = _RunSpanGamut(item);
+ }
+
+ return "<li>" + item + "</li>\n";
+ }
+ );
+
+ // attacklab: strip sentinel
+ list_str = list_str.replace(/~0/g,"");
+
+ g_list_level--;
+ return list_str;
+}
+
+
+var _DoCodeBlocks = function(text) {
+//
+// Process Markdown `<pre><code>` blocks.
+//
+
+ /*
+ text = text.replace(text,
+ /(?:\n\n|^)
+ ( // $1 = the code block -- one or more lines, starting with a space/tab
+ (?:
+ (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
+ .*\n+
+ )+
+ )
+ (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
+ /g,function(){...});
+ */
+
+ // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
+ text += "~0";
+
+ text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
+ function(wholeMatch,m1,m2) {
+ var codeblock = m1;
+ var nextChar = m2;
+
+ codeblock = _EncodeCode( _Outdent(codeblock));
+ codeblock = _Detab(codeblock);
+ codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
+ codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
+
+ codeblock = "<pre><code>" + codeblock + "\n</code></pre>";
+
+ return hashBlock(codeblock) + nextChar;
+ }
+ );
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/,"");
+
+ return text;
+}
+
+var hashBlock = function(text) {
+ text = text.replace(/(^\n+|\n+$)/g,"");
+ return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n";
+}
+
+
+var _DoCodeSpans = function(text) {
+//
+// * Backtick quotes are used for <code></code> spans.
+//
+// * You can use multiple backticks as the delimiters if you want to
+// include literal backticks in the code span. So, this input:
+//
+// Just type ``foo `bar` baz`` at the prompt.
+//
+// Will translate to:
+//
+// <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
+//
+// There's no arbitrary limit to the number of backticks you
+// can use as delimters. If you need three consecutive backticks
+// in your code, use four for delimiters, etc.
+//
+// * You can use spaces to get literal backticks at the edges:
+//
+// ... type `` `bar` `` ...
+//
+// Turns to:
+//
+// ... type <code>`bar`</code> ...
+//
+
+ /*
+ text = text.replace(/
+ (^|[^\\]) // Character before opening ` can't be a backslash
+ (`+) // $2 = Opening run of `
+ ( // $3 = The code block
+ [^\r]*?
+ [^`] // attacklab: work around lack of lookbehind
+ )
+ \2 // Matching closer
+ (?!`)
+ /gm, function(){...});
+ */
+
+ text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
+ function(wholeMatch,m1,m2,m3,m4) {
+ var c = m3;
+ c = c.replace(/^([ \t]*)/g,""); // leading whitespace
+ c = c.replace(/[ \t]*$/g,""); // trailing whitespace
+ c = _EncodeCode(c);
+ return m1+"<code>"+c+"</code>";
+ });
+
+ return text;
+}
+
+
+var _EncodeCode = function(text) {
+//
+// Encode/escape certain characters inside Markdown code runs.
+// The point is that in code, these characters are literals,
+// and lose their special Markdown meanings.
+//
+ // Encode all ampersands; HTML entities are not
+ // entities within a Markdown code span.
+ text = text.replace(/&/g,"&");
+
+ // Do the angle bracket song and dance:
+ text = text.replace(/</g,"<");
+ text = text.replace(/>/g,">");
+
+ // Now, escape characters that are magic in Markdown:
+ text = escapeCharacters(text,"\*_{}[]\\",false);
+
+// jj the line above breaks this:
+//---
+
+//* Item
+
+// 1. Subitem
+
+// special char: *
+//---
+
+ return text;
+}
+
+
+var _DoItalicsAndBold = function(text) {
+
+ // <strong> must go first:
+ text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
+ "<strong>$2</strong>");
+
+ text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,
+ "<em>$2</em>");
+
+ return text;
+}
+
+
+var _DoBlockQuotes = function(text) {
+
+ /*
+ text = text.replace(/
+ ( // Wrap whole match in $1
+ (
+ ^[ \t]*>[ \t]? // '>' at the start of a line
+ .+\n // rest of the first line
+ (.+\n)* // subsequent consecutive lines
+ \n* // blanks
+ )+
+ )
+ /gm, function(){...});
+ */
+
+ text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
+ function(wholeMatch,m1) {
+ var bq = m1;
+
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ // "----------bug".replace(/^-/g,"") == "bug"
+
+ bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting
+
+ // attacklab: clean up hack
+ bq = bq.replace(/~0/g,"");
+
+ bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines
+ bq = _RunBlockGamut(bq); // recurse
+
+ bq = bq.replace(/(^|\n)/g,"$1 ");
+ // These leading spaces screw with <pre> content, so we need to fix that:
+ bq = bq.replace(
+ /(\s*<pre>[^\r]+?<\/pre>)/gm,
+ function(wholeMatch,m1) {
+ var pre = m1;
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ pre = pre.replace(/^ /mg,"~0");
+ pre = pre.replace(/~0/g,"");
+ return pre;
+ });
+
+ return hashBlock("<blockquote>\n" + bq + "\n</blockquote>");
+ });
+ return text;
+}
+
+
+var _FormParagraphs = function(text) {
+//
+// Params:
+// $text - string to process with html <p> tags
+//
+
+ // Strip leading and trailing lines:
+ text = text.replace(/^\n+/g,"");
+ text = text.replace(/\n+$/g,"");
+
+ var grafs = text.split(/\n{2,}/g);
+ var grafsOut = new Array();
+
+ //
+ // Wrap <p> tags.
+ //
+ var end = grafs.length;
+ for (var i=0; i<end; i++) {
+ var str = grafs[i];
+
+ // if this is an HTML marker, copy it
+ if (str.search(/~K(\d+)K/g) >= 0) {
+ grafsOut.push(str);
+ }
+ else if (str.search(/\S/) >= 0) {
+ str = _RunSpanGamut(str);
+ str = str.replace(/^([ \t]*)/g,"<p>");
+ str += "</p>"
+ grafsOut.push(str);
+ }
+
+ }
+
+ //
+ // Unhashify HTML blocks
+ //
+ end = grafsOut.length;
+ for (var i=0; i<end; i++) {
+ // if this is a marker for an html block...
+ while (grafsOut[i].search(/~K(\d+)K/) >= 0) {
+ var blockText = g_html_blocks[RegExp.$1];
+ blockText = blockText.replace(/\$/g,"$$$$"); // Escape any dollar signs
+ grafsOut[i] = grafsOut[i].replace(/~K\d+K/,blockText);
+ }
+ }
+
+ return grafsOut.join("\n\n");
+}
+
+
+var _EncodeAmpsAndAngles = function(text) {
+// Smart processing for ampersands and angle brackets that need to be encoded.
+
+ // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
+ // http://bumppo.net/projects/amputator/
+ text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&");
+
+ // Encode naked <'s
+ text = text.replace(/<(?![a-z\/?\$!])/gi,"<");
+
+ return text;
+}
+
+
+var _EncodeBackslashEscapes = function(text) {
+//
+// Parameter: String.
+// Returns: The string, with after processing the following backslash
+// escape sequences.
+//
+
+ // attacklab: The polite way to do this is with the new
+ // escapeCharacters() function:
+ //
+ // text = escapeCharacters(text,"\\",true);
+ // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
+ //
+ // ...but we're sidestepping its use of the (slow) RegExp constructor
+ // as an optimization for Firefox. This function gets called a LOT.
+
+ text = text.replace(/\\(\\)/g,escapeCharacters_callback);
+ text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback);
+ return text;
+}
+
+
+var _DoAutoLinks = function(text) {
+
+ text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"<a href=\"$1\">$1</a>");
+
+ // Email addresses: <ad...@domain.foo>
+
+ /*
+ text = text.replace(/
+ <
+ (?:mailto:)?
+ (
+ [-.\w]+
+ \@
+ [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
+ )
+ >
+ /gi, _DoAutoLinks_callback());
+ */
+ text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
+ function(wholeMatch,m1) {
+ return _EncodeEmailAddress( _UnescapeSpecialChars(m1) );
+ }
+ );
+
+ return text;
+}
+
+
+var _EncodeEmailAddress = function(addr) {
+//
+// Input: an email address, e.g. "foo@example.com"
+//
+// Output: the email address as a mailto link, with each character
+// of the address encoded as either a decimal or hex entity, in
+// the hopes of foiling most address harvesting spam bots. E.g.:
+//
+// <a href="mailto:foo@e
+// xample.com">foo
+// @example.com</a>
+//
+// Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
+// mailing list: <http://tinyurl.com/yu7ue>
+//
+
+ // attacklab: why can't javascript speak hex?
+ function char2hex(ch) {
+ var hexDigits = '0123456789ABCDEF';
+ var dec = ch.charCodeAt(0);
+ return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15));
+ }
+
+ var encode = [
+ function(ch){return "&#"+ch.charCodeAt(0)+";";},
+ function(ch){return "&#x"+char2hex(ch)+";";},
+ function(ch){return ch;}
+ ];
+
+ addr = "mailto:" + addr;
+
+ addr = addr.replace(/./g, function(ch) {
+ if (ch == "@") {
+ // this *must* be encoded. I insist.
+ ch = encode[Math.floor(Math.random()*2)](ch);
+ } else if (ch !=":") {
+ // leave ':' alone (to spot mailto: later)
+ var r = Math.random();
+ // roughly 10% raw, 45% hex, 45% dec
+ ch = (
+ r > .9 ? encode[2](ch) :
+ r > .45 ? encode[1](ch) :
+ encode[0](ch)
+ );
+ }
+ return ch;
+ });
+
+ addr = "<a href=\"" + addr + "\">" + addr + "</a>";
+ addr = addr.replace(/">.+:/g,"\">"); // strip the mailto: from the visible part
+
+ return addr;
+}
+
+
+var _UnescapeSpecialChars = function(text) {
+//
+// Swap back in all the special characters we've hidden.
+//
+ text = text.replace(/~E(\d+)E/g,
+ function(wholeMatch,m1) {
+ var charCodeToReplace = parseInt(m1);
+ return String.fromCharCode(charCodeToReplace);
+ }
+ );
+ return text;
+}
+
+
+var _Outdent = function(text) {
+//
+// Remove one level of line-leading tabs or spaces
+//
+
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ // "----------bug".replace(/^-/g,"") == "bug"
+
+ text = text.replace(/^(\t|[ ]{1,4})/gm,"~0"); // attacklab: g_tab_width
+
+ // attacklab: clean up hack
+ text = text.replace(/~0/g,"")
+
+ return text;
+}
+
+var _Detab = function(text) {
+// attacklab: Detab's completely rewritten for speed.
+// In perl we could fix it by anchoring the regexp with \G.
+// In javascript we're less fortunate.
+
+ // expand first n-1 tabs
+ text = text.replace(/\t(?=\t)/g," "); // attacklab: g_tab_width
+
+ // replace the nth with two sentinels
+ text = text.replace(/\t/g,"~A~B");
+
+ // use the sentinel to anchor our regex so it doesn't explode
+ text = text.replace(/~B(.+?)~A/g,
+ function(wholeMatch,m1,m2) {
+ var leadingText = m1;
+ var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width
+
+ // there *must* be a better way to do this:
+ for (var i=0; i<numSpaces; i++) leadingText+=" ";
+
+ return leadingText;
+ }
+ );
+
+ // clean up sentinels
+ text = text.replace(/~A/g," "); // attacklab: g_tab_width
+ text = text.replace(/~B/g,"");
+
+ return text;
+}
+
+
+//
+// attacklab: Utility functions
+//
+
+
+var escapeCharacters = function(text, charsToEscape, afterBackslash) {
+ // First we have to escape the escape characters so that
+ // we can build a character class out of them
+ var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g,"\\$1") + "])";
+
+ if (afterBackslash) {
+ regexString = "\\\\" + regexString;
+ }
+
+ var regex = new RegExp(regexString,"g");
+ text = text.replace(regex,escapeCharacters_callback);
+
+ return text;
+}
+
+
+var escapeCharacters_callback = function(wholeMatch,m1) {
+ var charCodeToEscape = m1.charCodeAt(0);
+ return "~E"+charCodeToEscape+"E";
+}
+
+} // end of Showdown.converter
+
+// export
if (typeof exports != 'undefined') exports.Showdown = Showdown;
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[05/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/LICENSE-MIT
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/LICENSE-MIT b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/LICENSE-MIT
index bc56a8a..88caf87 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/LICENSE-MIT
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/LICENSE-MIT
@@ -1,22 +1,22 @@
-Copyright (c) 2012-2014 Chris Talkington, contributors.
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+Copyright (c) 2012-2014 Chris Talkington, contributors.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/README.md b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/README.md
index 5ef812f..069afcb 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/README.md
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/README.md
@@ -1,166 +1,166 @@
-# Archiver v0.11.0 [](https://travis-ci.org/ctalkington/node-archiver)
-
-a streaming interface for archive generation
-
-[](https://nodei.co/npm/archiver/)
-
-## Install
-
-```bash
-npm install archiver --save
-```
-
-You can also use `npm install https://github.com/ctalkington/node-archiver/archive/master.tar.gz` to test upcoming versions.
-
-## Archiver
-
-#### create(format, options)
-
-Creates an Archiver instance based on the format (zip, tar, etc) passed. Parameters can be passed directly to `Archiver` constructor for convenience.
-
-#### registerFormat(format, module)
-
-Registers an archive format. Format modules are essentially transform streams with a few required methods. They will be further documented once a formal spec is in place.
-
-### Instance Methods
-
-Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) methods.
-
-#### append(input, data)
-
-Appends an input source (text string, buffer, or stream) to the instance. When the instance has received, processed, and emitted the input, the `entry` event is fired.
-
-Replaced `#addFile` in v0.5.
-
-```js
-archive.append('string', { name:'string.txt' });
-archive.append(new Buffer('string'), { name:'buffer.txt' });
-archive.append(fs.createReadStream('mydir/file.txt'), { name:'stream.txt' });
-archive.append(null, { name:'dir/' });
-```
-
-#### bulk(mappings)
-
-Appends multiple entries from passed array of src-dest mappings. A lazystream wrapper is used to prevent issues with open file limits.
-
-Globbing patterns are supported through use of the [file-utils](https://github.com/SBoudrias/file-utils) package. Please note that multiple src files to single dest file (ie concat) is not supported.
-
-The `data` property can be set (per src-dest mapping) to define data for matched entries.
-
-```js
-archive.bulk([
- { src: ['mydir/**'], data: { date: new Date() } },
- { expand: true, cwd: 'mydir', src: ['**'], dest: 'newdir' }
-]);
-```
-
-For more detail on this feature, please see [BULK.md](https://github.com/ctalkington/node-archiver/blob/master/BULK.md).
-
-#### file(filepath, data)
-
-Appends a file given its filepath using a lazystream wrapper to prevent issues with open file limits. When the instance has received, processed, and emitted the file, the `entry` event is fired.
-
-```js
-archive.file('mydir/file.txt', { name:'file.txt' });
-```
-
-#### finalize()
-
-Finalizes the instance and prevents further appending to the archive structure (queue will continue til drained). The `end`, `close` or `finish` events on the destination stream may fire right after calling this method so you should set listeners beforehand to properly detect stream completion.
-
-*You must call this method to get a valid archive and end the instance stream.*
-
-#### pointer()
-
-Returns the current byte length emitted by archiver. Use this in your end callback to log generated size.
-
-## Events
-
-Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) events.
-
-#### entry
-
-Fired when the input has been received, processed, and emitted. Passes entry data as first argument.
-
-## Zip
-
-### Options
-
-#### comment `string`
-
-Sets the zip comment.
-
-#### forceUTC `boolean`
-
-If true, forces the entry date to UTC. Helps with testing across timezones.
-
-#### store `boolean`
-
-If true, all entry contents will be archived without compression by default.
-
-#### zlib `object`
-
-Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
-
-### Entry Data
-
-#### name `string` `required`
-
-Sets the entry name including internal path.
-
-#### date `string|Date`
-
-Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
-
-#### store `boolean`
-
-If true, entry contents will be archived without compression.
-
-#### comment `string`
-
-Sets the entry comment.
-
-#### mode `number`
-
-Sets the entry permissions. Defaults to octal 0755 (directory) or 0644 (file).
-
-## Tar
-
-### Options
-
-#### gzip `boolean`
-
-Compresses the tar archive using gzip, default is false.
-
-#### gzipOptions `object`
-
-Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
-
-### Entry Data
-
-#### name `string` `required`
-
-Sets the entry name including internal path.
-
-#### date `string|Date`
-
-Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
-
-#### mode `number`
-
-Sets the entry permissions. Defaults to octal 0755 (directory) or 0644 (file).
-
-## Libraries
-
-Archiver makes use of several libraries/modules to avoid duplication of efforts.
-
-- [zip-stream](https://npmjs.org/package/zip-stream)
-- [tar-stream](https://npmjs.org/package/tar-stream)
-
-## Things of Interest
-
-- [Source Docs (coming soon)](https://docsrc.com/archiver/)
-- [Examples](https://github.com/ctalkington/node-archiver/blob/master/examples)
-- [Changelog](https://github.com/ctalkington/node-archiver/releases)
-- [Contributing](https://github.com/ctalkington/node-archiver/blob/master/CONTRIBUTING.md)
+# Archiver v0.11.0 [](https://travis-ci.org/ctalkington/node-archiver)
+
+a streaming interface for archive generation
+
+[](https://nodei.co/npm/archiver/)
+
+## Install
+
+```bash
+npm install archiver --save
+```
+
+You can also use `npm install https://github.com/ctalkington/node-archiver/archive/master.tar.gz` to test upcoming versions.
+
+## Archiver
+
+#### create(format, options)
+
+Creates an Archiver instance based on the format (zip, tar, etc) passed. Parameters can be passed directly to `Archiver` constructor for convenience.
+
+#### registerFormat(format, module)
+
+Registers an archive format. Format modules are essentially transform streams with a few required methods. They will be further documented once a formal spec is in place.
+
+### Instance Methods
+
+Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) methods.
+
+#### append(input, data)
+
+Appends an input source (text string, buffer, or stream) to the instance. When the instance has received, processed, and emitted the input, the `entry` event is fired.
+
+Replaced `#addFile` in v0.5.
+
+```js
+archive.append('string', { name:'string.txt' });
+archive.append(new Buffer('string'), { name:'buffer.txt' });
+archive.append(fs.createReadStream('mydir/file.txt'), { name:'stream.txt' });
+archive.append(null, { name:'dir/' });
+```
+
+#### bulk(mappings)
+
+Appends multiple entries from passed array of src-dest mappings. A lazystream wrapper is used to prevent issues with open file limits.
+
+Globbing patterns are supported through use of the [file-utils](https://github.com/SBoudrias/file-utils) package. Please note that multiple src files to single dest file (ie concat) is not supported.
+
+The `data` property can be set (per src-dest mapping) to define data for matched entries.
+
+```js
+archive.bulk([
+ { src: ['mydir/**'], data: { date: new Date() } },
+ { expand: true, cwd: 'mydir', src: ['**'], dest: 'newdir' }
+]);
+```
+
+For more detail on this feature, please see [BULK.md](https://github.com/ctalkington/node-archiver/blob/master/BULK.md).
+
+#### file(filepath, data)
+
+Appends a file given its filepath using a lazystream wrapper to prevent issues with open file limits. When the instance has received, processed, and emitted the file, the `entry` event is fired.
+
+```js
+archive.file('mydir/file.txt', { name:'file.txt' });
+```
+
+#### finalize()
+
+Finalizes the instance and prevents further appending to the archive structure (queue will continue til drained). The `end`, `close` or `finish` events on the destination stream may fire right after calling this method so you should set listeners beforehand to properly detect stream completion.
+
+*You must call this method to get a valid archive and end the instance stream.*
+
+#### pointer()
+
+Returns the current byte length emitted by archiver. Use this in your end callback to log generated size.
+
+## Events
+
+Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) events.
+
+#### entry
+
+Fired when the input has been received, processed, and emitted. Passes entry data as first argument.
+
+## Zip
+
+### Options
+
+#### comment `string`
+
+Sets the zip comment.
+
+#### forceUTC `boolean`
+
+If true, forces the entry date to UTC. Helps with testing across timezones.
+
+#### store `boolean`
+
+If true, all entry contents will be archived without compression by default.
+
+#### zlib `object`
+
+Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
+
+### Entry Data
+
+#### name `string` `required`
+
+Sets the entry name including internal path.
+
+#### date `string|Date`
+
+Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
+
+#### store `boolean`
+
+If true, entry contents will be archived without compression.
+
+#### comment `string`
+
+Sets the entry comment.
+
+#### mode `number`
+
+Sets the entry permissions. Defaults to octal 0755 (directory) or 0644 (file).
+
+## Tar
+
+### Options
+
+#### gzip `boolean`
+
+Compresses the tar archive using gzip, default is false.
+
+#### gzipOptions `object`
+
+Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
+
+### Entry Data
+
+#### name `string` `required`
+
+Sets the entry name including internal path.
+
+#### date `string|Date`
+
+Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
+
+#### mode `number`
+
+Sets the entry permissions. Defaults to octal 0755 (directory) or 0644 (file).
+
+## Libraries
+
+Archiver makes use of several libraries/modules to avoid duplication of efforts.
+
+- [zip-stream](https://npmjs.org/package/zip-stream)
+- [tar-stream](https://npmjs.org/package/tar-stream)
+
+## Things of Interest
+
+- [Source Docs (coming soon)](https://docsrc.com/archiver/)
+- [Examples](https://github.com/ctalkington/node-archiver/blob/master/examples)
+- [Changelog](https://github.com/ctalkington/node-archiver/releases)
+- [Contributing](https://github.com/ctalkington/node-archiver/blob/master/CONTRIBUTING.md)
- [MIT License](https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/archiver.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/archiver.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/archiver.js
index bc6b750..ed509c7 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/archiver.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/archiver.js
@@ -1,42 +1,42 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
- */
-var ArchiverCore = require('./modules/core');
-var formatModules = {};
-
-var archiver = module.exports = function(format, options) {
- return archiver.create(format, options);
-};
-
-archiver.create = function(format, options) {
- if (formatModules[format]) {
- var inst = new ArchiverCore(options);
- inst.setModule(new formatModules[format](options));
-
- return inst;
- } else {
- throw new Error('unknown format: ' + format);
- }
-};
-
-archiver.registerFormat = function(format, module) {
- if (module && typeof module === 'function' && typeof module.prototype.append === 'function') {
- formatModules[format] = module;
-
- // backwards compat
- var compatName = 'create' + format.charAt(0).toUpperCase() + format.slice(1);
- archiver[compatName] = function(options) {
- return archiver.create(format, options);
- };
- } else {
- throw new Error('format module invalid: ' + format);
- }
-};
-
-archiver.registerFormat('zip', require('./modules/zip'));
-archiver.registerFormat('tar', require('./modules/tar'));
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
+ */
+var ArchiverCore = require('./modules/core');
+var formatModules = {};
+
+var archiver = module.exports = function(format, options) {
+ return archiver.create(format, options);
+};
+
+archiver.create = function(format, options) {
+ if (formatModules[format]) {
+ var inst = new ArchiverCore(options);
+ inst.setModule(new formatModules[format](options));
+
+ return inst;
+ } else {
+ throw new Error('unknown format: ' + format);
+ }
+};
+
+archiver.registerFormat = function(format, module) {
+ if (module && typeof module === 'function' && typeof module.prototype.append === 'function') {
+ formatModules[format] = module;
+
+ // backwards compat
+ var compatName = 'create' + format.charAt(0).toUpperCase() + format.slice(1);
+ archiver[compatName] = function(options) {
+ return archiver.create(format, options);
+ };
+ } else {
+ throw new Error('format module invalid: ' + format);
+ }
+};
+
+archiver.registerFormat('zip', require('./modules/zip'));
+archiver.registerFormat('tar', require('./modules/tar'));
archiver.registerFormat('json', require('./modules/json'));
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/core/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/core/index.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/core/index.js
index a314ff6..d3c76fc 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/core/index.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/core/index.js
@@ -1,319 +1,319 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
- */
-var fs = require('fs');
-var inherits = require('util').inherits;
-var Transform = require('readable-stream').Transform;
-
-var async = require('async');
-
-var util = require('../../util');
-
-var Archiver = module.exports = function(options) {
- options = this.options = util.defaults(options, {
- highWaterMark: 1024 * 1024
- });
-
- Transform.call(this, options);
-
- this._entries = [];
- this._module = false;
- this._pointer = 0;
-
- this._queue = async.queue(this._onQueueTask.bind(this), 1);
- this._queue.drain = this._onQueueDrain.bind(this);
-
- this._state = {
- finalize: false,
- finalized: false,
- modulePiped: false
- };
-};
-
-inherits(Archiver, Transform);
-
-Archiver.prototype._append = function(filepath, data) {
- data = data || {};
-
- if (!data.name) {
- data.name = filepath;
- }
-
- data.sourcePath = filepath;
-
- this._queue.push({
- data: data,
- source: null,
- deferredStat: true,
- filepath: filepath
- });
-};
-
-Archiver.prototype._moduleAppend = function(source, data, callback) {
- this._module.append(source, data, callback);
-};
-
-Archiver.prototype._moduleFinalize = function() {
- this._state.finalized = true;
-
- if (typeof this._module.finalize === 'function') {
- this._module.finalize();
- } else if (typeof this._module.end === 'function') {
- this._module.end();
- } else {
- this.emit('error', new Error('format module missing finalize and end method'));
- }
-};
-
-Archiver.prototype._moduleSupports = function(key) {
- this._module.supports = util.defaults(this._module.supports, {
- directory: false
- });
-
- return this._module.supports[key];
-};
-
-Archiver.prototype._normalizeEntryData = function(data, stats) {
- stats = stats || false;
- data = util.defaults(data, {
- type: 'file',
- name: null,
- date: null,
- mode: null,
- sourcePath: null
- });
-
- var isDir = data.type === 'directory';
-
- if (data.name) {
- data.name = util.sanitizePath(data.name);
-
- if (data.name.slice(-1) === '/') {
- isDir = true;
- data.type = 'directory';
- } else if (isDir) {
- data.name += '/';
- }
- }
-
- if (typeof data.mode === 'number') {
- data.mode &= 0777;
- } else if (stats) {
- data.mode = stats.mode & 0777;
- } else {
- data.mode = isDir ? 0755 : 0644;
- }
-
- if (stats && data.date === null) {
- data.date = stats.mtime;
- }
-
- data.date = util.dateify(data.date);
-
- data._stats = stats;
-
- return data;
-};
-
-Archiver.prototype._onModuleError = function(err) {
- this.emit('error', err);
-};
-
-Archiver.prototype._onQueueDrain = function() {
- if (this._state.finalize && !this._state.finalized && this._queue.idle()) {
- this._moduleFinalize();
- }
-};
-
-Archiver.prototype._onQueueTask = function(task, callback) {
- var afterAppend = function(err, entry) {
- if (err) {
- this.emit('error', err);
- callback();
- return;
- }
-
- entry = entry || task.data;
-
- this.emit('entry', entry);
- this._entries.push(entry);
-
- callback();
- }.bind(this);
-
- var afterStat = function(err, stats) {
- if (err) {
- this.emit('error', err);
- callback();
- return;
- }
-
- task = this._updateQueueTaskWithStats(task, stats);
-
- if (task.source !== null) {
- this._moduleAppend(task.source, task.data, afterAppend);
- } else {
- this.emit('error', new Error('unsupported entry: ' + task.filepath));
- callback();
- return;
- }
- }.bind(this);
-
- if (task.deferredStat) {
- fs.stat(task.filepath, afterStat);
- } else {
- this._moduleAppend(task.source, task.data, afterAppend);
- }
-};
-
-Archiver.prototype._updateQueueTaskWithStats = function(task, stats) {
- if (stats.isFile()) {
- task.data.type = 'file';
- task.data.sourceType = 'stream';
- task.source = util.lazyReadStream(task.filepath);
- } else if (stats.isDirectory() && this._moduleSupports('directory')) {
- task.data.name = util.trailingSlashIt(task.data.name);
- task.data.type = 'directory';
- task.data.sourcePath = util.trailingSlashIt(task.filepath);
- task.data.sourceType = 'buffer';
- task.source = new Buffer(0);
- } else {
- return task;
- }
-
- task.data = this._normalizeEntryData(task.data, stats);
- return task;
-};
-
-Archiver.prototype._pipeModuleOutput = function() {
- this._module.on('error', this._onModuleError.bind(this));
- this._module.pipe(this);
-
- this._state.modulePiped = true;
-};
-
-Archiver.prototype._processFile = function(source, data, callback) {
- this.emit('error', new Error('method not implemented'));
-};
-
-Archiver.prototype._transform = function(chunk, encoding, callback) {
- if (chunk) {
- this._pointer += chunk.length;
- }
-
- callback(null, chunk);
-};
-
-Archiver.prototype.append = function(source, data) {
- if (this._state.finalize) {
- this.emit('error', new Error('unable to append after calling finalize.'));
- return this;
- }
-
- data = this._normalizeEntryData(data);
-
- if (typeof data.name !== 'string' || data.name.length === 0) {
- this.emit('error', new Error('entry name must be a non-empty string value'));
- return this;
- }
-
- if (data.type === 'directory' && !this._moduleSupports('directory')) {
- this.emit('error', new Error('entries of "directory" type not currently supported by this module'));
- return this;
- }
-
- source = util.normalizeInputSource(source);
-
- if (Buffer.isBuffer(source)) {
- data.sourceType = 'buffer';
- } else if (util.isStream(source)) {
- data.sourceType = 'stream';
- } else {
- this.emit('error', new Error('input source must be valid Stream or Buffer instance'));
- return this;
- }
-
- this._queue.push({
- data: data,
- source: source
- });
-
- return this;
-};
-
-Archiver.prototype.bulk = function(mappings) {
- if (this._state.finalize) {
- this.emit('error', new Error('unable to append after calling finalize.'));
- return this;
- }
-
- if (!Array.isArray(mappings)) {
- mappings = [mappings];
- }
-
- var self = this;
- var files = util.file.normalizeFilesArray(mappings);
-
- files.forEach(function(file){
- var isExpandedPair = file.orig.expand || false;
- var fileData = file.data || {};
-
- file.src.forEach(function(filepath) {
- var data = util._.extend({}, fileData);
- var name = isExpandedPair ? file.dest : util.unixifyPath(file.dest || '', filepath);
-
- if (name === '.') {
- return;
- }
-
- data.name = name;
- self._append(filepath, data);
- });
- });
-
- return this;
-};
-
-Archiver.prototype.file = function(filepath, data) {
- if (this._state.finalize) {
- this.emit('error', new Error('unable to append after calling finalize.'));
- return this;
- }
-
- if (typeof filepath !== 'string' || filepath.length === 0) {
- this.emit('error', new Error('filepath must be a non-empty string value'));
- return this;
- }
-
- this._append(filepath, data);
-
- return this;
-};
-
-Archiver.prototype.finalize = function() {
- this._state.finalize = true;
-
- if (this._queue.idle()) {
- this._moduleFinalize();
- }
-
- return this;
-};
-
-Archiver.prototype.setModule = function(module) {
- if (this._state.modulePiped) {
- this.emit('error', new Error('format module already set'));
- return;
- }
-
- this._module = module;
- this._pipeModuleOutput();
-};
-
-Archiver.prototype.pointer = function() {
- return this._pointer;
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
+ */
+var fs = require('fs');
+var inherits = require('util').inherits;
+var Transform = require('readable-stream').Transform;
+
+var async = require('async');
+
+var util = require('../../util');
+
+var Archiver = module.exports = function(options) {
+ options = this.options = util.defaults(options, {
+ highWaterMark: 1024 * 1024
+ });
+
+ Transform.call(this, options);
+
+ this._entries = [];
+ this._module = false;
+ this._pointer = 0;
+
+ this._queue = async.queue(this._onQueueTask.bind(this), 1);
+ this._queue.drain = this._onQueueDrain.bind(this);
+
+ this._state = {
+ finalize: false,
+ finalized: false,
+ modulePiped: false
+ };
+};
+
+inherits(Archiver, Transform);
+
+Archiver.prototype._append = function(filepath, data) {
+ data = data || {};
+
+ if (!data.name) {
+ data.name = filepath;
+ }
+
+ data.sourcePath = filepath;
+
+ this._queue.push({
+ data: data,
+ source: null,
+ deferredStat: true,
+ filepath: filepath
+ });
+};
+
+Archiver.prototype._moduleAppend = function(source, data, callback) {
+ this._module.append(source, data, callback);
+};
+
+Archiver.prototype._moduleFinalize = function() {
+ this._state.finalized = true;
+
+ if (typeof this._module.finalize === 'function') {
+ this._module.finalize();
+ } else if (typeof this._module.end === 'function') {
+ this._module.end();
+ } else {
+ this.emit('error', new Error('format module missing finalize and end method'));
+ }
+};
+
+Archiver.prototype._moduleSupports = function(key) {
+ this._module.supports = util.defaults(this._module.supports, {
+ directory: false
+ });
+
+ return this._module.supports[key];
+};
+
+Archiver.prototype._normalizeEntryData = function(data, stats) {
+ stats = stats || false;
+ data = util.defaults(data, {
+ type: 'file',
+ name: null,
+ date: null,
+ mode: null,
+ sourcePath: null
+ });
+
+ var isDir = data.type === 'directory';
+
+ if (data.name) {
+ data.name = util.sanitizePath(data.name);
+
+ if (data.name.slice(-1) === '/') {
+ isDir = true;
+ data.type = 'directory';
+ } else if (isDir) {
+ data.name += '/';
+ }
+ }
+
+ if (typeof data.mode === 'number') {
+ data.mode &= 0777;
+ } else if (stats) {
+ data.mode = stats.mode & 0777;
+ } else {
+ data.mode = isDir ? 0755 : 0644;
+ }
+
+ if (stats && data.date === null) {
+ data.date = stats.mtime;
+ }
+
+ data.date = util.dateify(data.date);
+
+ data._stats = stats;
+
+ return data;
+};
+
+Archiver.prototype._onModuleError = function(err) {
+ this.emit('error', err);
+};
+
+Archiver.prototype._onQueueDrain = function() {
+ if (this._state.finalize && !this._state.finalized && this._queue.idle()) {
+ this._moduleFinalize();
+ }
+};
+
+Archiver.prototype._onQueueTask = function(task, callback) {
+ var afterAppend = function(err, entry) {
+ if (err) {
+ this.emit('error', err);
+ callback();
+ return;
+ }
+
+ entry = entry || task.data;
+
+ this.emit('entry', entry);
+ this._entries.push(entry);
+
+ callback();
+ }.bind(this);
+
+ var afterStat = function(err, stats) {
+ if (err) {
+ this.emit('error', err);
+ callback();
+ return;
+ }
+
+ task = this._updateQueueTaskWithStats(task, stats);
+
+ if (task.source !== null) {
+ this._moduleAppend(task.source, task.data, afterAppend);
+ } else {
+ this.emit('error', new Error('unsupported entry: ' + task.filepath));
+ callback();
+ return;
+ }
+ }.bind(this);
+
+ if (task.deferredStat) {
+ fs.stat(task.filepath, afterStat);
+ } else {
+ this._moduleAppend(task.source, task.data, afterAppend);
+ }
+};
+
+Archiver.prototype._updateQueueTaskWithStats = function(task, stats) {
+ if (stats.isFile()) {
+ task.data.type = 'file';
+ task.data.sourceType = 'stream';
+ task.source = util.lazyReadStream(task.filepath);
+ } else if (stats.isDirectory() && this._moduleSupports('directory')) {
+ task.data.name = util.trailingSlashIt(task.data.name);
+ task.data.type = 'directory';
+ task.data.sourcePath = util.trailingSlashIt(task.filepath);
+ task.data.sourceType = 'buffer';
+ task.source = new Buffer(0);
+ } else {
+ return task;
+ }
+
+ task.data = this._normalizeEntryData(task.data, stats);
+ return task;
+};
+
+Archiver.prototype._pipeModuleOutput = function() {
+ this._module.on('error', this._onModuleError.bind(this));
+ this._module.pipe(this);
+
+ this._state.modulePiped = true;
+};
+
+Archiver.prototype._processFile = function(source, data, callback) {
+ this.emit('error', new Error('method not implemented'));
+};
+
+Archiver.prototype._transform = function(chunk, encoding, callback) {
+ if (chunk) {
+ this._pointer += chunk.length;
+ }
+
+ callback(null, chunk);
+};
+
+Archiver.prototype.append = function(source, data) {
+ if (this._state.finalize) {
+ this.emit('error', new Error('unable to append after calling finalize.'));
+ return this;
+ }
+
+ data = this._normalizeEntryData(data);
+
+ if (typeof data.name !== 'string' || data.name.length === 0) {
+ this.emit('error', new Error('entry name must be a non-empty string value'));
+ return this;
+ }
+
+ if (data.type === 'directory' && !this._moduleSupports('directory')) {
+ this.emit('error', new Error('entries of "directory" type not currently supported by this module'));
+ return this;
+ }
+
+ source = util.normalizeInputSource(source);
+
+ if (Buffer.isBuffer(source)) {
+ data.sourceType = 'buffer';
+ } else if (util.isStream(source)) {
+ data.sourceType = 'stream';
+ } else {
+ this.emit('error', new Error('input source must be valid Stream or Buffer instance'));
+ return this;
+ }
+
+ this._queue.push({
+ data: data,
+ source: source
+ });
+
+ return this;
+};
+
+Archiver.prototype.bulk = function(mappings) {
+ if (this._state.finalize) {
+ this.emit('error', new Error('unable to append after calling finalize.'));
+ return this;
+ }
+
+ if (!Array.isArray(mappings)) {
+ mappings = [mappings];
+ }
+
+ var self = this;
+ var files = util.file.normalizeFilesArray(mappings);
+
+ files.forEach(function(file){
+ var isExpandedPair = file.orig.expand || false;
+ var fileData = file.data || {};
+
+ file.src.forEach(function(filepath) {
+ var data = util._.extend({}, fileData);
+ var name = isExpandedPair ? file.dest : util.unixifyPath(file.dest || '', filepath);
+
+ if (name === '.') {
+ return;
+ }
+
+ data.name = name;
+ self._append(filepath, data);
+ });
+ });
+
+ return this;
+};
+
+Archiver.prototype.file = function(filepath, data) {
+ if (this._state.finalize) {
+ this.emit('error', new Error('unable to append after calling finalize.'));
+ return this;
+ }
+
+ if (typeof filepath !== 'string' || filepath.length === 0) {
+ this.emit('error', new Error('filepath must be a non-empty string value'));
+ return this;
+ }
+
+ this._append(filepath, data);
+
+ return this;
+};
+
+Archiver.prototype.finalize = function() {
+ this._state.finalize = true;
+
+ if (this._queue.idle()) {
+ this._moduleFinalize();
+ }
+
+ return this;
+};
+
+Archiver.prototype.setModule = function(module) {
+ if (this._state.modulePiped) {
+ this.emit('error', new Error('format module already set'));
+ return;
+ }
+
+ this._module = module;
+ this._pipeModuleOutput();
+};
+
+Archiver.prototype.pointer = function() {
+ return this._pointer;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/json/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/json/index.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/json/index.js
index 001c449..9b6f857 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/json/index.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/json/index.js
@@ -1,71 +1,71 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-var Transform = require('readable-stream').Transform;
-
-var crc32 = require('buffer-crc32');
-var util = require('../../util');
-
-var Json = module.exports = function(options) {
- options = this.options = util.defaults(options, {});
-
- Transform.call(this, options);
-
- this.supports = {
- directory: true
- };
-
- this.files = [];
-};
-
-inherits(Json, Transform);
-
-Json.prototype._transform = function(chunk, encoding, callback) {
- callback(null, chunk);
-};
-
-Json.prototype._writeStringified = function() {
- var fileString = JSON.stringify(this.files);
- this.write(fileString);
-};
-
-Json.prototype.append = function(source, data, callback) {
- var self = this;
-
- data.crc32 = 0;
-
- function onend(err, sourceBuffer) {
- if (err) {
- callback(err);
- return;
- }
-
- data.size = sourceBuffer.length || 0;
- data.crc32 = crc32.unsigned(sourceBuffer);
-
- self.files.push(data);
-
- callback(null, data);
- }
-
- if (data.sourceType === 'buffer') {
- onend(null, source);
- } else if (data.sourceType === 'stream') {
- util.collectStream(source, onend);
- }
-};
-
-Json.prototype.finalize = function(callback) {
- callback = callback || function() {};
-
- this._writeStringified();
-
- this.end();
-
- callback();
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+var Transform = require('readable-stream').Transform;
+
+var crc32 = require('buffer-crc32');
+var util = require('../../util');
+
+var Json = module.exports = function(options) {
+ options = this.options = util.defaults(options, {});
+
+ Transform.call(this, options);
+
+ this.supports = {
+ directory: true
+ };
+
+ this.files = [];
+};
+
+inherits(Json, Transform);
+
+Json.prototype._transform = function(chunk, encoding, callback) {
+ callback(null, chunk);
+};
+
+Json.prototype._writeStringified = function() {
+ var fileString = JSON.stringify(this.files);
+ this.write(fileString);
+};
+
+Json.prototype.append = function(source, data, callback) {
+ var self = this;
+
+ data.crc32 = 0;
+
+ function onend(err, sourceBuffer) {
+ if (err) {
+ callback(err);
+ return;
+ }
+
+ data.size = sourceBuffer.length || 0;
+ data.crc32 = crc32.unsigned(sourceBuffer);
+
+ self.files.push(data);
+
+ callback(null, data);
+ }
+
+ if (data.sourceType === 'buffer') {
+ onend(null, source);
+ } else if (data.sourceType === 'stream') {
+ util.collectStream(source, onend);
+ }
+};
+
+Json.prototype.finalize = function(callback) {
+ callback = callback || function() {};
+
+ this._writeStringified();
+
+ this.end();
+
+ callback();
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/tar/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/tar/index.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/tar/index.js
index 5fba091..d3c2542 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/tar/index.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/tar/index.js
@@ -1,84 +1,84 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
- */
-var zlib = require('zlib');
-
-var engine = require('tar-stream');
-var util = require('../../util');
-
-var Tar = module.exports = function(options) {
- options = this.options = util.defaults(options, {
- gzip: false
- });
-
- if (typeof options.gzipOptions !== 'object') {
- options.gzipOptions = {};
- }
-
- this.supports = {
- directory: true
- };
-
- this.engine = engine.pack(options);
- this.compressor = false;
-
- if (options.gzip) {
- this.compressor = zlib.createGzip(options.gzipOptions);
- this.compressor.on('error', this._onCompressorError.bind(this));
- }
-};
-
-Tar.prototype._onCompressorError = function(err) {
- this.engine.emit('error', err);
-};
-
-Tar.prototype.append = function(source, data, callback) {
- var self = this;
-
- data.mtime = data.date;
-
- function append(err, sourceBuffer) {
- if (err) {
- callback(err);
- return;
- }
-
- self.engine.entry(data, sourceBuffer, function(err) {
- callback(err, data);
- });
- }
-
- if (data.sourceType === 'buffer') {
- append(null, source);
- } else if (data.sourceType === 'stream' && data._stats) {
- data.size = data._stats.size;
-
- var entry = self.engine.entry(data, function(err) {
- callback(err, data);
- });
-
- source.pipe(entry);
- } else if (data.sourceType === 'stream') {
- util.collectStream(source, append);
- }
-};
-
-Tar.prototype.finalize = function() {
- this.engine.finalize();
-};
-
-Tar.prototype.on = function() {
- return this.engine.on.apply(this.engine, arguments);
-};
-
-Tar.prototype.pipe = function(destination, options) {
- if (this.compressor) {
- return this.engine.pipe.apply(this.engine, [this.compressor]).pipe(destination, options);
- } else {
- return this.engine.pipe.apply(this.engine, arguments);
- }
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
+ */
+var zlib = require('zlib');
+
+var engine = require('tar-stream');
+var util = require('../../util');
+
+var Tar = module.exports = function(options) {
+ options = this.options = util.defaults(options, {
+ gzip: false
+ });
+
+ if (typeof options.gzipOptions !== 'object') {
+ options.gzipOptions = {};
+ }
+
+ this.supports = {
+ directory: true
+ };
+
+ this.engine = engine.pack(options);
+ this.compressor = false;
+
+ if (options.gzip) {
+ this.compressor = zlib.createGzip(options.gzipOptions);
+ this.compressor.on('error', this._onCompressorError.bind(this));
+ }
+};
+
+Tar.prototype._onCompressorError = function(err) {
+ this.engine.emit('error', err);
+};
+
+Tar.prototype.append = function(source, data, callback) {
+ var self = this;
+
+ data.mtime = data.date;
+
+ function append(err, sourceBuffer) {
+ if (err) {
+ callback(err);
+ return;
+ }
+
+ self.engine.entry(data, sourceBuffer, function(err) {
+ callback(err, data);
+ });
+ }
+
+ if (data.sourceType === 'buffer') {
+ append(null, source);
+ } else if (data.sourceType === 'stream' && data._stats) {
+ data.size = data._stats.size;
+
+ var entry = self.engine.entry(data, function(err) {
+ callback(err, data);
+ });
+
+ source.pipe(entry);
+ } else if (data.sourceType === 'stream') {
+ util.collectStream(source, append);
+ }
+};
+
+Tar.prototype.finalize = function() {
+ this.engine.finalize();
+};
+
+Tar.prototype.on = function() {
+ return this.engine.on.apply(this.engine, arguments);
+};
+
+Tar.prototype.pipe = function(destination, options) {
+ if (this.compressor) {
+ return this.engine.pipe.apply(this.engine, [this.compressor]).pipe(destination, options);
+ } else {
+ return this.engine.pipe.apply(this.engine, arguments);
+ }
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/zip/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/zip/index.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/zip/index.js
index 28c13d3..e00a106 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/zip/index.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/modules/zip/index.js
@@ -1,39 +1,39 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
- */
-var engine = require('zip-stream');
-var util = require('../../util');
-
-var Zip = module.exports = function(options) {
- options = this.options = util.defaults(options, {
- comment: '',
- forceUTC: false,
- store: false
- });
-
- this.supports = {
- directory: true
- };
-
- this.engine = new engine(options);
-};
-
-Zip.prototype.append = function(source, data, callback) {
- this.engine.entry(source, data, callback);
-};
-
-Zip.prototype.finalize = function() {
- this.engine.finalize();
-};
-
-Zip.prototype.on = function() {
- return this.engine.on.apply(this.engine, arguments);
-};
-
-Zip.prototype.pipe = function() {
- return this.engine.pipe.apply(this.engine, arguments);
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
+ */
+var engine = require('zip-stream');
+var util = require('../../util');
+
+var Zip = module.exports = function(options) {
+ options = this.options = util.defaults(options, {
+ comment: '',
+ forceUTC: false,
+ store: false
+ });
+
+ this.supports = {
+ directory: true
+ };
+
+ this.engine = new engine(options);
+};
+
+Zip.prototype.append = function(source, data, callback) {
+ this.engine.entry(source, data, callback);
+};
+
+Zip.prototype.finalize = function() {
+ this.engine.finalize();
+};
+
+Zip.prototype.on = function() {
+ return this.engine.on.apply(this.engine, arguments);
+};
+
+Zip.prototype.pipe = function() {
+ return this.engine.pipe.apply(this.engine, arguments);
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/util/file.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/util/file.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/util/file.js
index 1ecaae3..c398891 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/util/file.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/util/file.js
@@ -1,206 +1,206 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
- */
-var fs = require('fs');
-var path = require('path');
-
-var _ = require('lodash');
-var glob = require('glob');
-
-var file = module.exports = {};
-
-var pathSeparatorRe = /[\/\\]/g;
-
-// Process specified wildcard glob patterns or filenames against a
-// callback, excluding and uniquing files in the result set.
-var processPatterns = function(patterns, fn) {
- // Filepaths to return.
- var result = [];
- // Iterate over flattened patterns array.
- _.flatten(patterns).forEach(function(pattern) {
- // If the first character is ! it should be omitted
- var exclusion = pattern.indexOf('!') === 0;
- // If the pattern is an exclusion, remove the !
- if (exclusion) { pattern = pattern.slice(1); }
- // Find all matching files for this pattern.
- var matches = fn(pattern);
- if (exclusion) {
- // If an exclusion, remove matching files.
- result = _.difference(result, matches);
- } else {
- // Otherwise add matching files.
- result = _.union(result, matches);
- }
- });
- return result;
-};
-
-// True if the file path exists.
-file.exists = function() {
- var filepath = path.join.apply(path, arguments);
- return fs.existsSync(filepath);
-};
-
-// Return an array of all file paths that match the given wildcard patterns.
-file.expand = function() {
- var args = _.toArray(arguments);
- // If the first argument is an options object, save those options to pass
- // into the File.prototype.glob.sync method.
- var options = _.isPlainObject(args[0]) ? args.shift() : {};
- // Use the first argument if it's an Array, otherwise convert the arguments
- // object to an array and use that.
- var patterns = Array.isArray(args[0]) ? args[0] : args;
- // Return empty set if there are no patterns or filepaths.
- if (patterns.length === 0) { return []; }
- // Return all matching filepaths.
- var matches = processPatterns(patterns, function(pattern) {
- // Find all matching files for this pattern.
- return glob.sync(pattern, options);
- });
- // Filter result set?
- if (options.filter) {
- matches = matches.filter(function(filepath) {
- filepath = path.join(options.cwd || '', filepath);
- try {
- if (typeof options.filter === 'function') {
- return options.filter(filepath);
- } else {
- // If the file is of the right type and exists, this should work.
- return fs.statSync(filepath)[options.filter]();
- }
- } catch(e) {
- // Otherwise, it's probably not the right type.
- return false;
- }
- });
- }
- return matches;
-};
-
-// Build a multi task "files" object dynamically.
-file.expandMapping = function(patterns, destBase, options) {
- options = _.defaults({}, options, {
- rename: function(destBase, destPath) {
- return path.join(destBase || '', destPath);
- }
- });
- var files = [];
- var fileByDest = {};
- // Find all files matching pattern, using passed-in options.
- file.expand(options, patterns).forEach(function(src) {
- var destPath = src;
- // Flatten?
- if (options.flatten) {
- destPath = path.basename(destPath);
- }
- // Change the extension?
- if (options.ext) {
- destPath = destPath.replace(/(\.[^\/]*)?$/, options.ext);
- }
- // Generate destination filename.
- var dest = options.rename(destBase, destPath, options);
- // Prepend cwd to src path if necessary.
- if (options.cwd) { src = path.join(options.cwd, src); }
- // Normalize filepaths to be unix-style.
- dest = dest.replace(pathSeparatorRe, '/');
- src = src.replace(pathSeparatorRe, '/');
- // Map correct src path to dest path.
- if (fileByDest[dest]) {
- // If dest already exists, push this src onto that dest's src array.
- fileByDest[dest].src.push(src);
- } else {
- // Otherwise create a new src-dest file mapping object.
- files.push({
- src: [src],
- dest: dest,
- });
- // And store a reference for later use.
- fileByDest[dest] = files[files.length - 1];
- }
- });
- return files;
-};
-
-// reusing bits of grunt's multi-task source normalization
-file.normalizeFilesArray = function(data) {
- var files = [];
-
- data.forEach(function(obj) {
- var prop;
- if ('src' in obj || 'dest' in obj) {
- files.push(obj);
- }
- });
-
- if (files.length === 0) {
- return [];
- }
-
- files = _(files).chain().forEach(function(obj) {
- if (!('src' in obj) || !obj.src) { return; }
- // Normalize .src properties to flattened array.
- if (Array.isArray(obj.src)) {
- obj.src = _.flatten(obj.src);
- } else {
- obj.src = [obj.src];
- }
- }).map(function(obj) {
- // Build options object, removing unwanted properties.
- var expandOptions = _.extend({}, obj);
- delete expandOptions.src;
- delete expandOptions.dest;
-
- // Expand file mappings.
- if (obj.expand) {
- return file.expandMapping(obj.src, obj.dest, expandOptions).map(function(mapObj) {
- // Copy obj properties to result.
- var result = _.extend({}, obj);
- // Make a clone of the orig obj available.
- result.orig = _.extend({}, obj);
- // Set .src and .dest, processing both as templates.
- result.src = mapObj.src;
- result.dest = mapObj.dest;
- // Remove unwanted properties.
- ['expand', 'cwd', 'flatten', 'rename', 'ext'].forEach(function(prop) {
- delete result[prop];
- });
- return result;
- });
- }
-
- // Copy obj properties to result, adding an .orig property.
- var result = _.extend({}, obj);
- // Make a clone of the orig obj available.
- result.orig = _.extend({}, obj);
-
- if ('src' in result) {
- // Expose an expand-on-demand getter method as .src.
- Object.defineProperty(result, 'src', {
- enumerable: true,
- get: function fn() {
- var src;
- if (!('result' in fn)) {
- src = obj.src;
- // If src is an array, flatten it. Otherwise, make it into an array.
- src = Array.isArray(src) ? _.flatten(src) : [src];
- // Expand src files, memoizing result.
- fn.result = file.expand(expandOptions, src);
- }
- return fn.result;
- }
- });
- }
-
- if ('dest' in result) {
- result.dest = obj.dest;
- }
-
- return result;
- }).flatten().value();
-
- return files;
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
+ */
+var fs = require('fs');
+var path = require('path');
+
+var _ = require('lodash');
+var glob = require('glob');
+
+var file = module.exports = {};
+
+var pathSeparatorRe = /[\/\\]/g;
+
+// Process specified wildcard glob patterns or filenames against a
+// callback, excluding and uniquing files in the result set.
+var processPatterns = function(patterns, fn) {
+ // Filepaths to return.
+ var result = [];
+ // Iterate over flattened patterns array.
+ _.flatten(patterns).forEach(function(pattern) {
+ // If the first character is ! it should be omitted
+ var exclusion = pattern.indexOf('!') === 0;
+ // If the pattern is an exclusion, remove the !
+ if (exclusion) { pattern = pattern.slice(1); }
+ // Find all matching files for this pattern.
+ var matches = fn(pattern);
+ if (exclusion) {
+ // If an exclusion, remove matching files.
+ result = _.difference(result, matches);
+ } else {
+ // Otherwise add matching files.
+ result = _.union(result, matches);
+ }
+ });
+ return result;
+};
+
+// True if the file path exists.
+file.exists = function() {
+ var filepath = path.join.apply(path, arguments);
+ return fs.existsSync(filepath);
+};
+
+// Return an array of all file paths that match the given wildcard patterns.
+file.expand = function() {
+ var args = _.toArray(arguments);
+ // If the first argument is an options object, save those options to pass
+ // into the File.prototype.glob.sync method.
+ var options = _.isPlainObject(args[0]) ? args.shift() : {};
+ // Use the first argument if it's an Array, otherwise convert the arguments
+ // object to an array and use that.
+ var patterns = Array.isArray(args[0]) ? args[0] : args;
+ // Return empty set if there are no patterns or filepaths.
+ if (patterns.length === 0) { return []; }
+ // Return all matching filepaths.
+ var matches = processPatterns(patterns, function(pattern) {
+ // Find all matching files for this pattern.
+ return glob.sync(pattern, options);
+ });
+ // Filter result set?
+ if (options.filter) {
+ matches = matches.filter(function(filepath) {
+ filepath = path.join(options.cwd || '', filepath);
+ try {
+ if (typeof options.filter === 'function') {
+ return options.filter(filepath);
+ } else {
+ // If the file is of the right type and exists, this should work.
+ return fs.statSync(filepath)[options.filter]();
+ }
+ } catch(e) {
+ // Otherwise, it's probably not the right type.
+ return false;
+ }
+ });
+ }
+ return matches;
+};
+
+// Build a multi task "files" object dynamically.
+file.expandMapping = function(patterns, destBase, options) {
+ options = _.defaults({}, options, {
+ rename: function(destBase, destPath) {
+ return path.join(destBase || '', destPath);
+ }
+ });
+ var files = [];
+ var fileByDest = {};
+ // Find all files matching pattern, using passed-in options.
+ file.expand(options, patterns).forEach(function(src) {
+ var destPath = src;
+ // Flatten?
+ if (options.flatten) {
+ destPath = path.basename(destPath);
+ }
+ // Change the extension?
+ if (options.ext) {
+ destPath = destPath.replace(/(\.[^\/]*)?$/, options.ext);
+ }
+ // Generate destination filename.
+ var dest = options.rename(destBase, destPath, options);
+ // Prepend cwd to src path if necessary.
+ if (options.cwd) { src = path.join(options.cwd, src); }
+ // Normalize filepaths to be unix-style.
+ dest = dest.replace(pathSeparatorRe, '/');
+ src = src.replace(pathSeparatorRe, '/');
+ // Map correct src path to dest path.
+ if (fileByDest[dest]) {
+ // If dest already exists, push this src onto that dest's src array.
+ fileByDest[dest].src.push(src);
+ } else {
+ // Otherwise create a new src-dest file mapping object.
+ files.push({
+ src: [src],
+ dest: dest,
+ });
+ // And store a reference for later use.
+ fileByDest[dest] = files[files.length - 1];
+ }
+ });
+ return files;
+};
+
+// reusing bits of grunt's multi-task source normalization
+file.normalizeFilesArray = function(data) {
+ var files = [];
+
+ data.forEach(function(obj) {
+ var prop;
+ if ('src' in obj || 'dest' in obj) {
+ files.push(obj);
+ }
+ });
+
+ if (files.length === 0) {
+ return [];
+ }
+
+ files = _(files).chain().forEach(function(obj) {
+ if (!('src' in obj) || !obj.src) { return; }
+ // Normalize .src properties to flattened array.
+ if (Array.isArray(obj.src)) {
+ obj.src = _.flatten(obj.src);
+ } else {
+ obj.src = [obj.src];
+ }
+ }).map(function(obj) {
+ // Build options object, removing unwanted properties.
+ var expandOptions = _.extend({}, obj);
+ delete expandOptions.src;
+ delete expandOptions.dest;
+
+ // Expand file mappings.
+ if (obj.expand) {
+ return file.expandMapping(obj.src, obj.dest, expandOptions).map(function(mapObj) {
+ // Copy obj properties to result.
+ var result = _.extend({}, obj);
+ // Make a clone of the orig obj available.
+ result.orig = _.extend({}, obj);
+ // Set .src and .dest, processing both as templates.
+ result.src = mapObj.src;
+ result.dest = mapObj.dest;
+ // Remove unwanted properties.
+ ['expand', 'cwd', 'flatten', 'rename', 'ext'].forEach(function(prop) {
+ delete result[prop];
+ });
+ return result;
+ });
+ }
+
+ // Copy obj properties to result, adding an .orig property.
+ var result = _.extend({}, obj);
+ // Make a clone of the orig obj available.
+ result.orig = _.extend({}, obj);
+
+ if ('src' in result) {
+ // Expose an expand-on-demand getter method as .src.
+ Object.defineProperty(result, 'src', {
+ enumerable: true,
+ get: function fn() {
+ var src;
+ if (!('result' in fn)) {
+ src = obj.src;
+ // If src is an array, flatten it. Otherwise, make it into an array.
+ src = Array.isArray(src) ? _.flatten(src) : [src];
+ // Expand src files, memoizing result.
+ fn.result = file.expand(expandOptions, src);
+ }
+ return fn.result;
+ }
+ });
+ }
+
+ if ('dest' in result) {
+ result.dest = obj.dest;
+ }
+
+ return result;
+ }).flatten().value();
+
+ return files;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/util/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/util/index.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/util/index.js
index 0646151..02030fb 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/util/index.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/lib/util/index.js
@@ -1,103 +1,103 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
- */
-var fs = require('fs');
-var path = require('path');
-
-var Stream = require('stream').Stream;
-var PassThrough = require('readable-stream').PassThrough;
-
-var util = module.exports = {};
-
-util._ = require('lodash');
-util.lazystream = require('lazystream');
-util.file = require('./file');
-
-util.collectStream = function(source, callback) {
- var collection = [];
- var size = 0;
-
- source.on('error', callback);
-
- source.on('data', function(chunk) {
- collection.push(chunk);
- size += chunk.length;
- });
-
- source.on('end', function() {
- var buf = new Buffer(size, 'utf8');
- var offset = 0;
-
- collection.forEach(function(data) {
- data.copy(buf, offset);
- offset += data.length;
- });
-
- callback(null, buf);
- });
-};
-
-util.dateify = function(dateish) {
- dateish = dateish || new Date();
-
- if (dateish instanceof Date) {
- dateish = dateish;
- } else if (typeof dateish === 'string') {
- dateish = new Date(dateish);
- } else {
- dateish = new Date();
- }
-
- return dateish;
-};
-
-// this is slightly different from lodash version
-util.defaults = function(object, source, guard) {
- var args = arguments;
- args[0] = args[0] || {};
-
- return util._.defaults.apply(util._, args);
-};
-
-util.isStream = function(source) {
- return source instanceof Stream;
-};
-
-util.lazyReadStream = function(filepath) {
- return new util.lazystream.Readable(function() {
- return fs.createReadStream(filepath);
- });
-};
-
-util.normalizeInputSource = function(source) {
- if (source === null) {
- return new Buffer(0);
- } else if (typeof source === 'string') {
- return new Buffer(source);
- } else if (util.isStream(source) && !source._readableState) {
- var normalized = new PassThrough();
- source.pipe(normalized);
-
- return normalized;
- }
-
- return source;
-};
-
-util.sanitizePath = function() {
- var filepath = path.join.apply(path, arguments);
- return filepath.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
-};
-
-util.trailingSlashIt = function(str) {
- return str.slice(-1) !== '/' ? str + '/' : str;
-};
-
-util.unixifyPath = function() {
- var filepath = path.join.apply(path, arguments);
- return filepath.replace(/\\/g, '/');
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT
+ */
+var fs = require('fs');
+var path = require('path');
+
+var Stream = require('stream').Stream;
+var PassThrough = require('readable-stream').PassThrough;
+
+var util = module.exports = {};
+
+util._ = require('lodash');
+util.lazystream = require('lazystream');
+util.file = require('./file');
+
+util.collectStream = function(source, callback) {
+ var collection = [];
+ var size = 0;
+
+ source.on('error', callback);
+
+ source.on('data', function(chunk) {
+ collection.push(chunk);
+ size += chunk.length;
+ });
+
+ source.on('end', function() {
+ var buf = new Buffer(size, 'utf8');
+ var offset = 0;
+
+ collection.forEach(function(data) {
+ data.copy(buf, offset);
+ offset += data.length;
+ });
+
+ callback(null, buf);
+ });
+};
+
+util.dateify = function(dateish) {
+ dateish = dateish || new Date();
+
+ if (dateish instanceof Date) {
+ dateish = dateish;
+ } else if (typeof dateish === 'string') {
+ dateish = new Date(dateish);
+ } else {
+ dateish = new Date();
+ }
+
+ return dateish;
+};
+
+// this is slightly different from lodash version
+util.defaults = function(object, source, guard) {
+ var args = arguments;
+ args[0] = args[0] || {};
+
+ return util._.defaults.apply(util._, args);
+};
+
+util.isStream = function(source) {
+ return source instanceof Stream;
+};
+
+util.lazyReadStream = function(filepath) {
+ return new util.lazystream.Readable(function() {
+ return fs.createReadStream(filepath);
+ });
+};
+
+util.normalizeInputSource = function(source) {
+ if (source === null) {
+ return new Buffer(0);
+ } else if (typeof source === 'string') {
+ return new Buffer(source);
+ } else if (util.isStream(source) && !source._readableState) {
+ var normalized = new PassThrough();
+ source.pipe(normalized);
+
+ return normalized;
+ }
+
+ return source;
+};
+
+util.sanitizePath = function() {
+ var filepath = path.join.apply(path, arguments);
+ return filepath.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
+};
+
+util.trailingSlashIt = function(str) {
+ return str.slice(-1) !== '/' ? str + '/' : str;
+};
+
+util.unixifyPath = function() {
+ var filepath = path.join.apply(path, arguments);
+ return filepath.replace(/\\/g, '/');
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/LICENSE-MIT
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/LICENSE-MIT b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/LICENSE-MIT
index 819b403..56420a6 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/LICENSE-MIT
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/LICENSE-MIT
@@ -1,22 +1,22 @@
-Copyright (c) 2014 Chris Talkington, contributors.
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+Copyright (c) 2014 Chris Talkington, contributors.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/README.md b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/README.md
index e4ec56c..3fc4346 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/README.md
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/README.md
@@ -1,105 +1,105 @@
-# zip-stream v0.4.1 [](https://travis-ci.org/ctalkington/node-zip-stream)
-
-zip-stream is a streaming zip archive generator based on the `ZipArchiveOutputStream` prototype found in the [compress-commons](https://www.npmjs.org/package/compress-commons) project.
-
-It was originally created to be a successor to [zipstream](https://npmjs.org/package/zipstream).
-
-[](https://nodei.co/npm/zip-stream/)
-
-### Install
-
-```bash
-npm install zip-stream --save
-```
-
-You can also use `npm install https://github.com/ctalkington/node-zip-stream/archive/master.tar.gz` to test upcoming versions.
-
-### Usage
-
-This module is meant to be wrapped internally by other modules and therefore lacks any queue management. This means you have to wait until the previous entry has been fully consumed to add another. Nested callbacks should be used to add multiple entries. There are modules like [async](https://npmjs.org/package/async) that ease the so called "callback hell".
-
-If you want a module that handles entry queueing and much more, you should check out [archiver](https://npmjs.org/package/archiver) which uses this module internally.
-
-```js
-var packer = require('zip-stream');
-var archive = new packer(); // OR new packer(options)
-
-archive.on('error', function(err) {
- throw err;
-});
-
-// pipe archive where you want it (ie fs, http, etc)
-// listen to the destination's end, close, or finish event
-
-archive.entry('string contents', { name: 'string.txt' }, function(err, entry) {
- if (err) throw err;
- archive.entry(null, { name: 'directory/' }, function(err, entry) {
- if (err) throw err;
- archive.finish();
- });
-});
-```
-
-### Instance API
-
-#### getBytesWritten()
-
-Returns the current number of bytes written to this stream.
-
-#### entry(input, data, callback(err, data))
-
-Appends an input source (text string, buffer, or stream) to the instance. When the instance has received, processed, and emitted the input, the callback is fired.
-
-#### finish()
-
-Finalizes the instance. You should listen to the destination stream's `end`/`close`/`finish` event to know when all output has been safely consumed. (`finalize` is aliased for back-compat)
-
-### Instance Options
-
-#### comment `string`
-
-Sets the zip comment.
-
-#### store `boolean`
-
-If true, all entry contents will be archived without compression by default.
-
-#### zlib `object`
-
-Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
-
-### Entry Data
-
-#### name `string` `required`
-
-Sets the entry name including internal path.
-
-#### type `string`
-
-Sets the entry type. Defaults to `file` or `directory` if name ends with trailing slash.
-
-#### date `string|Date`
-
-Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
-
-#### store `boolean`
-
-If true, entry contents will be archived without compression.
-
-#### comment `string`
-
-Sets the entry comment.
-
-#### mode `number`
-
-Sets the entry permissions.
-
-## Things of Interest
-
-- [Releases](https://github.com/ctalkington/node-zip-stream/releases)
-- [Contributing](https://github.com/ctalkington/node-zip-stream/blob/master/CONTRIBUTING.md)
-- [MIT License](https://github.com/ctalkington/node-zip-stream/blob/master/LICENSE-MIT)
-
-## Credits
-
+# zip-stream v0.4.1 [](https://travis-ci.org/ctalkington/node-zip-stream)
+
+zip-stream is a streaming zip archive generator based on the `ZipArchiveOutputStream` prototype found in the [compress-commons](https://www.npmjs.org/package/compress-commons) project.
+
+It was originally created to be a successor to [zipstream](https://npmjs.org/package/zipstream).
+
+[](https://nodei.co/npm/zip-stream/)
+
+### Install
+
+```bash
+npm install zip-stream --save
+```
+
+You can also use `npm install https://github.com/ctalkington/node-zip-stream/archive/master.tar.gz` to test upcoming versions.
+
+### Usage
+
+This module is meant to be wrapped internally by other modules and therefore lacks any queue management. This means you have to wait until the previous entry has been fully consumed to add another. Nested callbacks should be used to add multiple entries. There are modules like [async](https://npmjs.org/package/async) that ease the so called "callback hell".
+
+If you want a module that handles entry queueing and much more, you should check out [archiver](https://npmjs.org/package/archiver) which uses this module internally.
+
+```js
+var packer = require('zip-stream');
+var archive = new packer(); // OR new packer(options)
+
+archive.on('error', function(err) {
+ throw err;
+});
+
+// pipe archive where you want it (ie fs, http, etc)
+// listen to the destination's end, close, or finish event
+
+archive.entry('string contents', { name: 'string.txt' }, function(err, entry) {
+ if (err) throw err;
+ archive.entry(null, { name: 'directory/' }, function(err, entry) {
+ if (err) throw err;
+ archive.finish();
+ });
+});
+```
+
+### Instance API
+
+#### getBytesWritten()
+
+Returns the current number of bytes written to this stream.
+
+#### entry(input, data, callback(err, data))
+
+Appends an input source (text string, buffer, or stream) to the instance. When the instance has received, processed, and emitted the input, the callback is fired.
+
+#### finish()
+
+Finalizes the instance. You should listen to the destination stream's `end`/`close`/`finish` event to know when all output has been safely consumed. (`finalize` is aliased for back-compat)
+
+### Instance Options
+
+#### comment `string`
+
+Sets the zip comment.
+
+#### store `boolean`
+
+If true, all entry contents will be archived without compression by default.
+
+#### zlib `object`
+
+Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
+
+### Entry Data
+
+#### name `string` `required`
+
+Sets the entry name including internal path.
+
+#### type `string`
+
+Sets the entry type. Defaults to `file` or `directory` if name ends with trailing slash.
+
+#### date `string|Date`
+
+Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
+
+#### store `boolean`
+
+If true, entry contents will be archived without compression.
+
+#### comment `string`
+
+Sets the entry comment.
+
+#### mode `number`
+
+Sets the entry permissions.
+
+## Things of Interest
+
+- [Releases](https://github.com/ctalkington/node-zip-stream/releases)
+- [Contributing](https://github.com/ctalkington/node-zip-stream/blob/master/CONTRIBUTING.md)
+- [MIT License](https://github.com/ctalkington/node-zip-stream/blob/master/LICENSE-MIT)
+
+## Credits
+
Concept inspired by Antoine van Wel's [zipstream](https://npmjs.org/package/zipstream) module, which is no longer being updated.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/lib/util/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/lib/util/index.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/lib/util/index.js
index 0b5a468..221d0af 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/lib/util/index.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/lib/util/index.js
@@ -1,103 +1,103 @@
-/**
- * node-zip-stream
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-zip-stream/blob/master/LICENSE-MIT
- */
-var fs = require('fs');
-var path = require('path');
-
-var Stream = require('stream').Stream;
-var PassThrough = require('readable-stream').PassThrough;
-
-var _ = require('lodash');
-
-var util = module.exports = {};
-
-util.convertDateTimeDos = function(input) {
- return new Date(
- ((input >> 25) & 0x7f) + 1980,
- ((input >> 21) & 0x0f) - 1,
- (input >> 16) & 0x1f,
- (input >> 11) & 0x1f,
- (input >> 5) & 0x3f,
- (input & 0x1f) << 1
- );
-};
-
-util.dateify = function(dateish) {
- dateish = dateish || new Date();
-
- if (dateish instanceof Date) {
- dateish = dateish;
- } else if (typeof dateish === 'string') {
- dateish = new Date(dateish);
- } else {
- dateish = new Date();
- }
-
- return dateish;
-};
-
-// this is slightly different from lodash version
-util.defaults = function(object, source, guard) {
- var args = arguments;
- args[0] = args[0] || {};
-
- return _.defaults.apply(_, args);
-};
-
-util.dosDateTime = function(d, utc) {
- d = (d instanceof Date) ? d : util.dateify(d);
- utc = utc || false;
-
- var year = utc ? d.getUTCFullYear() : d.getFullYear();
-
- if (year < 1980) {
- return 2162688; // 1980-1-1 00:00:00
- } else if (year >= 2044) {
- return 2141175677; // 2043-12-31 23:59:58
- }
-
- var val = {
- year: year,
- month: utc ? d.getUTCMonth() : d.getMonth(),
- date: utc ? d.getUTCDate() : d.getDate(),
- hours: utc ? d.getUTCHours() : d.getHours(),
- minutes: utc ? d.getUTCMinutes() : d.getMinutes(),
- seconds: utc ? d.getUTCSeconds() : d.getSeconds()
- };
-
- return ((val.year-1980) << 25) | ((val.month+1) << 21) | (val.date << 16) |
- (val.hours << 11) | (val.minutes << 5) | (val.seconds / 2);
-};
-
-util.isStream = function(source) {
- return source instanceof Stream;
-};
-
-util.normalizeInputSource = function(source) {
- if (source === null) {
- return new Buffer(0);
- } else if (typeof source === 'string') {
- return new Buffer(source);
- } else if (util.isStream(source) && !source._readableState) {
- var normalized = new PassThrough();
- source.pipe(normalized);
-
- return normalized;
- }
-
- return source;
-};
-
-util.sanitizePath = function() {
- var filepath = path.join.apply(path, arguments);
- return filepath.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
-};
-
-util.unixifyPath = function() {
- var filepath = path.join.apply(path, arguments);
- return filepath.replace(/\\/g, '/');
+/**
+ * node-zip-stream
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-zip-stream/blob/master/LICENSE-MIT
+ */
+var fs = require('fs');
+var path = require('path');
+
+var Stream = require('stream').Stream;
+var PassThrough = require('readable-stream').PassThrough;
+
+var _ = require('lodash');
+
+var util = module.exports = {};
+
+util.convertDateTimeDos = function(input) {
+ return new Date(
+ ((input >> 25) & 0x7f) + 1980,
+ ((input >> 21) & 0x0f) - 1,
+ (input >> 16) & 0x1f,
+ (input >> 11) & 0x1f,
+ (input >> 5) & 0x3f,
+ (input & 0x1f) << 1
+ );
+};
+
+util.dateify = function(dateish) {
+ dateish = dateish || new Date();
+
+ if (dateish instanceof Date) {
+ dateish = dateish;
+ } else if (typeof dateish === 'string') {
+ dateish = new Date(dateish);
+ } else {
+ dateish = new Date();
+ }
+
+ return dateish;
+};
+
+// this is slightly different from lodash version
+util.defaults = function(object, source, guard) {
+ var args = arguments;
+ args[0] = args[0] || {};
+
+ return _.defaults.apply(_, args);
+};
+
+util.dosDateTime = function(d, utc) {
+ d = (d instanceof Date) ? d : util.dateify(d);
+ utc = utc || false;
+
+ var year = utc ? d.getUTCFullYear() : d.getFullYear();
+
+ if (year < 1980) {
+ return 2162688; // 1980-1-1 00:00:00
+ } else if (year >= 2044) {
+ return 2141175677; // 2043-12-31 23:59:58
+ }
+
+ var val = {
+ year: year,
+ month: utc ? d.getUTCMonth() : d.getMonth(),
+ date: utc ? d.getUTCDate() : d.getDate(),
+ hours: utc ? d.getUTCHours() : d.getHours(),
+ minutes: utc ? d.getUTCMinutes() : d.getMinutes(),
+ seconds: utc ? d.getUTCSeconds() : d.getSeconds()
+ };
+
+ return ((val.year-1980) << 25) | ((val.month+1) << 21) | (val.date << 16) |
+ (val.hours << 11) | (val.minutes << 5) | (val.seconds / 2);
+};
+
+util.isStream = function(source) {
+ return source instanceof Stream;
+};
+
+util.normalizeInputSource = function(source) {
+ if (source === null) {
+ return new Buffer(0);
+ } else if (typeof source === 'string') {
+ return new Buffer(source);
+ } else if (util.isStream(source) && !source._readableState) {
+ var normalized = new PassThrough();
+ source.pipe(normalized);
+
+ return normalized;
+ }
+
+ return source;
+};
+
+util.sanitizePath = function() {
+ var filepath = path.join.apply(path, arguments);
+ return filepath.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
+};
+
+util.unixifyPath = function() {
+ var filepath = path.join.apply(path, arguments);
+ return filepath.replace(/\\/g, '/');
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/lib/zip-stream.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/lib/zip-stream.js b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/lib/zip-stream.js
index d13960b..898ab82 100644
--- a/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/lib/zip-stream.js
+++ b/node_modules/node-firefox-install-app/node_modules/zip-folder/node_modules/archiver/node_modules/zip-stream/lib/zip-stream.js
@@ -1,110 +1,110 @@
-/**
- * node-zip-stream
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-zip-stream/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-
-var ZipArchiveOutputStream = require('compress-commons').ZipArchiveOutputStream;
-var ZipArchiveEntry = require('compress-commons').ZipArchiveEntry;
-
-var util = require('./util');
-
-var ZipStream = module.exports = function(options) {
- if (!(this instanceof ZipStream)) {
- return new ZipStream(options);
- }
-
- options = this.options = options || {};
- options.zlib = options.zlib || {};
-
- ZipArchiveOutputStream.call(this, options);
-
- if (typeof options.level === 'number' && options.level >= 0) {
- options.zlib.level = options.level;
- delete options.level;
- }
-
- if (options.zlib.level && options.zlib.level === 0) {
- options.store = true;
- }
-
- if (options.comment && options.comment.length > 0) {
- this.setComment(options.comment);
- }
-};
-
-inherits(ZipStream, ZipArchiveOutputStream);
-
-ZipStream.prototype._normalizeFileData = function(data) {
- data = util.defaults(data, {
- type: 'file',
- name: null,
- date: null,
- mode: null,
- store: this.options.store,
- comment: ''
- });
-
- var isDir = data.type === 'directory';
-
- if (data.name) {
- data.name = util.sanitizePath(data.name);
-
- if (data.name.slice(-1) === '/') {
- isDir = true;
- data.type = 'directory';
- } else if (isDir) {
- data.name += '/';
- }
- }
-
- if (isDir) {
- data.store = true;
- }
-
- data.date = util.dateify(data.date);
-
- return data;
-};
-
-ZipStream.prototype.entry = function(source, data, callback) {
- if (typeof callback !== 'function') {
- callback = this._emitErrorCallback.bind(this);
- }
-
- data = this._normalizeFileData(data);
-
- if (data.type !== 'file' && data.type !== 'directory') {
- callback(new Error(data.type + ' entries not currently supported'));
- return;
- }
-
- if (typeof data.name !== 'string' || data.name.length === 0) {
- callback(new Error('entry name must be a non-empty string value'));
- return;
- }
-
- var entry = new ZipArchiveEntry(data.name);
- entry.setTime(data.date);
-
- if (data.store) {
- entry.setMethod(0);
- }
-
- if (data.comment.length > 0) {
- entry.setComment(data.comment);
- }
-
- if (typeof data.mode === 'number') {
- entry.setUnixMode(data.mode);
- }
-
- return ZipArchiveOutputStream.prototype.entry.call(this, entry, source, callback);
-};
-
-ZipStream.prototype.finalize = function() {
- this.finish();
+/**
+ * node-zip-stream
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-zip-stream/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+
+var ZipArchiveOutputStream = require('compress-commons').ZipArchiveOutputStream;
+var ZipArchiveEntry = require('compress-commons').ZipArchiveEntry;
+
+var util = require('./util');
+
+var ZipStream = module.exports = function(options) {
+ if (!(this instanceof ZipStream)) {
+ return new ZipStream(options);
+ }
+
+ options = this.options = options || {};
+ options.zlib = options.zlib || {};
+
+ ZipArchiveOutputStream.call(this, options);
+
+ if (typeof options.level === 'number' && options.level >= 0) {
+ options.zlib.level = options.level;
+ delete options.level;
+ }
+
+ if (options.zlib.level && options.zlib.level === 0) {
+ options.store = true;
+ }
+
+ if (options.comment && options.comment.length > 0) {
+ this.setComment(options.comment);
+ }
+};
+
+inherits(ZipStream, ZipArchiveOutputStream);
+
+ZipStream.prototype._normalizeFileData = function(data) {
+ data = util.defaults(data, {
+ type: 'file',
+ name: null,
+ date: null,
+ mode: null,
+ store: this.options.store,
+ comment: ''
+ });
+
+ var isDir = data.type === 'directory';
+
+ if (data.name) {
+ data.name = util.sanitizePath(data.name);
+
+ if (data.name.slice(-1) === '/') {
+ isDir = true;
+ data.type = 'directory';
+ } else if (isDir) {
+ data.name += '/';
+ }
+ }
+
+ if (isDir) {
+ data.store = true;
+ }
+
+ data.date = util.dateify(data.date);
+
+ return data;
+};
+
+ZipStream.prototype.entry = function(source, data, callback) {
+ if (typeof callback !== 'function') {
+ callback = this._emitErrorCallback.bind(this);
+ }
+
+ data = this._normalizeFileData(data);
+
+ if (data.type !== 'file' && data.type !== 'directory') {
+ callback(new Error(data.type + ' entries not currently supported'));
+ return;
+ }
+
+ if (typeof data.name !== 'string' || data.name.length === 0) {
+ callback(new Error('entry name must be a non-empty string value'));
+ return;
+ }
+
+ var entry = new ZipArchiveEntry(data.name);
+ entry.setTime(data.date);
+
+ if (data.store) {
+ entry.setMethod(0);
+ }
+
+ if (data.comment.length > 0) {
+ entry.setComment(data.comment);
+ }
+
+ if (typeof data.mode === 'number') {
+ entry.setUnixMode(data.mode);
+ }
+
+ return ZipArchiveOutputStream.prototype.entry.call(this, entry, source, callback);
+};
+
+ZipStream.prototype.finalize = function() {
+ this.finish();
};
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[06/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js b/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
index 6c34fbe..5e5a969 100644
--- a/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
+++ b/node_modules/node-firefox-find-ports/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
@@ -1,3854 +1,3854 @@
-/*
- * JSHint, by JSHint Community.
- *
- * Licensed under the same slightly modified MIT license that JSLint is.
- * It stops evil-doers everywhere.
- *
- * JSHint is a derivative work of JSLint:
- *
- * Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * The Software shall be used for Good, not Evil.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * JSHint was forked from 2010-12-16 edition of JSLint.
- *
- */
-
-/*
- JSHINT is a global function. It takes two parameters.
-
- var myResult = JSHINT(source, option);
-
- The first parameter is either a string or an array of strings. If it is a
- string, it will be split on '\n' or '\r'. If it is an array of strings, it
- is assumed that each string represents one line. The source can be a
- JavaScript text or a JSON text.
-
- The second parameter is an optional object of options which control the
- operation of JSHINT. Most of the options are booleans: They are all
- optional and have a default value of false. One of the options, predef,
- can be an array of names, which will be used to declare global variables,
- or an object whose keys are used as global names, with a boolean value
- that determines if they are assignable.
-
- If it checks out, JSHINT returns true. Otherwise, it returns false.
-
- If false, you can inspect JSHINT.errors to find out the problems.
- JSHINT.errors is an array of objects containing these members:
-
- {
- line : The line (relative to 0) at which the lint was found
- character : The character (relative to 0) at which the lint was found
- reason : The problem
- evidence : The text line in which the problem occurred
- raw : The raw message before the details were inserted
- a : The first detail
- b : The second detail
- c : The third detail
- d : The fourth detail
- }
-
- If a fatal error was found, a null will be the last element of the
- JSHINT.errors array.
-
- You can request a Function Report, which shows all of the functions
- and the parameters and vars that they use. This can be used to find
- implied global variables and other problems. The report is in HTML and
- can be inserted in an HTML <body>.
-
- var myReport = JSHINT.report(limited);
-
- If limited is true, then the report will be limited to only errors.
-
- You can request a data structure which contains JSHint's results.
-
- var myData = JSHINT.data();
-
- It returns a structure with this form:
-
- {
- errors: [
- {
- line: NUMBER,
- character: NUMBER,
- reason: STRING,
- evidence: STRING
- }
- ],
- functions: [
- name: STRING,
- line: NUMBER,
- last: NUMBER,
- param: [
- STRING
- ],
- closure: [
- STRING
- ],
- var: [
- STRING
- ],
- exception: [
- STRING
- ],
- outer: [
- STRING
- ],
- unused: [
- STRING
- ],
- global: [
- STRING
- ],
- label: [
- STRING
- ]
- ],
- globals: [
- STRING
- ],
- member: {
- STRING: NUMBER
- },
- unuseds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- implieds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- urls: [
- STRING
- ],
- json: BOOLEAN
- }
-
- Empty arrays will not be included.
-
-*/
-
-/*jshint
- evil: true, nomen: false, onevar: false, regexp: false, strict: true, boss: true
-*/
-
-/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
- "(begin)", "(breakage)", "(context)", "(error)", "(global)",
- "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
- "(params)", "(scope)", "(statement)", "(verb)", "*", "+", "++", "-",
- "--", "\/", "<", "<=", "==", "===", ">", ">=", $, $$, $A, $F, $H, $R, $break,
- $continue, $w, Abstract, Ajax, __filename, __dirname, ActiveXObject, Array,
- ArrayBuffer, ArrayBufferView, Autocompleter, Assets, Boolean, Builder,
- Buffer, Browser, COM, CScript, Canvas, CustomAnimation, Class, Control,
- Chain, Color, Cookie, Core, DataView, Date, Debug, Draggable, Draggables,
- Droppables, Document, DomReady, DOMReady, Drag, E, Enumerator, Enumerable,
- Element, Elements, Error, Effect, EvalError, Event, Events, FadeAnimation,
- Field, Flash, Float32Array, Float64Array, Form, FormField, Frame, Function,
- Fx, Group, Hash, HotKey, HTMLElement, HtmlTable, Iframe, IframeShim, Image,
- Int16Array, Int32Array, Int8Array, Insertion, InputValidator, JSON, Keyboard,
- Locale, LN10, LN2, LOG10E, LOG2E, MAX_VALUE, MIN_VALUE, Mask, Math, MenuItem,
- MoveAnimation, MooTools, Native, NEGATIVE_INFINITY, Number, Object,
- ObjectRange, Option, Options, OverText, PI, POSITIVE_INFINITY,
- PeriodicalExecuter, Point, Position, Prototype, RangeError, Rectangle,
- ReferenceError, RegExp, ResizeAnimation, Request, RotateAnimation, SQRT1_2,
- SQRT2, ScrollBar, Scriptaculous, Scroller, Slick, Slider, Selector, String,
- Style, SyntaxError, Sortable, Sortables, SortableObserver, Sound, Spinner,
- System, Swiff, Text, TextArea, Template, Timer, Tips, Type, TypeError,
- Toggle, Try, URI, URIError, URL, VBArray, WScript, Web, Window, XMLDOM,
- XMLHttpRequest, XPathEvaluator, XPathException, XPathExpression,
- XPathNamespace, XPathNSResolver, XPathResult, "\\", a, addEventListener,
- address, alert, apply, applicationCache, arguments, arity, asi, b, bitwise,
- block, blur, boolOptions, boss, browser, c, call, callee, caller, cases,
- charAt, charCodeAt, character, clearInterval, clearTimeout, close, closed,
- closure, comment, condition, confirm, console, constructor, content, couch,
- create, css, curly, d, data, datalist, dd, debug, decodeURI,
- decodeURIComponent, defaultStatus, defineClass, deserialize, devel,
- document, edition, else, emit, encodeURI, encodeURIComponent, entityify,
- eqeqeq, eqnull, errors, es5, escape, eval, event, evidence, evil, ex,
- exception, exec, exps, expr, exports, FileReader, first, floor, focus,
- forin, fragment, frames, from, fromCharCode, fud, funct, function, functions,
- g, gc, getComputedStyle, getRow, GLOBAL, global, globals, globalstrict,
- hasOwnProperty, help, history, i, id, identifier, immed, implieds,
- include, indent, indexOf, init, ins, instanceOf, isAlpha,
- isApplicationRunning, isArray, isDigit, isFinite, isNaN, join, jshint,
- JSHINT, json, jquery, jQuery, keys, label, labelled, last, laxbreak,
- latedef, lbp, led, left, length, line, load, loadClass, localStorage,
- location, log, loopfunc, m, match, maxerr, maxlen, member,message, meta,
- module, moveBy, moveTo, mootools, name, navigator, new, newcap, noarg,
- node, noempty, nomen, nonew, nud, onbeforeunload, onblur, onerror, onevar,
- onfocus, onload, onresize, onunload, open, openDatabase, openURL, opener,
- opera, outer, param, parent, parseFloat, parseInt, passfail, plusplus,
- predef, print, process, prompt, prototype, prototypejs, push, quit, range,
- raw, reach, reason, regexp, readFile, readUrl, removeEventListener, replace,
- report, require, reserved, resizeBy, resizeTo, resolvePath, resumeUpdates,
- respond, rhino, right, runCommand, scroll, screen, scrollBy, scrollTo,
- scrollbar, search, seal, send, serialize, setInterval, setTimeout, shift,
- slice, sort,spawn, split, stack, status, start, strict, sub, substr, supernew,
- shadow, supplant, sum, sync, test, toLowerCase, toString, toUpperCase, toint32,
- token, top, type, typeOf, Uint16Array, Uint32Array, Uint8Array, undef,
- unused, urls, value, valueOf, var, version, WebSocket, white, window, Worker
-*/
-
-/*global exports: false */
-
-// We build the application inside a function so that we produce only a single
-// global variable. That function will be invoked immediately, and its return
-// value is the JSHINT function itself.
-
-var JSHINT = (function () {
- "use strict";
-
- var anonname, // The guessed name for anonymous functions.
-
-// These are operators that should not be used with the ! operator.
-
- bang = {
- '<' : true,
- '<=' : true,
- '==' : true,
- '===': true,
- '!==': true,
- '!=' : true,
- '>' : true,
- '>=' : true,
- '+' : true,
- '-' : true,
- '*' : true,
- '/' : true,
- '%' : true
- },
-
-// These are the JSHint boolean options.
-
- boolOptions = {
- asi : true, // if automatic semicolon insertion should be tolerated
- bitwise : true, // if bitwise operators should not be allowed
- boss : true, // if advanced usage of assignments should be allowed
- browser : true, // if the standard browser globals should be predefined
- couch : true, // if CouchDB globals should be predefined
- curly : true, // if curly braces around blocks should be required (even in if/for/while)
- debug : true, // if debugger statements should be allowed
- devel : true, // if logging globals should be predefined (console, alert, etc.)
- eqeqeq : true, // if === should be required
- eqnull : true, // if == null comparisons should be tolerated
- es5 : true, // if ES5 syntax should be allowed
- evil : true, // if eval should be allowed
- expr : true, // if ExpressionStatement should be allowed as Programs
- forin : true, // if for in statements must filter
- globalstrict: true, // if global "use strict"; should be allowed (also enables 'strict')
- immed : true, // if immediate invocations must be wrapped in parens
- jquery : true, // if jQuery globals should be predefined
- latedef : true, // if the use before definition should not be tolerated
- laxbreak : true, // if line breaks should not be checked
- loopfunc : true, // if functions should be allowed to be defined within loops
- mootools : true, // if MooTools globals should be predefined
- newcap : true, // if constructor names must be capitalized
- noarg : true, // if arguments.caller and arguments.callee should be disallowed
- node : true, // if the Node.js environment globals should be predefined
- noempty : true, // if empty blocks should be disallowed
- nonew : true, // if using `new` for side-effects should be disallowed
- nomen : true, // if names should be checked
- onevar : true, // if only one var statement per function should be allowed
- passfail : true, // if the scan should stop on first error
- plusplus : true, // if increment/decrement should not be allowed
- prototypejs : true, // if Prototype and Scriptaculous globals shoudl be predefined
- regexp : true, // if the . should not be allowed in regexp literals
- rhino : true, // if the Rhino environment globals should be predefined
- undef : true, // if variables should be declared before used
- shadow : true, // if variable shadowing should be tolerated
- strict : true, // require the "use strict"; pragma
- sub : true, // if all forms of subscript notation are tolerated
- supernew : true, // if `new function () { ... };` and `new Object;` should be tolerated
- white : true // if strict whitespace rules apply
- },
-
-// browser contains a set of global names which are commonly provided by a
-// web browser environment.
-
- browser = {
- ArrayBuffer : false,
- ArrayBufferView : false,
- addEventListener: false,
- applicationCache: false,
- blur : false,
- clearInterval : false,
- clearTimeout : false,
- close : false,
- closed : false,
- DataView : false,
- defaultStatus : false,
- document : false,
- event : false,
- FileReader : false,
- Float32Array : false,
- Float64Array : false,
- focus : false,
- frames : false,
- getComputedStyle: false,
- HTMLElement : false,
- history : false,
- Int16Array : false,
- Int32Array : false,
- Int8Array : false,
- Image : false,
- length : false,
- localStorage : false,
- location : false,
- moveBy : false,
- moveTo : false,
- name : false,
- navigator : false,
- onbeforeunload : true,
- onblur : true,
- onerror : true,
- onfocus : true,
- onload : true,
- onresize : true,
- onunload : true,
- open : false,
- openDatabase : false,
- opener : false,
- Option : false,
- parent : false,
- print : false,
- removeEventListener: false,
- resizeBy : false,
- resizeTo : false,
- screen : false,
- scroll : false,
- scrollBy : false,
- scrollTo : false,
- setInterval : false,
- setTimeout : false,
- status : false,
- top : false,
- Uint16Array : false,
- Uint32Array : false,
- Uint8Array : false,
- WebSocket : false,
- window : false,
- Worker : false,
- XMLHttpRequest : false,
- XPathEvaluator : false,
- XPathException : false,
- XPathExpression : false,
- XPathNamespace : false,
- XPathNSResolver : false,
- XPathResult : false
- },
-
- couch = {
- "require" : false,
- respond : false,
- getRow : false,
- emit : false,
- send : false,
- start : false,
- sum : false,
- log : false,
- exports : false,
- module : false
- },
-
- devel = {
- alert : false,
- confirm : false,
- console : false,
- Debug : false,
- opera : false,
- prompt : false
- },
-
- escapes = {
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '/' : '\\/',
- '\\': '\\\\'
- },
-
- funct, // The current function
-
- functionicity = [
- 'closure', 'exception', 'global', 'label',
- 'outer', 'unused', 'var'
- ],
-
- functions, // All of the functions
-
- global, // The global scope
- implied, // Implied globals
- inblock,
- indent,
- jsonmode,
-
- jquery = {
- '$' : false,
- jQuery : false
- },
-
- lines,
- lookahead,
- member,
- membersOnly,
-
- mootools = {
- '$' : false,
- '$$' : false,
- Assets : false,
- Browser : false,
- Chain : false,
- Class : false,
- Color : false,
- Cookie : false,
- Core : false,
- Document : false,
- DomReady : false,
- DOMReady : false,
- Drag : false,
- Element : false,
- Elements : false,
- Event : false,
- Events : false,
- Fx : false,
- Group : false,
- Hash : false,
- HtmlTable : false,
- Iframe : false,
- IframeShim : false,
- InputValidator : false,
- instanceOf : false,
- Keyboard : false,
- Locale : false,
- Mask : false,
- MooTools : false,
- Native : false,
- Options : false,
- OverText : false,
- Request : false,
- Scroller : false,
- Slick : false,
- Slider : false,
- Sortables : false,
- Spinner : false,
- Swiff : false,
- Tips : false,
- Type : false,
- typeOf : false,
- URI : false,
- Window : false
- },
-
- nexttoken,
-
- node = {
- __filename : false,
- __dirname : false,
- exports : false,
- Buffer : false,
- GLOBAL : false,
- global : false,
- module : false,
- process : false,
- require : false
- },
-
- noreach,
- option,
- predefined, // Global variables defined by option
- prereg,
- prevtoken,
-
- prototypejs = {
- '$' : false,
- '$$' : false,
- '$A' : false,
- '$F' : false,
- '$H' : false,
- '$R' : false,
- '$break' : false,
- '$continue' : false,
- '$w' : false,
- Abstract : false,
- Ajax : false,
- Class : false,
- Enumerable : false,
- Element : false,
- Event : false,
- Field : false,
- Form : false,
- Hash : false,
- Insertion : false,
- ObjectRange : false,
- PeriodicalExecuter: false,
- Position : false,
- Prototype : false,
- Selector : false,
- Template : false,
- Toggle : false,
- Try : false,
- Autocompleter : false,
- Builder : false,
- Control : false,
- Draggable : false,
- Draggables : false,
- Droppables : false,
- Effect : false,
- Sortable : false,
- SortableObserver : false,
- Sound : false,
- Scriptaculous : false
- },
-
- rhino = {
- defineClass : false,
- deserialize : false,
- gc : false,
- help : false,
- load : false,
- loadClass : false,
- print : false,
- quit : false,
- readFile : false,
- readUrl : false,
- runCommand : false,
- seal : false,
- serialize : false,
- spawn : false,
- sync : false,
- toint32 : false,
- version : false
- },
-
- scope, // The current scope
- src,
- stack,
-
-// standard contains the global names that are provided by the
-// ECMAScript standard.
-
- standard = {
- Array : false,
- Boolean : false,
- Date : false,
- decodeURI : false,
- decodeURIComponent : false,
- encodeURI : false,
- encodeURIComponent : false,
- Error : false,
- 'eval' : false,
- EvalError : false,
- Function : false,
- hasOwnProperty : false,
- isFinite : false,
- isNaN : false,
- JSON : false,
- Math : false,
- Number : false,
- Object : false,
- parseInt : false,
- parseFloat : false,
- RangeError : false,
- ReferenceError : false,
- RegExp : false,
- String : false,
- SyntaxError : false,
- TypeError : false,
- URIError : false
- },
-
- standard_member = {
- E : true,
- LN2 : true,
- LN10 : true,
- LOG2E : true,
- LOG10E : true,
- MAX_VALUE : true,
- MIN_VALUE : true,
- NEGATIVE_INFINITY : true,
- PI : true,
- POSITIVE_INFINITY : true,
- SQRT1_2 : true,
- SQRT2 : true
- },
-
- strict_mode,
- syntax = {},
- tab,
- token,
- urls,
- warnings,
-
-// Regular expressions. Some of these are stupidly long.
-
-// unsafe comment or string
- ax = /@cc|<\/?|script|\]\s*\]|<\s*!|</i,
-// unsafe characters that are silently deleted by one or more browsers
- cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
-// token
- tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jshint|jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
-// characters in strings that need escapement
- nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
- nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
-// star slash
- lx = /\*\/|\/\*/,
-// identifier
- ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
-// javascript url
- jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
-// catches /* falls through */ comments
- ft = /^\s*\/\*\s*falls\sthrough\s*\*\/\s*$/;
-
- function F() {} // Used by Object.create
-
- function is_own(object, name) {
-
-// The object.hasOwnProperty method fails when the property under consideration
-// is named 'hasOwnProperty'. So we have to use this more convoluted form.
-
- return Object.prototype.hasOwnProperty.call(object, name);
- }
-
-// Provide critical ES5 functions to ES3.
-
- if (typeof Array.isArray !== 'function') {
- Array.isArray = function (o) {
- return Object.prototype.toString.apply(o) === '[object Array]';
- };
- }
-
- if (typeof Object.create !== 'function') {
- Object.create = function (o) {
- F.prototype = o;
- return new F();
- };
- }
-
- if (typeof Object.keys !== 'function') {
- Object.keys = function (o) {
- var a = [], k;
- for (k in o) {
- if (is_own(o, k)) {
- a.push(k);
- }
- }
- return a;
- };
- }
-
-// Non standard methods
-
- if (typeof String.prototype.entityify !== 'function') {
- String.prototype.entityify = function () {
- return this
- .replace(/&/g, '&')
- .replace(/</g, '<')
- .replace(/>/g, '>');
- };
- }
-
- if (typeof String.prototype.isAlpha !== 'function') {
- String.prototype.isAlpha = function () {
- return (this >= 'a' && this <= 'z\uffff') ||
- (this >= 'A' && this <= 'Z\uffff');
- };
- }
-
- if (typeof String.prototype.isDigit !== 'function') {
- String.prototype.isDigit = function () {
- return (this >= '0' && this <= '9');
- };
- }
-
- if (typeof String.prototype.supplant !== 'function') {
- String.prototype.supplant = function (o) {
- return this.replace(/\{([^{}]*)\}/g, function (a, b) {
- var r = o[b];
- return typeof r === 'string' || typeof r === 'number' ? r : a;
- });
- };
- }
-
- if (typeof String.prototype.name !== 'function') {
- String.prototype.name = function () {
-
-// If the string looks like an identifier, then we can return it as is.
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can simply slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe
-// sequences.
-
- if (ix.test(this)) {
- return this;
- }
- if (nx.test(this)) {
- return '"' + this.replace(nxg, function (a) {
- var c = escapes[a];
- if (c) {
- return c;
- }
- return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
- }) + '"';
- }
- return '"' + this + '"';
- };
- }
-
-
- function combine(t, o) {
- var n;
- for (n in o) {
- if (is_own(o, n)) {
- t[n] = o[n];
- }
- }
- }
-
- function assume() {
- if (option.couch)
- combine(predefined, couch);
-
- if (option.rhino)
- combine(predefined, rhino);
-
- if (option.prototypejs)
- combine(predefined, prototypejs);
-
- if (option.node)
- combine(predefined, node);
-
- if (option.devel)
- combine(predefined, devel);
-
- if (option.browser)
- combine(predefined, browser);
-
- if (option.jquery)
- combine(predefined, jquery);
-
- if (option.mootools)
- combine(predefined, mootools);
-
- if (option.globalstrict)
- option.strict = true;
- }
-
-
-// Produce an error warning.
-
- function quit(m, l, ch) {
- throw {
- name: 'JSHintError',
- line: l,
- character: ch,
- message: m + " (" + Math.floor((l / lines.length) * 100) +
- "% scanned)."
- };
- }
-
- function warning(m, t, a, b, c, d) {
- var ch, l, w;
- t = t || nexttoken;
- if (t.id === '(end)') { // `~
- t = token;
- }
- l = t.line || 0;
- ch = t.from || 0;
- w = {
- id: '(error)',
- raw: m,
- evidence: lines[l - 1] || '',
- line: l,
- character: ch,
- a: a,
- b: b,
- c: c,
- d: d
- };
- w.reason = m.supplant(w);
- JSHINT.errors.push(w);
- if (option.passfail) {
- quit('Stopping. ', l, ch);
- }
- warnings += 1;
- if (warnings >= option.maxerr) {
- quit("Too many errors.", l, ch);
- }
- return w;
- }
-
- function warningAt(m, l, ch, a, b, c, d) {
- return warning(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
- function error(m, t, a, b, c, d) {
- var w = warning(m, t, a, b, c, d);
- quit("Stopping, unable to continue.", w.line, w.character);
- }
-
- function errorAt(m, l, ch, a, b, c, d) {
- return error(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
-
-
-// lexical analysis and token construction
-
- var lex = (function lex() {
- var character, from, line, s;
-
-// Private lex methods
-
- function nextLine() {
- var at,
- tw; // trailing whitespace check
-
- if (line >= lines.length)
- return false;
-
- character = 1;
- s = lines[line];
- line += 1;
- at = s.search(/ \t/);
-
- if (at >= 0)
- warningAt("Mixed spaces and tabs.", line, at + 1);
-
- s = s.replace(/\t/g, tab);
- at = s.search(cx);
-
- if (at >= 0)
- warningAt("Unsafe character.", line, at);
-
- if (option.maxlen && option.maxlen < s.length)
- warningAt("Line too long.", line, s.length);
-
- // Check for trailing whitespaces
- tw = s.search(/\s+$/);
- if (option.white && ~tw)
- warningAt("Trailing whitespace.", line, tw);
-
- return true;
- }
-
-// Produce a token object. The token inherits from a syntax symbol.
-
- function it(type, value) {
- var i, t;
- if (type === '(color)' || type === '(range)') {
- t = {type: type};
- } else if (type === '(punctuator)' ||
- (type === '(identifier)' && is_own(syntax, value))) {
- t = syntax[value] || syntax['(error)'];
- } else {
- t = syntax[type];
- }
- t = Object.create(t);
- if (type === '(string)' || type === '(range)') {
- if (jx.test(value)) {
- warningAt("Script URL.", line, from);
- }
- }
- if (type === '(identifier)') {
- t.identifier = true;
- if (value === '__iterator__' || value === '__proto__') {
- errorAt("Reserved name '{a}'.",
- line, from, value);
- } else if (option.nomen &&
- (value.charAt(0) === '_' ||
- value.charAt(value.length - 1) === '_')) {
- warningAt("Unexpected {a} in '{b}'.", line, from,
- "dangling '_'", value);
- }
- }
- t.value = value;
- t.line = line;
- t.character = character;
- t.from = from;
- i = t.id;
- if (i !== '(endline)') {
- prereg = i &&
- (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
- i === 'return');
- }
- return t;
- }
-
-// Public lex methods
-
- return {
- init: function (source) {
- if (typeof source === 'string') {
- lines = source
- .replace(/\r\n/g, '\n')
- .replace(/\r/g, '\n')
- .split('\n');
- } else {
- lines = source;
- }
-
- // If the first line is a shebang (#!), make it a blank and move on.
- // Shebangs are used by Node scripts.
- if (lines[0] && lines[0].substr(0, 2) == '#!')
- lines[0] = '';
-
- line = 0;
- nextLine();
- from = 1;
- },
-
- range: function (begin, end) {
- var c, value = '';
- from = character;
- if (s.charAt(0) !== begin) {
- errorAt("Expected '{a}' and instead saw '{b}'.",
- line, character, begin, s.charAt(0));
- }
- for (;;) {
- s = s.slice(1);
- character += 1;
- c = s.charAt(0);
- switch (c) {
- case '':
- errorAt("Missing '{a}'.", line, character, c);
- break;
- case end:
- s = s.slice(1);
- character += 1;
- return it('(range)', value);
- case '\\':
- warningAt("Unexpected '{a}'.", line, character, c);
- }
- value += c;
- }
-
- },
-
-// token -- this is called by advance to get the next token.
-
- token: function () {
- var b, c, captures, d, depth, high, i, l, low, q, t;
-
- function match(x) {
- var r = x.exec(s), r1;
- if (r) {
- l = r[0].length;
- r1 = r[1];
- c = r1.charAt(0);
- s = s.substr(l);
- from = character + l - r1.length;
- character += l;
- return r1;
- }
- }
-
- function string(x) {
- var c, j, r = '';
-
- if (jsonmode && x !== '"') {
- warningAt("Strings must use doublequote.",
- line, character);
- }
-
- function esc(n) {
- var i = parseInt(s.substr(j + 1, n), 16);
- j += n;
- if (i >= 32 && i <= 126 &&
- i !== 34 && i !== 92 && i !== 39) {
- warningAt("Unnecessary escapement.", line, character);
- }
- character += n;
- c = String.fromCharCode(i);
- }
- j = 0;
- for (;;) {
- while (j >= s.length) {
- j = 0;
- if (!nextLine()) {
- errorAt("Unclosed string.", line, from);
- }
- }
- c = s.charAt(j);
- if (c === x) {
- character += 1;
- s = s.substr(j + 1);
- return it('(string)', r, x);
- }
- if (c < ' ') {
- if (c === '\n' || c === '\r') {
- break;
- }
- warningAt("Control character in string: {a}.",
- line, character + j, s.slice(0, j));
- } else if (c === '\\') {
- j += 1;
- character += 1;
- c = s.charAt(j);
- switch (c) {
- case '\\':
- case '"':
- case '/':
- break;
- case '\'':
- if (jsonmode) {
- warningAt("Avoid \\'.", line, character);
- }
- break;
- case 'b':
- c = '\b';
- break;
- case 'f':
- c = '\f';
- break;
- case 'n':
- c = '\n';
- break;
- case 'r':
- c = '\r';
- break;
- case 't':
- c = '\t';
- break;
- case 'u':
- esc(4);
- break;
- case 'v':
- if (jsonmode) {
- warningAt("Avoid \\v.", line, character);
- }
- c = '\v';
- break;
- case 'x':
- if (jsonmode) {
- warningAt("Avoid \\x-.", line, character);
- }
- esc(2);
- break;
- default:
- warningAt("Bad escapement.", line, character);
- }
- }
- r += c;
- character += 1;
- j += 1;
- }
- }
-
- for (;;) {
- if (!s) {
- return it(nextLine() ? '(endline)' : '(end)', '');
- }
- t = match(tx);
- if (!t) {
- t = '';
- c = '';
- while (s && s < '!') {
- s = s.substr(1);
- }
- if (s) {
- errorAt("Unexpected '{a}'.", line, character, s.substr(0, 1));
- }
- } else {
-
- // identifier
-
- if (c.isAlpha() || c === '_' || c === '$') {
- return it('(identifier)', t);
- }
-
- // number
-
- if (c.isDigit()) {
- if (!isFinite(Number(t))) {
- warningAt("Bad number '{a}'.",
- line, character, t);
- }
- if (s.substr(0, 1).isAlpha()) {
- warningAt("Missing space after '{a}'.",
- line, character, t);
- }
- if (c === '0') {
- d = t.substr(1, 1);
- if (d.isDigit()) {
- if (token.id !== '.') {
- warningAt("Don't use extra leading zeros '{a}'.",
- line, character, t);
- }
- } else if (jsonmode && (d === 'x' || d === 'X')) {
- warningAt("Avoid 0x-. '{a}'.",
- line, character, t);
- }
- }
- if (t.substr(t.length - 1) === '.') {
- warningAt(
-"A trailing decimal point can be confused with a dot '{a}'.", line, character, t);
- }
- return it('(number)', t);
- }
- switch (t) {
-
- // string
-
- case '"':
- case "'":
- return string(t);
-
- // // comment
-
- case '//':
- if (src) {
- warningAt("Unexpected comment.", line, character);
- }
- s = '';
- token.comment = true;
- break;
-
- // /* comment
-
- case '/*':
- if (src) {
- warningAt("Unexpected comment.", line, character);
- }
- for (;;) {
- i = s.search(lx);
- if (i >= 0) {
- break;
- }
- if (!nextLine()) {
- errorAt("Unclosed comment.", line, character);
- }
- }
- character += i + 2;
- if (s.substr(i, 1) === '/') {
- errorAt("Nested comment.", line, character);
- }
- s = s.substr(i + 2);
- token.comment = true;
- break;
-
- // /*members /*jshint /*global
-
- case '/*members':
- case '/*member':
- case '/*jshint':
- case '/*jslint':
- case '/*global':
- case '*/':
- return {
- value: t,
- type: 'special',
- line: line,
- character: character,
- from: from
- };
-
- case '':
- break;
- // /
- case '/':
- if (token.id === '/=') {
- errorAt(
-"A regular expression literal can be confused with '/='.", line, from);
- }
- if (prereg) {
- depth = 0;
- captures = 0;
- l = 0;
- for (;;) {
- b = true;
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '':
- errorAt("Unclosed regular expression.",
- line, from);
- return;
- case '/':
- if (depth > 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, '/');
- }
- c = s.substr(0, l - 1);
- q = {
- g: true,
- i: true,
- m: true
- };
- while (q[s.charAt(l)] === true) {
- q[s.charAt(l)] = false;
- l += 1;
- }
- character += l;
- s = s.substr(l);
- q = s.charAt(0);
- if (q === '/' || q === '*') {
- errorAt("Confusing regular expression.",
- line, from);
- }
- return it('(regexp)', c);
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- break;
- case '(':
- depth += 1;
- b = false;
- if (s.charAt(l) === '?') {
- l += 1;
- switch (s.charAt(l)) {
- case ':':
- case '=':
- case '!':
- l += 1;
- break;
- default:
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
- }
- } else {
- captures += 1;
- }
- break;
- case '|':
- b = false;
- break;
- case ')':
- if (depth === 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, ')');
- } else {
- depth -= 1;
- }
- break;
- case ' ':
- q = 1;
- while (s.charAt(l) === ' ') {
- l += 1;
- q += 1;
- }
- if (q > 1) {
- warningAt(
-"Spaces are hard to count. Use {{a}}.", line, from + l, q);
- }
- break;
- case '[':
- c = s.charAt(l);
- if (c === '^') {
- l += 1;
- if (option.regexp) {
- warningAt("Insecure '{a}'.",
- line, from + l, c);
- } else if (s.charAt(l) === ']') {
- errorAt("Unescaped '{a}'.",
- line, from + l, '^');
- }
- }
- q = false;
- if (c === ']') {
- warningAt("Empty class.", line,
- from + l - 1);
- q = true;
- }
-klass: do {
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '[':
- case '^':
- warningAt("Unescaped '{a}'.",
- line, from + l, c);
- q = true;
- break;
- case '-':
- if (q) {
- q = false;
- } else {
- warningAt("Unescaped '{a}'.",
- line, from + l, '-');
- q = true;
- }
- break;
- case ']':
- if (!q) {
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, '-');
- }
- break klass;
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- q = true;
- break;
- case '/':
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, '/');
- q = true;
- break;
- case '<':
- q = true;
- break;
- default:
- q = true;
- }
- } while (c);
- break;
- case '.':
- if (option.regexp) {
- warningAt("Insecure '{a}'.", line,
- from + l, c);
- }
- break;
- case ']':
- case '?':
- case '{':
- case '}':
- case '+':
- case '*':
- warningAt("Unescaped '{a}'.", line,
- from + l, c);
- }
- if (b) {
- switch (s.charAt(l)) {
- case '?':
- case '+':
- case '*':
- l += 1;
- if (s.charAt(l) === '?') {
- l += 1;
- }
- break;
- case '{':
- l += 1;
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- warningAt(
-"Expected a number and instead saw '{a}'.", line, from + l, c);
- }
- l += 1;
- low = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- low = +c + (low * 10);
- }
- high = low;
- if (c === ',') {
- l += 1;
- high = Infinity;
- c = s.charAt(l);
- if (c >= '0' && c <= '9') {
- l += 1;
- high = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- high = +c + (high * 10);
- }
- }
- }
- if (s.charAt(l) !== '}') {
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
- } else {
- l += 1;
- }
- if (s.charAt(l) === '?') {
- l += 1;
- }
- if (low > high) {
- warningAt(
-"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
- }
- }
- }
- }
- c = s.substr(0, l - 1);
- character += l;
- s = s.substr(l);
- return it('(regexp)', c);
- }
- return it('(punctuator)', t);
-
- // punctuator
-
- case '#':
- return it('(punctuator)', t);
- default:
- return it('(punctuator)', t);
- }
- }
- }
- }
- };
- }());
-
-
- function addlabel(t, type) {
-
- if (t === 'hasOwnProperty') {
- warning("'hasOwnProperty' is a really bad name.");
- }
-
-// Define t in the current function in the current scope.
-
- if (is_own(funct, t) && !funct['(global)']) {
- if (funct[t] === true) {
- if (option.latedef)
- warning("'{a}' was used before it was defined.", nexttoken, t);
- } else {
- if (!option.shadow)
- warning("'{a}' is already defined.", nexttoken, t);
- }
- }
-
- funct[t] = type;
- if (funct['(global)']) {
- global[t] = funct;
- if (is_own(implied, t)) {
- if (option.latedef)
- warning("'{a}' was used before it was defined.", nexttoken, t);
- delete implied[t];
- }
- } else {
- scope[t] = funct;
- }
- }
-
-
- function doOption() {
- var b, obj, filter, o = nexttoken.value, t, v;
- switch (o) {
- case '*/':
- error("Unbegun comment.");
- break;
- case '/*members':
- case '/*member':
- o = '/*members';
- if (!membersOnly) {
- membersOnly = {};
- }
- obj = membersOnly;
- break;
- case '/*jshint':
- case '/*jslint':
- obj = option;
- filter = boolOptions;
- break;
- case '/*global':
- obj = predefined;
- break;
- default:
- error("What?");
- }
- t = lex.token();
-loop: for (;;) {
- for (;;) {
- if (t.type === 'special' && t.value === '*/') {
- break loop;
- }
- if (t.id !== '(endline)' && t.id !== ',') {
- break;
- }
- t = lex.token();
- }
- if (t.type !== '(string)' && t.type !== '(identifier)' &&
- o !== '/*members') {
- error("Bad option.", t);
- }
- v = lex.token();
- if (v.id === ':') {
- v = lex.token();
- if (obj === membersOnly) {
- error("Expected '{a}' and instead saw '{b}'.",
- t, '*/', ':');
- }
- if (t.value === 'indent' && (o === '/*jshint' || o === '/*jslint')) {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.white = true;
- obj.indent = b;
- } else if (t.value === 'maxerr' && (o === '/*jshint' || o === '/*jslint')) {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxerr = b;
- } else if (t.value === 'maxlen' && (o === '/*jshint' || o === '/*jslint')) {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxlen = b;
- } else if (v.value === 'true') {
- obj[t.value] = true;
- } else if (v.value === 'false') {
- obj[t.value] = false;
- } else {
- error("Bad option value.", v);
- }
- t = lex.token();
- } else {
- if (o === '/*jshint' || o === '/*jslint') {
- error("Missing option value.", t);
- }
- obj[t.value] = false;
- t = v;
- }
- }
- if (filter) {
- assume();
- }
- }
-
-
-// We need a peek function. If it has an argument, it peeks that much farther
-// ahead. It is used to distinguish
-// for ( var i in ...
-// from
-// for ( var i = ...
-
- function peek(p) {
- var i = p || 0, j = 0, t;
-
- while (j <= i) {
- t = lookahead[j];
- if (!t) {
- t = lookahead[j] = lex.token();
- }
- j += 1;
- }
- return t;
- }
-
-
-
-// Produce the next token. It looks for programming errors.
-
- function advance(id, t) {
- switch (token.id) {
- case '(number)':
- if (nexttoken.id === '.') {
- warning("A dot following a number can be confused with a decimal point.", token);
- }
- break;
- case '-':
- if (nexttoken.id === '-' || nexttoken.id === '--') {
- warning("Confusing minusses.");
- }
- break;
- case '+':
- if (nexttoken.id === '+' || nexttoken.id === '++') {
- warning("Confusing plusses.");
- }
- break;
- }
- if (token.type === '(string)' || token.identifier) {
- anonname = token.value;
- }
-
- if (id && nexttoken.id !== id) {
- if (t) {
- if (nexttoken.id === '(end)') {
- warning("Unmatched '{a}'.", t, t.id);
- } else {
- warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
- nexttoken, id, t.id, t.line, nexttoken.value);
- }
- } else if (nexttoken.type !== '(identifier)' ||
- nexttoken.value !== id) {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, id, nexttoken.value);
- }
- }
- prevtoken = token;
- token = nexttoken;
- for (;;) {
- nexttoken = lookahead.shift() || lex.token();
- if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
- return;
- }
- if (nexttoken.type === 'special') {
- doOption();
- } else {
- if (nexttoken.id !== '(endline)') {
- break;
- }
- }
- }
- }
-
-
-// This is the heart of JSHINT, the Pratt parser. In addition to parsing, it
-// is looking for ad hoc lint patterns. We add .fud to Pratt's model, which is
-// like .nud except that it is only used on the first token of a statement.
-// Having .fud makes it much easier to define statement-oriented languages like
-// JavaScript. I retained Pratt's nomenclature.
-
-// .nud Null denotation
-// .fud First null denotation
-// .led Left denotation
-// lbp Left binding power
-// rbp Right binding power
-
-// They are elements of the parsing method called Top Down Operator Precedence.
-
- function expression(rbp, initial) {
- var left, isArray = false;
-
- if (nexttoken.id === '(end)')
- error("Unexpected early end of program.", token);
-
- advance();
- if (initial) {
- anonname = 'anonymous';
- funct['(verb)'] = token.value;
- }
- if (initial === true && token.fud) {
- left = token.fud();
- } else {
- if (token.nud) {
- left = token.nud();
- } else {
- if (nexttoken.type === '(number)' && token.id === '.') {
- warning("A leading decimal point can be confused with a dot: '.{a}'.",
- token, nexttoken.value);
- advance();
- return token;
- } else {
- error("Expected an identifier and instead saw '{a}'.",
- token, token.id);
- }
- }
- while (rbp < nexttoken.lbp) {
- isArray = token.value == 'Array';
- advance();
- if (isArray && token.id == '(' && nexttoken.id == ')')
- warning("Use the array literal notation [].", token);
- if (token.led) {
- left = token.led(left);
- } else {
- error("Expected an operator and instead saw '{a}'.",
- token, token.id);
- }
- }
- }
- return left;
- }
-
-
-// Functions for conformance of style.
-
- function adjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white) {
- if (left.character !== right.from && left.line === right.line) {
- warning("Unexpected space after '{a}'.", right, left.value);
- }
- }
- }
-
- function nobreak(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white && (left.character !== right.from || left.line !== right.line)) {
- warning("Unexpected space before '{a}'.", right, right.value);
- }
- }
-
- function nospace(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white && !left.comment) {
- if (left.line === right.line) {
- adjacent(left, right);
- }
- }
- }
-
- function nonadjacent(left, right) {
- if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.line === right.line && left.character === right.from) {
- warning("Missing space after '{a}'.",
- nexttoken, left.value);
- }
- }
- }
-
- function nobreaknonadjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (!option.laxbreak && left.line !== right.line) {
- warning("Bad line breaking before '{a}'.", right, right.id);
- } else if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.character === right.from) {
- warning("Missing space after '{a}'.",
- nexttoken, left.value);
- }
- }
- }
-
- function indentation(bias) {
- var i;
- if (option.white && nexttoken.id !== '(end)') {
- i = indent + (bias || 0);
- if (nexttoken.from !== i) {
- warning(
-"Expected '{a}' to have an indentation at {b} instead at {c}.",
- nexttoken, nexttoken.value, i, nexttoken.from);
- }
- }
- }
-
- function nolinebreak(t) {
- t = t || token;
- if (t.line !== nexttoken.line) {
- warning("Line breaking error '{a}'.", t, t.value);
- }
- }
-
-
- function comma() {
- if (token.line !== nexttoken.line) {
- if (!option.laxbreak) {
- warning("Bad line breaking before '{a}'.", token, nexttoken.id);
- }
- } else if (token.character !== nexttoken.from && option.white) {
- warning("Unexpected space after '{a}'.", nexttoken, token.value);
- }
- advance(',');
- nonadjacent(token, nexttoken);
- }
-
-
-// Functional constructors for making the symbols that will be inherited by
-// tokens.
-
- function symbol(s, p) {
- var x = syntax[s];
- if (!x || typeof x !== 'object') {
- syntax[s] = x = {
- id: s,
- lbp: p,
- value: s
- };
- }
- return x;
- }
-
-
- function delim(s) {
- return symbol(s, 0);
- }
-
-
- function stmt(s, f) {
- var x = delim(s);
- x.identifier = x.reserved = true;
- x.fud = f;
- return x;
- }
-
-
- function blockstmt(s, f) {
- var x = stmt(s, f);
- x.block = true;
- return x;
- }
-
-
- function reserveName(x) {
- var c = x.id.charAt(0);
- if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
- x.identifier = x.reserved = true;
- }
- return x;
- }
-
-
- function prefix(s, f) {
- var x = symbol(s, 150);
- reserveName(x);
- x.nud = (typeof f === 'function') ? f : function () {
- this.right = expression(150);
- this.arity = 'unary';
- if (this.id === '++' || this.id === '--') {
- if (option.plusplus) {
- warning("Unexpected use of '{a}'.", this, this.id);
- } else if ((!this.right.identifier || this.right.reserved) &&
- this.right.id !== '.' && this.right.id !== '[') {
- warning("Bad operand.", this);
- }
- }
- return this;
- };
- return x;
- }
-
-
- function type(s, f) {
- var x = delim(s);
- x.type = s;
- x.nud = f;
- return x;
- }
-
-
- function reserve(s, f) {
- var x = type(s, f);
- x.identifier = x.reserved = true;
- return x;
- }
-
-
- function reservevar(s, v) {
- return reserve(s, function () {
- if (typeof v === 'function') {
- v(this);
- }
- return this;
- });
- }
-
-
- function infix(s, f, p, w) {
- var x = symbol(s, p);
- reserveName(x);
- x.led = function (left) {
- if (!w) {
- nobreaknonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- }
- if (typeof f === 'function') {
- return f(left, this);
- } else {
- this.left = left;
- this.right = expression(p);
- return this;
- }
- };
- return x;
- }
-
-
- function relation(s, f) {
- var x = symbol(s, 100);
- x.led = function (left) {
- nobreaknonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- var right = expression(100);
- if ((left && left.id === 'NaN') || (right && right.id === 'NaN')) {
- warning("Use the isNaN function to compare with NaN.", this);
- } else if (f) {
- f.apply(this, [left, right]);
- }
- if (left.id === '!') {
- warning("Confusing use of '{a}'.", left, '!');
- }
- if (right.id === '!') {
- warning("Confusing use of '{a}'.", left, '!');
- }
- this.left = left;
- this.right = right;
- return this;
- };
- return x;
- }
-
-
- function isPoorRelation(node) {
- return node &&
- ((node.type === '(number)' && +node.value === 0) ||
- (node.type === '(string)' && node.value === '') ||
- (node.type === 'null' && !option.eqnull) ||
- node.type === 'true' ||
- node.type === 'false' ||
- node.type === 'undefined');
- }
-
-
- function assignop(s, f) {
- symbol(s, 20).exps = true;
- return infix(s, function (left, that) {
- var l;
- that.left = left;
- if (predefined[left.value] === false &&
- scope[left.value]['(global)'] === true) {
- warning("Read only.", left);
- } else if (left['function']) {
- warning("'{a}' is a function.", left, left.value);
- }
- if (left) {
- if (left.id === '.' || left.id === '[') {
- if (!left.left || left.left.value === 'arguments') {
- warning('Bad assignment.', that);
- }
- that.right = expression(19);
- return that;
- } else if (left.identifier && !left.reserved) {
- if (funct[left.value] === 'exception') {
- warning("Do not assign to the exception parameter.", left);
- }
- that.right = expression(19);
- return that;
- }
- if (left === syntax['function']) {
- warning(
-"Expected an identifier in an assignment and instead saw a function invocation.",
- token);
- }
- }
- error("Bad assignment.", that);
- }, 20);
- }
-
-
- function bitwise(s, f, p) {
- var x = symbol(s, p);
- reserveName(x);
- x.led = (typeof f === 'function') ? f : function (left) {
- if (option.bitwise) {
- warning("Unexpected use of '{a}'.", this, this.id);
- }
- this.left = left;
- this.right = expression(p);
- return this;
- };
- return x;
- }
-
-
- function bitwiseassignop(s) {
- symbol(s, 20).exps = true;
- return infix(s, function (left, that) {
- if (option.bitwise) {
- warning("Unexpected use of '{a}'.", that, that.id);
- }
- nonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- if (left) {
- if (left.id === '.' || left.id === '[' ||
- (left.identifier && !left.reserved)) {
- expression(19);
- return that;
- }
- if (left === syntax['function']) {
- warning(
-"Expected an identifier in an assignment, and instead saw a function invocation.",
- token);
- }
- return that;
- }
- error("Bad assignment.", that);
- }, 20);
- }
-
-
- function suffix(s, f) {
- var x = symbol(s, 150);
- x.led = function (left) {
- if (option.plusplus) {
- warning("Unexpected use of '{a}'.", this, this.id);
- } else if ((!left.identifier || left.reserved) &&
- left.id !== '.' && left.id !== '[') {
- warning("Bad operand.", this);
- }
- this.left = left;
- return this;
- };
- return x;
- }
-
-
- // fnparam means that this identifier is being defined as a function
- // argument (see identifier())
- function optionalidentifier(fnparam) {
- if (nexttoken.identifier) {
- advance();
- if (token.reserved && !option.es5) {
- // `undefined` as a function param is a common pattern to protect
- // against the case when somebody does `undefined = true` and
- // help with minification. More info: https://gist.github.com/315916
- if (!fnparam || token.value != 'undefined') {
- warning("Expected an identifier and instead saw '{a}' (a reserved word).",
- token, token.id);
- }
- }
- return token.value;
- }
- }
-
- // fnparam means that this identifier is being defined as a function
- // argument
- function identifier(fnparam) {
- var i = optionalidentifier(fnparam);
- if (i) {
- return i;
- }
- if (token.id === 'function' && nexttoken.id === '(') {
- warning("Missing name in function declaration.");
- } else {
- error("Expected an identifier and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- }
-
-
- function reachable(s) {
- var i = 0, t;
- if (nexttoken.id !== ';' || noreach) {
- return;
- }
- for (;;) {
- t = peek(i);
- if (t.reach) {
- return;
- }
- if (t.id !== '(endline)') {
- if (t.id === 'function') {
- warning(
-"Inner functions should be listed at the top of the outer function.", t);
- break;
- }
- warning("Unreachable '{a}' after '{b}'.", t, t.value, s);
- break;
- }
- i += 1;
- }
- }
-
-
- function statement(noindent) {
- var i = indent, r, s = scope, t = nexttoken;
-
-// We don't like the empty statement.
-
- if (t.id === ';') {
- warning("Unnecessary semicolon.", t);
- advance(';');
- return;
- }
-
-// Is this a labelled statement?
-
- if (t.identifier && !t.reserved && peek().id === ':') {
- advance();
- advance(':');
- scope = Object.create(s);
- addlabel(t.value, 'label');
- if (!nexttoken.labelled) {
- warning("Label '{a}' on {b} statement.",
- nexttoken, t.value, nexttoken.value);
- }
- if (jx.test(t.value + ':')) {
- warning("Label '{a}' looks like a javascript url.",
- t, t.value);
- }
- nexttoken.label = t.value;
- t = nexttoken;
- }
-
-// Parse the statement.
-
- if (!noindent) {
- indentation();
- }
- r = expression(0, true);
-
-// Look for the final semicolon.
-
- if (!t.block) {
- if (!option.expr && (!r || !r.exps)) {
- warning("Expected an assignment or function call and instead saw an expression.", token);
- } else if (option.nonew && r.id === '(' && r.left.id === 'new') {
- warning("Do not use 'new' for side effects.");
- }
- if (nexttoken.id !== ';') {
- if (!option.asi) {
- warningAt("Missing semicolon.", token.line, token.from + token.value.length);
- }
- } else {
- adjacent(token, nexttoken);
- advance(';');
- nonadjacent(token, nexttoken);
- }
- }
-
-// Restore the indentation.
-
- indent = i;
- scope = s;
- return r;
- }
-
-
- function use_strict() {
- if (nexttoken.value === 'use strict') {
- if (strict_mode) {
- warning("Unnecessary \"use strict\".");
- }
- advance();
- advance(';');
- strict_mode = true;
- option.newcap = true;
- option.undef = true;
- return true;
- } else {
- return false;
- }
- }
-
-
- function statements(begin) {
- var a = [], f, p;
-
- while (!nexttoken.reach && nexttoken.id !== '(end)') {
- if (nexttoken.id === ';') {
- warning("Unnecessary semicolon.");
- advance(';');
- } else {
- a.push(statement());
- }
- }
- return a;
- }
-
-
- /*
- * Parses a single block. A block is a sequence of statements wrapped in
- * braces.
- *
- * ordinary - true for everything but function bodies and try blocks.
- * stmt - true if block can be a single statement (e.g. in if/for/while).
- */
- function block(ordinary, stmt) {
- var a,
- b = inblock,
- old_indent = indent,
- m = strict_mode,
- s = scope,
- t;
-
- inblock = ordinary;
- scope = Object.create(scope);
- nonadjacent(token, nexttoken);
- t = nexttoken;
-
- if (nexttoken.id === '{') {
- advance('{');
- if (nexttoken.id !== '}' || token.line !== nexttoken.line) {
- indent += option.indent;
- while (!ordinary && nexttoken.from > indent) {
- indent += option.indent;
- }
- if (!ordinary && !use_strict() && !m && option.strict &&
- funct['(context)']['(global)']) {
- warning("Missing \"use strict\" statement.");
- }
- a = statements();
- strict_mode = m;
- indent -= option.indent;
- indentation();
- }
- advance('}', t);
- indent = old_indent;
- } else if (!ordinary) {
- error("Expected '{a}' and instead saw '{b}'.",
- nexttoken, '{', nexttoken.value);
- } else {
- if (!stmt || option.curly)
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, '{', nexttoken.value);
-
- noreach = true;
- a = [statement()];
- noreach = false;
- }
- funct['(verb)'] = null;
- scope = s;
- inblock = b;
- if (ordinary && option.noempty && (!a || a.length === 0)) {
- warning("Empty block.");
- }
- return a;
- }
-
-
- function countMember(m) {
- if (membersOnly && typeof membersOnly[m] !== 'boolean') {
- warning("Unexpected /*member '{a}'.", token, m);
- }
- if (typeof member[m] === 'number') {
- member[m] += 1;
- } else {
- member[m] = 1;
- }
- }
-
-
- function note_implied(token) {
- var name = token.value, line = token.line, a = implied[name];
- if (typeof a === 'function') {
- a = false;
- }
- if (!a) {
- a = [line];
- implied[name] = a;
- } else if (a[a.length - 1] !== line) {
- a.push(line);
- }
- }
-
-// Build the syntax table by declaring the syntactic elements of the language.
-
- type('(number)', function () {
- return this;
- });
- type('(string)', function () {
- return this;
- });
-
- syntax['(identifier)'] = {
- type: '(identifier)',
- lbp: 0,
- identifier: true,
- nud: function () {
- var v = this.value,
- s = scope[v],
- f;
- if (typeof s === 'function') {
-
-// Protection against accidental inheritance.
-
- s = undefined;
- } else if (typeof s === 'boolean') {
- f = funct;
- funct = functions[0];
- addlabel(v, 'var');
- s = funct;
- funct = f;
- }
-
-// The name is in scope and defined in the current function.
-
- if (funct === s) {
-
-// Change 'unused' to 'var', and reject labels.
-
- switch (funct[v]) {
- case 'unused':
- funct[v] = 'var';
- break;
- case 'unction':
- funct[v] = 'function';
- this['function'] = true;
- break;
- case 'function':
- this['function'] = true;
- break;
- case 'label':
- warning("'{a}' is a statement label.", token, v);
- break;
- }
-
-// The name is not defined in the function. If we are in the global scope,
-// then we have an undefined variable.
-//
-// Operators typeof and delete do not raise runtime errors even if the base
-// object of a reference is null so no need to display warning if we're
-// inside of typeof or delete.
-
- } else if (funct['(global)']) {
- if (anonname != 'typeof' && anonname != 'delete' &&
- option.undef && typeof predefined[v] !== 'boolean') {
- warning("'{a}' is not defined.", token, v
<TRUNCATED>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[09/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
index 6c34fbe..5e5a969 100644
--- a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
@@ -1,3854 +1,3854 @@
-/*
- * JSHint, by JSHint Community.
- *
- * Licensed under the same slightly modified MIT license that JSLint is.
- * It stops evil-doers everywhere.
- *
- * JSHint is a derivative work of JSLint:
- *
- * Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * The Software shall be used for Good, not Evil.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * JSHint was forked from 2010-12-16 edition of JSLint.
- *
- */
-
-/*
- JSHINT is a global function. It takes two parameters.
-
- var myResult = JSHINT(source, option);
-
- The first parameter is either a string or an array of strings. If it is a
- string, it will be split on '\n' or '\r'. If it is an array of strings, it
- is assumed that each string represents one line. The source can be a
- JavaScript text or a JSON text.
-
- The second parameter is an optional object of options which control the
- operation of JSHINT. Most of the options are booleans: They are all
- optional and have a default value of false. One of the options, predef,
- can be an array of names, which will be used to declare global variables,
- or an object whose keys are used as global names, with a boolean value
- that determines if they are assignable.
-
- If it checks out, JSHINT returns true. Otherwise, it returns false.
-
- If false, you can inspect JSHINT.errors to find out the problems.
- JSHINT.errors is an array of objects containing these members:
-
- {
- line : The line (relative to 0) at which the lint was found
- character : The character (relative to 0) at which the lint was found
- reason : The problem
- evidence : The text line in which the problem occurred
- raw : The raw message before the details were inserted
- a : The first detail
- b : The second detail
- c : The third detail
- d : The fourth detail
- }
-
- If a fatal error was found, a null will be the last element of the
- JSHINT.errors array.
-
- You can request a Function Report, which shows all of the functions
- and the parameters and vars that they use. This can be used to find
- implied global variables and other problems. The report is in HTML and
- can be inserted in an HTML <body>.
-
- var myReport = JSHINT.report(limited);
-
- If limited is true, then the report will be limited to only errors.
-
- You can request a data structure which contains JSHint's results.
-
- var myData = JSHINT.data();
-
- It returns a structure with this form:
-
- {
- errors: [
- {
- line: NUMBER,
- character: NUMBER,
- reason: STRING,
- evidence: STRING
- }
- ],
- functions: [
- name: STRING,
- line: NUMBER,
- last: NUMBER,
- param: [
- STRING
- ],
- closure: [
- STRING
- ],
- var: [
- STRING
- ],
- exception: [
- STRING
- ],
- outer: [
- STRING
- ],
- unused: [
- STRING
- ],
- global: [
- STRING
- ],
- label: [
- STRING
- ]
- ],
- globals: [
- STRING
- ],
- member: {
- STRING: NUMBER
- },
- unuseds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- implieds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- urls: [
- STRING
- ],
- json: BOOLEAN
- }
-
- Empty arrays will not be included.
-
-*/
-
-/*jshint
- evil: true, nomen: false, onevar: false, regexp: false, strict: true, boss: true
-*/
-
-/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
- "(begin)", "(breakage)", "(context)", "(error)", "(global)",
- "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
- "(params)", "(scope)", "(statement)", "(verb)", "*", "+", "++", "-",
- "--", "\/", "<", "<=", "==", "===", ">", ">=", $, $$, $A, $F, $H, $R, $break,
- $continue, $w, Abstract, Ajax, __filename, __dirname, ActiveXObject, Array,
- ArrayBuffer, ArrayBufferView, Autocompleter, Assets, Boolean, Builder,
- Buffer, Browser, COM, CScript, Canvas, CustomAnimation, Class, Control,
- Chain, Color, Cookie, Core, DataView, Date, Debug, Draggable, Draggables,
- Droppables, Document, DomReady, DOMReady, Drag, E, Enumerator, Enumerable,
- Element, Elements, Error, Effect, EvalError, Event, Events, FadeAnimation,
- Field, Flash, Float32Array, Float64Array, Form, FormField, Frame, Function,
- Fx, Group, Hash, HotKey, HTMLElement, HtmlTable, Iframe, IframeShim, Image,
- Int16Array, Int32Array, Int8Array, Insertion, InputValidator, JSON, Keyboard,
- Locale, LN10, LN2, LOG10E, LOG2E, MAX_VALUE, MIN_VALUE, Mask, Math, MenuItem,
- MoveAnimation, MooTools, Native, NEGATIVE_INFINITY, Number, Object,
- ObjectRange, Option, Options, OverText, PI, POSITIVE_INFINITY,
- PeriodicalExecuter, Point, Position, Prototype, RangeError, Rectangle,
- ReferenceError, RegExp, ResizeAnimation, Request, RotateAnimation, SQRT1_2,
- SQRT2, ScrollBar, Scriptaculous, Scroller, Slick, Slider, Selector, String,
- Style, SyntaxError, Sortable, Sortables, SortableObserver, Sound, Spinner,
- System, Swiff, Text, TextArea, Template, Timer, Tips, Type, TypeError,
- Toggle, Try, URI, URIError, URL, VBArray, WScript, Web, Window, XMLDOM,
- XMLHttpRequest, XPathEvaluator, XPathException, XPathExpression,
- XPathNamespace, XPathNSResolver, XPathResult, "\\", a, addEventListener,
- address, alert, apply, applicationCache, arguments, arity, asi, b, bitwise,
- block, blur, boolOptions, boss, browser, c, call, callee, caller, cases,
- charAt, charCodeAt, character, clearInterval, clearTimeout, close, closed,
- closure, comment, condition, confirm, console, constructor, content, couch,
- create, css, curly, d, data, datalist, dd, debug, decodeURI,
- decodeURIComponent, defaultStatus, defineClass, deserialize, devel,
- document, edition, else, emit, encodeURI, encodeURIComponent, entityify,
- eqeqeq, eqnull, errors, es5, escape, eval, event, evidence, evil, ex,
- exception, exec, exps, expr, exports, FileReader, first, floor, focus,
- forin, fragment, frames, from, fromCharCode, fud, funct, function, functions,
- g, gc, getComputedStyle, getRow, GLOBAL, global, globals, globalstrict,
- hasOwnProperty, help, history, i, id, identifier, immed, implieds,
- include, indent, indexOf, init, ins, instanceOf, isAlpha,
- isApplicationRunning, isArray, isDigit, isFinite, isNaN, join, jshint,
- JSHINT, json, jquery, jQuery, keys, label, labelled, last, laxbreak,
- latedef, lbp, led, left, length, line, load, loadClass, localStorage,
- location, log, loopfunc, m, match, maxerr, maxlen, member,message, meta,
- module, moveBy, moveTo, mootools, name, navigator, new, newcap, noarg,
- node, noempty, nomen, nonew, nud, onbeforeunload, onblur, onerror, onevar,
- onfocus, onload, onresize, onunload, open, openDatabase, openURL, opener,
- opera, outer, param, parent, parseFloat, parseInt, passfail, plusplus,
- predef, print, process, prompt, prototype, prototypejs, push, quit, range,
- raw, reach, reason, regexp, readFile, readUrl, removeEventListener, replace,
- report, require, reserved, resizeBy, resizeTo, resolvePath, resumeUpdates,
- respond, rhino, right, runCommand, scroll, screen, scrollBy, scrollTo,
- scrollbar, search, seal, send, serialize, setInterval, setTimeout, shift,
- slice, sort,spawn, split, stack, status, start, strict, sub, substr, supernew,
- shadow, supplant, sum, sync, test, toLowerCase, toString, toUpperCase, toint32,
- token, top, type, typeOf, Uint16Array, Uint32Array, Uint8Array, undef,
- unused, urls, value, valueOf, var, version, WebSocket, white, window, Worker
-*/
-
-/*global exports: false */
-
-// We build the application inside a function so that we produce only a single
-// global variable. That function will be invoked immediately, and its return
-// value is the JSHINT function itself.
-
-var JSHINT = (function () {
- "use strict";
-
- var anonname, // The guessed name for anonymous functions.
-
-// These are operators that should not be used with the ! operator.
-
- bang = {
- '<' : true,
- '<=' : true,
- '==' : true,
- '===': true,
- '!==': true,
- '!=' : true,
- '>' : true,
- '>=' : true,
- '+' : true,
- '-' : true,
- '*' : true,
- '/' : true,
- '%' : true
- },
-
-// These are the JSHint boolean options.
-
- boolOptions = {
- asi : true, // if automatic semicolon insertion should be tolerated
- bitwise : true, // if bitwise operators should not be allowed
- boss : true, // if advanced usage of assignments should be allowed
- browser : true, // if the standard browser globals should be predefined
- couch : true, // if CouchDB globals should be predefined
- curly : true, // if curly braces around blocks should be required (even in if/for/while)
- debug : true, // if debugger statements should be allowed
- devel : true, // if logging globals should be predefined (console, alert, etc.)
- eqeqeq : true, // if === should be required
- eqnull : true, // if == null comparisons should be tolerated
- es5 : true, // if ES5 syntax should be allowed
- evil : true, // if eval should be allowed
- expr : true, // if ExpressionStatement should be allowed as Programs
- forin : true, // if for in statements must filter
- globalstrict: true, // if global "use strict"; should be allowed (also enables 'strict')
- immed : true, // if immediate invocations must be wrapped in parens
- jquery : true, // if jQuery globals should be predefined
- latedef : true, // if the use before definition should not be tolerated
- laxbreak : true, // if line breaks should not be checked
- loopfunc : true, // if functions should be allowed to be defined within loops
- mootools : true, // if MooTools globals should be predefined
- newcap : true, // if constructor names must be capitalized
- noarg : true, // if arguments.caller and arguments.callee should be disallowed
- node : true, // if the Node.js environment globals should be predefined
- noempty : true, // if empty blocks should be disallowed
- nonew : true, // if using `new` for side-effects should be disallowed
- nomen : true, // if names should be checked
- onevar : true, // if only one var statement per function should be allowed
- passfail : true, // if the scan should stop on first error
- plusplus : true, // if increment/decrement should not be allowed
- prototypejs : true, // if Prototype and Scriptaculous globals shoudl be predefined
- regexp : true, // if the . should not be allowed in regexp literals
- rhino : true, // if the Rhino environment globals should be predefined
- undef : true, // if variables should be declared before used
- shadow : true, // if variable shadowing should be tolerated
- strict : true, // require the "use strict"; pragma
- sub : true, // if all forms of subscript notation are tolerated
- supernew : true, // if `new function () { ... };` and `new Object;` should be tolerated
- white : true // if strict whitespace rules apply
- },
-
-// browser contains a set of global names which are commonly provided by a
-// web browser environment.
-
- browser = {
- ArrayBuffer : false,
- ArrayBufferView : false,
- addEventListener: false,
- applicationCache: false,
- blur : false,
- clearInterval : false,
- clearTimeout : false,
- close : false,
- closed : false,
- DataView : false,
- defaultStatus : false,
- document : false,
- event : false,
- FileReader : false,
- Float32Array : false,
- Float64Array : false,
- focus : false,
- frames : false,
- getComputedStyle: false,
- HTMLElement : false,
- history : false,
- Int16Array : false,
- Int32Array : false,
- Int8Array : false,
- Image : false,
- length : false,
- localStorage : false,
- location : false,
- moveBy : false,
- moveTo : false,
- name : false,
- navigator : false,
- onbeforeunload : true,
- onblur : true,
- onerror : true,
- onfocus : true,
- onload : true,
- onresize : true,
- onunload : true,
- open : false,
- openDatabase : false,
- opener : false,
- Option : false,
- parent : false,
- print : false,
- removeEventListener: false,
- resizeBy : false,
- resizeTo : false,
- screen : false,
- scroll : false,
- scrollBy : false,
- scrollTo : false,
- setInterval : false,
- setTimeout : false,
- status : false,
- top : false,
- Uint16Array : false,
- Uint32Array : false,
- Uint8Array : false,
- WebSocket : false,
- window : false,
- Worker : false,
- XMLHttpRequest : false,
- XPathEvaluator : false,
- XPathException : false,
- XPathExpression : false,
- XPathNamespace : false,
- XPathNSResolver : false,
- XPathResult : false
- },
-
- couch = {
- "require" : false,
- respond : false,
- getRow : false,
- emit : false,
- send : false,
- start : false,
- sum : false,
- log : false,
- exports : false,
- module : false
- },
-
- devel = {
- alert : false,
- confirm : false,
- console : false,
- Debug : false,
- opera : false,
- prompt : false
- },
-
- escapes = {
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '/' : '\\/',
- '\\': '\\\\'
- },
-
- funct, // The current function
-
- functionicity = [
- 'closure', 'exception', 'global', 'label',
- 'outer', 'unused', 'var'
- ],
-
- functions, // All of the functions
-
- global, // The global scope
- implied, // Implied globals
- inblock,
- indent,
- jsonmode,
-
- jquery = {
- '$' : false,
- jQuery : false
- },
-
- lines,
- lookahead,
- member,
- membersOnly,
-
- mootools = {
- '$' : false,
- '$$' : false,
- Assets : false,
- Browser : false,
- Chain : false,
- Class : false,
- Color : false,
- Cookie : false,
- Core : false,
- Document : false,
- DomReady : false,
- DOMReady : false,
- Drag : false,
- Element : false,
- Elements : false,
- Event : false,
- Events : false,
- Fx : false,
- Group : false,
- Hash : false,
- HtmlTable : false,
- Iframe : false,
- IframeShim : false,
- InputValidator : false,
- instanceOf : false,
- Keyboard : false,
- Locale : false,
- Mask : false,
- MooTools : false,
- Native : false,
- Options : false,
- OverText : false,
- Request : false,
- Scroller : false,
- Slick : false,
- Slider : false,
- Sortables : false,
- Spinner : false,
- Swiff : false,
- Tips : false,
- Type : false,
- typeOf : false,
- URI : false,
- Window : false
- },
-
- nexttoken,
-
- node = {
- __filename : false,
- __dirname : false,
- exports : false,
- Buffer : false,
- GLOBAL : false,
- global : false,
- module : false,
- process : false,
- require : false
- },
-
- noreach,
- option,
- predefined, // Global variables defined by option
- prereg,
- prevtoken,
-
- prototypejs = {
- '$' : false,
- '$$' : false,
- '$A' : false,
- '$F' : false,
- '$H' : false,
- '$R' : false,
- '$break' : false,
- '$continue' : false,
- '$w' : false,
- Abstract : false,
- Ajax : false,
- Class : false,
- Enumerable : false,
- Element : false,
- Event : false,
- Field : false,
- Form : false,
- Hash : false,
- Insertion : false,
- ObjectRange : false,
- PeriodicalExecuter: false,
- Position : false,
- Prototype : false,
- Selector : false,
- Template : false,
- Toggle : false,
- Try : false,
- Autocompleter : false,
- Builder : false,
- Control : false,
- Draggable : false,
- Draggables : false,
- Droppables : false,
- Effect : false,
- Sortable : false,
- SortableObserver : false,
- Sound : false,
- Scriptaculous : false
- },
-
- rhino = {
- defineClass : false,
- deserialize : false,
- gc : false,
- help : false,
- load : false,
- loadClass : false,
- print : false,
- quit : false,
- readFile : false,
- readUrl : false,
- runCommand : false,
- seal : false,
- serialize : false,
- spawn : false,
- sync : false,
- toint32 : false,
- version : false
- },
-
- scope, // The current scope
- src,
- stack,
-
-// standard contains the global names that are provided by the
-// ECMAScript standard.
-
- standard = {
- Array : false,
- Boolean : false,
- Date : false,
- decodeURI : false,
- decodeURIComponent : false,
- encodeURI : false,
- encodeURIComponent : false,
- Error : false,
- 'eval' : false,
- EvalError : false,
- Function : false,
- hasOwnProperty : false,
- isFinite : false,
- isNaN : false,
- JSON : false,
- Math : false,
- Number : false,
- Object : false,
- parseInt : false,
- parseFloat : false,
- RangeError : false,
- ReferenceError : false,
- RegExp : false,
- String : false,
- SyntaxError : false,
- TypeError : false,
- URIError : false
- },
-
- standard_member = {
- E : true,
- LN2 : true,
- LN10 : true,
- LOG2E : true,
- LOG10E : true,
- MAX_VALUE : true,
- MIN_VALUE : true,
- NEGATIVE_INFINITY : true,
- PI : true,
- POSITIVE_INFINITY : true,
- SQRT1_2 : true,
- SQRT2 : true
- },
-
- strict_mode,
- syntax = {},
- tab,
- token,
- urls,
- warnings,
-
-// Regular expressions. Some of these are stupidly long.
-
-// unsafe comment or string
- ax = /@cc|<\/?|script|\]\s*\]|<\s*!|</i,
-// unsafe characters that are silently deleted by one or more browsers
- cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
-// token
- tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jshint|jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
-// characters in strings that need escapement
- nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
- nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
-// star slash
- lx = /\*\/|\/\*/,
-// identifier
- ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
-// javascript url
- jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
-// catches /* falls through */ comments
- ft = /^\s*\/\*\s*falls\sthrough\s*\*\/\s*$/;
-
- function F() {} // Used by Object.create
-
- function is_own(object, name) {
-
-// The object.hasOwnProperty method fails when the property under consideration
-// is named 'hasOwnProperty'. So we have to use this more convoluted form.
-
- return Object.prototype.hasOwnProperty.call(object, name);
- }
-
-// Provide critical ES5 functions to ES3.
-
- if (typeof Array.isArray !== 'function') {
- Array.isArray = function (o) {
- return Object.prototype.toString.apply(o) === '[object Array]';
- };
- }
-
- if (typeof Object.create !== 'function') {
- Object.create = function (o) {
- F.prototype = o;
- return new F();
- };
- }
-
- if (typeof Object.keys !== 'function') {
- Object.keys = function (o) {
- var a = [], k;
- for (k in o) {
- if (is_own(o, k)) {
- a.push(k);
- }
- }
- return a;
- };
- }
-
-// Non standard methods
-
- if (typeof String.prototype.entityify !== 'function') {
- String.prototype.entityify = function () {
- return this
- .replace(/&/g, '&')
- .replace(/</g, '<')
- .replace(/>/g, '>');
- };
- }
-
- if (typeof String.prototype.isAlpha !== 'function') {
- String.prototype.isAlpha = function () {
- return (this >= 'a' && this <= 'z\uffff') ||
- (this >= 'A' && this <= 'Z\uffff');
- };
- }
-
- if (typeof String.prototype.isDigit !== 'function') {
- String.prototype.isDigit = function () {
- return (this >= '0' && this <= '9');
- };
- }
-
- if (typeof String.prototype.supplant !== 'function') {
- String.prototype.supplant = function (o) {
- return this.replace(/\{([^{}]*)\}/g, function (a, b) {
- var r = o[b];
- return typeof r === 'string' || typeof r === 'number' ? r : a;
- });
- };
- }
-
- if (typeof String.prototype.name !== 'function') {
- String.prototype.name = function () {
-
-// If the string looks like an identifier, then we can return it as is.
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can simply slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe
-// sequences.
-
- if (ix.test(this)) {
- return this;
- }
- if (nx.test(this)) {
- return '"' + this.replace(nxg, function (a) {
- var c = escapes[a];
- if (c) {
- return c;
- }
- return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
- }) + '"';
- }
- return '"' + this + '"';
- };
- }
-
-
- function combine(t, o) {
- var n;
- for (n in o) {
- if (is_own(o, n)) {
- t[n] = o[n];
- }
- }
- }
-
- function assume() {
- if (option.couch)
- combine(predefined, couch);
-
- if (option.rhino)
- combine(predefined, rhino);
-
- if (option.prototypejs)
- combine(predefined, prototypejs);
-
- if (option.node)
- combine(predefined, node);
-
- if (option.devel)
- combine(predefined, devel);
-
- if (option.browser)
- combine(predefined, browser);
-
- if (option.jquery)
- combine(predefined, jquery);
-
- if (option.mootools)
- combine(predefined, mootools);
-
- if (option.globalstrict)
- option.strict = true;
- }
-
-
-// Produce an error warning.
-
- function quit(m, l, ch) {
- throw {
- name: 'JSHintError',
- line: l,
- character: ch,
- message: m + " (" + Math.floor((l / lines.length) * 100) +
- "% scanned)."
- };
- }
-
- function warning(m, t, a, b, c, d) {
- var ch, l, w;
- t = t || nexttoken;
- if (t.id === '(end)') { // `~
- t = token;
- }
- l = t.line || 0;
- ch = t.from || 0;
- w = {
- id: '(error)',
- raw: m,
- evidence: lines[l - 1] || '',
- line: l,
- character: ch,
- a: a,
- b: b,
- c: c,
- d: d
- };
- w.reason = m.supplant(w);
- JSHINT.errors.push(w);
- if (option.passfail) {
- quit('Stopping. ', l, ch);
- }
- warnings += 1;
- if (warnings >= option.maxerr) {
- quit("Too many errors.", l, ch);
- }
- return w;
- }
-
- function warningAt(m, l, ch, a, b, c, d) {
- return warning(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
- function error(m, t, a, b, c, d) {
- var w = warning(m, t, a, b, c, d);
- quit("Stopping, unable to continue.", w.line, w.character);
- }
-
- function errorAt(m, l, ch, a, b, c, d) {
- return error(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
-
-
-// lexical analysis and token construction
-
- var lex = (function lex() {
- var character, from, line, s;
-
-// Private lex methods
-
- function nextLine() {
- var at,
- tw; // trailing whitespace check
-
- if (line >= lines.length)
- return false;
-
- character = 1;
- s = lines[line];
- line += 1;
- at = s.search(/ \t/);
-
- if (at >= 0)
- warningAt("Mixed spaces and tabs.", line, at + 1);
-
- s = s.replace(/\t/g, tab);
- at = s.search(cx);
-
- if (at >= 0)
- warningAt("Unsafe character.", line, at);
-
- if (option.maxlen && option.maxlen < s.length)
- warningAt("Line too long.", line, s.length);
-
- // Check for trailing whitespaces
- tw = s.search(/\s+$/);
- if (option.white && ~tw)
- warningAt("Trailing whitespace.", line, tw);
-
- return true;
- }
-
-// Produce a token object. The token inherits from a syntax symbol.
-
- function it(type, value) {
- var i, t;
- if (type === '(color)' || type === '(range)') {
- t = {type: type};
- } else if (type === '(punctuator)' ||
- (type === '(identifier)' && is_own(syntax, value))) {
- t = syntax[value] || syntax['(error)'];
- } else {
- t = syntax[type];
- }
- t = Object.create(t);
- if (type === '(string)' || type === '(range)') {
- if (jx.test(value)) {
- warningAt("Script URL.", line, from);
- }
- }
- if (type === '(identifier)') {
- t.identifier = true;
- if (value === '__iterator__' || value === '__proto__') {
- errorAt("Reserved name '{a}'.",
- line, from, value);
- } else if (option.nomen &&
- (value.charAt(0) === '_' ||
- value.charAt(value.length - 1) === '_')) {
- warningAt("Unexpected {a} in '{b}'.", line, from,
- "dangling '_'", value);
- }
- }
- t.value = value;
- t.line = line;
- t.character = character;
- t.from = from;
- i = t.id;
- if (i !== '(endline)') {
- prereg = i &&
- (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
- i === 'return');
- }
- return t;
- }
-
-// Public lex methods
-
- return {
- init: function (source) {
- if (typeof source === 'string') {
- lines = source
- .replace(/\r\n/g, '\n')
- .replace(/\r/g, '\n')
- .split('\n');
- } else {
- lines = source;
- }
-
- // If the first line is a shebang (#!), make it a blank and move on.
- // Shebangs are used by Node scripts.
- if (lines[0] && lines[0].substr(0, 2) == '#!')
- lines[0] = '';
-
- line = 0;
- nextLine();
- from = 1;
- },
-
- range: function (begin, end) {
- var c, value = '';
- from = character;
- if (s.charAt(0) !== begin) {
- errorAt("Expected '{a}' and instead saw '{b}'.",
- line, character, begin, s.charAt(0));
- }
- for (;;) {
- s = s.slice(1);
- character += 1;
- c = s.charAt(0);
- switch (c) {
- case '':
- errorAt("Missing '{a}'.", line, character, c);
- break;
- case end:
- s = s.slice(1);
- character += 1;
- return it('(range)', value);
- case '\\':
- warningAt("Unexpected '{a}'.", line, character, c);
- }
- value += c;
- }
-
- },
-
-// token -- this is called by advance to get the next token.
-
- token: function () {
- var b, c, captures, d, depth, high, i, l, low, q, t;
-
- function match(x) {
- var r = x.exec(s), r1;
- if (r) {
- l = r[0].length;
- r1 = r[1];
- c = r1.charAt(0);
- s = s.substr(l);
- from = character + l - r1.length;
- character += l;
- return r1;
- }
- }
-
- function string(x) {
- var c, j, r = '';
-
- if (jsonmode && x !== '"') {
- warningAt("Strings must use doublequote.",
- line, character);
- }
-
- function esc(n) {
- var i = parseInt(s.substr(j + 1, n), 16);
- j += n;
- if (i >= 32 && i <= 126 &&
- i !== 34 && i !== 92 && i !== 39) {
- warningAt("Unnecessary escapement.", line, character);
- }
- character += n;
- c = String.fromCharCode(i);
- }
- j = 0;
- for (;;) {
- while (j >= s.length) {
- j = 0;
- if (!nextLine()) {
- errorAt("Unclosed string.", line, from);
- }
- }
- c = s.charAt(j);
- if (c === x) {
- character += 1;
- s = s.substr(j + 1);
- return it('(string)', r, x);
- }
- if (c < ' ') {
- if (c === '\n' || c === '\r') {
- break;
- }
- warningAt("Control character in string: {a}.",
- line, character + j, s.slice(0, j));
- } else if (c === '\\') {
- j += 1;
- character += 1;
- c = s.charAt(j);
- switch (c) {
- case '\\':
- case '"':
- case '/':
- break;
- case '\'':
- if (jsonmode) {
- warningAt("Avoid \\'.", line, character);
- }
- break;
- case 'b':
- c = '\b';
- break;
- case 'f':
- c = '\f';
- break;
- case 'n':
- c = '\n';
- break;
- case 'r':
- c = '\r';
- break;
- case 't':
- c = '\t';
- break;
- case 'u':
- esc(4);
- break;
- case 'v':
- if (jsonmode) {
- warningAt("Avoid \\v.", line, character);
- }
- c = '\v';
- break;
- case 'x':
- if (jsonmode) {
- warningAt("Avoid \\x-.", line, character);
- }
- esc(2);
- break;
- default:
- warningAt("Bad escapement.", line, character);
- }
- }
- r += c;
- character += 1;
- j += 1;
- }
- }
-
- for (;;) {
- if (!s) {
- return it(nextLine() ? '(endline)' : '(end)', '');
- }
- t = match(tx);
- if (!t) {
- t = '';
- c = '';
- while (s && s < '!') {
- s = s.substr(1);
- }
- if (s) {
- errorAt("Unexpected '{a}'.", line, character, s.substr(0, 1));
- }
- } else {
-
- // identifier
-
- if (c.isAlpha() || c === '_' || c === '$') {
- return it('(identifier)', t);
- }
-
- // number
-
- if (c.isDigit()) {
- if (!isFinite(Number(t))) {
- warningAt("Bad number '{a}'.",
- line, character, t);
- }
- if (s.substr(0, 1).isAlpha()) {
- warningAt("Missing space after '{a}'.",
- line, character, t);
- }
- if (c === '0') {
- d = t.substr(1, 1);
- if (d.isDigit()) {
- if (token.id !== '.') {
- warningAt("Don't use extra leading zeros '{a}'.",
- line, character, t);
- }
- } else if (jsonmode && (d === 'x' || d === 'X')) {
- warningAt("Avoid 0x-. '{a}'.",
- line, character, t);
- }
- }
- if (t.substr(t.length - 1) === '.') {
- warningAt(
-"A trailing decimal point can be confused with a dot '{a}'.", line, character, t);
- }
- return it('(number)', t);
- }
- switch (t) {
-
- // string
-
- case '"':
- case "'":
- return string(t);
-
- // // comment
-
- case '//':
- if (src) {
- warningAt("Unexpected comment.", line, character);
- }
- s = '';
- token.comment = true;
- break;
-
- // /* comment
-
- case '/*':
- if (src) {
- warningAt("Unexpected comment.", line, character);
- }
- for (;;) {
- i = s.search(lx);
- if (i >= 0) {
- break;
- }
- if (!nextLine()) {
- errorAt("Unclosed comment.", line, character);
- }
- }
- character += i + 2;
- if (s.substr(i, 1) === '/') {
- errorAt("Nested comment.", line, character);
- }
- s = s.substr(i + 2);
- token.comment = true;
- break;
-
- // /*members /*jshint /*global
-
- case '/*members':
- case '/*member':
- case '/*jshint':
- case '/*jslint':
- case '/*global':
- case '*/':
- return {
- value: t,
- type: 'special',
- line: line,
- character: character,
- from: from
- };
-
- case '':
- break;
- // /
- case '/':
- if (token.id === '/=') {
- errorAt(
-"A regular expression literal can be confused with '/='.", line, from);
- }
- if (prereg) {
- depth = 0;
- captures = 0;
- l = 0;
- for (;;) {
- b = true;
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '':
- errorAt("Unclosed regular expression.",
- line, from);
- return;
- case '/':
- if (depth > 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, '/');
- }
- c = s.substr(0, l - 1);
- q = {
- g: true,
- i: true,
- m: true
- };
- while (q[s.charAt(l)] === true) {
- q[s.charAt(l)] = false;
- l += 1;
- }
- character += l;
- s = s.substr(l);
- q = s.charAt(0);
- if (q === '/' || q === '*') {
- errorAt("Confusing regular expression.",
- line, from);
- }
- return it('(regexp)', c);
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- break;
- case '(':
- depth += 1;
- b = false;
- if (s.charAt(l) === '?') {
- l += 1;
- switch (s.charAt(l)) {
- case ':':
- case '=':
- case '!':
- l += 1;
- break;
- default:
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
- }
- } else {
- captures += 1;
- }
- break;
- case '|':
- b = false;
- break;
- case ')':
- if (depth === 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, ')');
- } else {
- depth -= 1;
- }
- break;
- case ' ':
- q = 1;
- while (s.charAt(l) === ' ') {
- l += 1;
- q += 1;
- }
- if (q > 1) {
- warningAt(
-"Spaces are hard to count. Use {{a}}.", line, from + l, q);
- }
- break;
- case '[':
- c = s.charAt(l);
- if (c === '^') {
- l += 1;
- if (option.regexp) {
- warningAt("Insecure '{a}'.",
- line, from + l, c);
- } else if (s.charAt(l) === ']') {
- errorAt("Unescaped '{a}'.",
- line, from + l, '^');
- }
- }
- q = false;
- if (c === ']') {
- warningAt("Empty class.", line,
- from + l - 1);
- q = true;
- }
-klass: do {
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '[':
- case '^':
- warningAt("Unescaped '{a}'.",
- line, from + l, c);
- q = true;
- break;
- case '-':
- if (q) {
- q = false;
- } else {
- warningAt("Unescaped '{a}'.",
- line, from + l, '-');
- q = true;
- }
- break;
- case ']':
- if (!q) {
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, '-');
- }
- break klass;
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- q = true;
- break;
- case '/':
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, '/');
- q = true;
- break;
- case '<':
- q = true;
- break;
- default:
- q = true;
- }
- } while (c);
- break;
- case '.':
- if (option.regexp) {
- warningAt("Insecure '{a}'.", line,
- from + l, c);
- }
- break;
- case ']':
- case '?':
- case '{':
- case '}':
- case '+':
- case '*':
- warningAt("Unescaped '{a}'.", line,
- from + l, c);
- }
- if (b) {
- switch (s.charAt(l)) {
- case '?':
- case '+':
- case '*':
- l += 1;
- if (s.charAt(l) === '?') {
- l += 1;
- }
- break;
- case '{':
- l += 1;
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- warningAt(
-"Expected a number and instead saw '{a}'.", line, from + l, c);
- }
- l += 1;
- low = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- low = +c + (low * 10);
- }
- high = low;
- if (c === ',') {
- l += 1;
- high = Infinity;
- c = s.charAt(l);
- if (c >= '0' && c <= '9') {
- l += 1;
- high = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- high = +c + (high * 10);
- }
- }
- }
- if (s.charAt(l) !== '}') {
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
- } else {
- l += 1;
- }
- if (s.charAt(l) === '?') {
- l += 1;
- }
- if (low > high) {
- warningAt(
-"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
- }
- }
- }
- }
- c = s.substr(0, l - 1);
- character += l;
- s = s.substr(l);
- return it('(regexp)', c);
- }
- return it('(punctuator)', t);
-
- // punctuator
-
- case '#':
- return it('(punctuator)', t);
- default:
- return it('(punctuator)', t);
- }
- }
- }
- }
- };
- }());
-
-
- function addlabel(t, type) {
-
- if (t === 'hasOwnProperty') {
- warning("'hasOwnProperty' is a really bad name.");
- }
-
-// Define t in the current function in the current scope.
-
- if (is_own(funct, t) && !funct['(global)']) {
- if (funct[t] === true) {
- if (option.latedef)
- warning("'{a}' was used before it was defined.", nexttoken, t);
- } else {
- if (!option.shadow)
- warning("'{a}' is already defined.", nexttoken, t);
- }
- }
-
- funct[t] = type;
- if (funct['(global)']) {
- global[t] = funct;
- if (is_own(implied, t)) {
- if (option.latedef)
- warning("'{a}' was used before it was defined.", nexttoken, t);
- delete implied[t];
- }
- } else {
- scope[t] = funct;
- }
- }
-
-
- function doOption() {
- var b, obj, filter, o = nexttoken.value, t, v;
- switch (o) {
- case '*/':
- error("Unbegun comment.");
- break;
- case '/*members':
- case '/*member':
- o = '/*members';
- if (!membersOnly) {
- membersOnly = {};
- }
- obj = membersOnly;
- break;
- case '/*jshint':
- case '/*jslint':
- obj = option;
- filter = boolOptions;
- break;
- case '/*global':
- obj = predefined;
- break;
- default:
- error("What?");
- }
- t = lex.token();
-loop: for (;;) {
- for (;;) {
- if (t.type === 'special' && t.value === '*/') {
- break loop;
- }
- if (t.id !== '(endline)' && t.id !== ',') {
- break;
- }
- t = lex.token();
- }
- if (t.type !== '(string)' && t.type !== '(identifier)' &&
- o !== '/*members') {
- error("Bad option.", t);
- }
- v = lex.token();
- if (v.id === ':') {
- v = lex.token();
- if (obj === membersOnly) {
- error("Expected '{a}' and instead saw '{b}'.",
- t, '*/', ':');
- }
- if (t.value === 'indent' && (o === '/*jshint' || o === '/*jslint')) {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.white = true;
- obj.indent = b;
- } else if (t.value === 'maxerr' && (o === '/*jshint' || o === '/*jslint')) {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxerr = b;
- } else if (t.value === 'maxlen' && (o === '/*jshint' || o === '/*jslint')) {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxlen = b;
- } else if (v.value === 'true') {
- obj[t.value] = true;
- } else if (v.value === 'false') {
- obj[t.value] = false;
- } else {
- error("Bad option value.", v);
- }
- t = lex.token();
- } else {
- if (o === '/*jshint' || o === '/*jslint') {
- error("Missing option value.", t);
- }
- obj[t.value] = false;
- t = v;
- }
- }
- if (filter) {
- assume();
- }
- }
-
-
-// We need a peek function. If it has an argument, it peeks that much farther
-// ahead. It is used to distinguish
-// for ( var i in ...
-// from
-// for ( var i = ...
-
- function peek(p) {
- var i = p || 0, j = 0, t;
-
- while (j <= i) {
- t = lookahead[j];
- if (!t) {
- t = lookahead[j] = lex.token();
- }
- j += 1;
- }
- return t;
- }
-
-
-
-// Produce the next token. It looks for programming errors.
-
- function advance(id, t) {
- switch (token.id) {
- case '(number)':
- if (nexttoken.id === '.') {
- warning("A dot following a number can be confused with a decimal point.", token);
- }
- break;
- case '-':
- if (nexttoken.id === '-' || nexttoken.id === '--') {
- warning("Confusing minusses.");
- }
- break;
- case '+':
- if (nexttoken.id === '+' || nexttoken.id === '++') {
- warning("Confusing plusses.");
- }
- break;
- }
- if (token.type === '(string)' || token.identifier) {
- anonname = token.value;
- }
-
- if (id && nexttoken.id !== id) {
- if (t) {
- if (nexttoken.id === '(end)') {
- warning("Unmatched '{a}'.", t, t.id);
- } else {
- warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
- nexttoken, id, t.id, t.line, nexttoken.value);
- }
- } else if (nexttoken.type !== '(identifier)' ||
- nexttoken.value !== id) {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, id, nexttoken.value);
- }
- }
- prevtoken = token;
- token = nexttoken;
- for (;;) {
- nexttoken = lookahead.shift() || lex.token();
- if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
- return;
- }
- if (nexttoken.type === 'special') {
- doOption();
- } else {
- if (nexttoken.id !== '(endline)') {
- break;
- }
- }
- }
- }
-
-
-// This is the heart of JSHINT, the Pratt parser. In addition to parsing, it
-// is looking for ad hoc lint patterns. We add .fud to Pratt's model, which is
-// like .nud except that it is only used on the first token of a statement.
-// Having .fud makes it much easier to define statement-oriented languages like
-// JavaScript. I retained Pratt's nomenclature.
-
-// .nud Null denotation
-// .fud First null denotation
-// .led Left denotation
-// lbp Left binding power
-// rbp Right binding power
-
-// They are elements of the parsing method called Top Down Operator Precedence.
-
- function expression(rbp, initial) {
- var left, isArray = false;
-
- if (nexttoken.id === '(end)')
- error("Unexpected early end of program.", token);
-
- advance();
- if (initial) {
- anonname = 'anonymous';
- funct['(verb)'] = token.value;
- }
- if (initial === true && token.fud) {
- left = token.fud();
- } else {
- if (token.nud) {
- left = token.nud();
- } else {
- if (nexttoken.type === '(number)' && token.id === '.') {
- warning("A leading decimal point can be confused with a dot: '.{a}'.",
- token, nexttoken.value);
- advance();
- return token;
- } else {
- error("Expected an identifier and instead saw '{a}'.",
- token, token.id);
- }
- }
- while (rbp < nexttoken.lbp) {
- isArray = token.value == 'Array';
- advance();
- if (isArray && token.id == '(' && nexttoken.id == ')')
- warning("Use the array literal notation [].", token);
- if (token.led) {
- left = token.led(left);
- } else {
- error("Expected an operator and instead saw '{a}'.",
- token, token.id);
- }
- }
- }
- return left;
- }
-
-
-// Functions for conformance of style.
-
- function adjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white) {
- if (left.character !== right.from && left.line === right.line) {
- warning("Unexpected space after '{a}'.", right, left.value);
- }
- }
- }
-
- function nobreak(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white && (left.character !== right.from || left.line !== right.line)) {
- warning("Unexpected space before '{a}'.", right, right.value);
- }
- }
-
- function nospace(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white && !left.comment) {
- if (left.line === right.line) {
- adjacent(left, right);
- }
- }
- }
-
- function nonadjacent(left, right) {
- if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.line === right.line && left.character === right.from) {
- warning("Missing space after '{a}'.",
- nexttoken, left.value);
- }
- }
- }
-
- function nobreaknonadjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (!option.laxbreak && left.line !== right.line) {
- warning("Bad line breaking before '{a}'.", right, right.id);
- } else if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.character === right.from) {
- warning("Missing space after '{a}'.",
- nexttoken, left.value);
- }
- }
- }
-
- function indentation(bias) {
- var i;
- if (option.white && nexttoken.id !== '(end)') {
- i = indent + (bias || 0);
- if (nexttoken.from !== i) {
- warning(
-"Expected '{a}' to have an indentation at {b} instead at {c}.",
- nexttoken, nexttoken.value, i, nexttoken.from);
- }
- }
- }
-
- function nolinebreak(t) {
- t = t || token;
- if (t.line !== nexttoken.line) {
- warning("Line breaking error '{a}'.", t, t.value);
- }
- }
-
-
- function comma() {
- if (token.line !== nexttoken.line) {
- if (!option.laxbreak) {
- warning("Bad line breaking before '{a}'.", token, nexttoken.id);
- }
- } else if (token.character !== nexttoken.from && option.white) {
- warning("Unexpected space after '{a}'.", nexttoken, token.value);
- }
- advance(',');
- nonadjacent(token, nexttoken);
- }
-
-
-// Functional constructors for making the symbols that will be inherited by
-// tokens.
-
- function symbol(s, p) {
- var x = syntax[s];
- if (!x || typeof x !== 'object') {
- syntax[s] = x = {
- id: s,
- lbp: p,
- value: s
- };
- }
- return x;
- }
-
-
- function delim(s) {
- return symbol(s, 0);
- }
-
-
- function stmt(s, f) {
- var x = delim(s);
- x.identifier = x.reserved = true;
- x.fud = f;
- return x;
- }
-
-
- function blockstmt(s, f) {
- var x = stmt(s, f);
- x.block = true;
- return x;
- }
-
-
- function reserveName(x) {
- var c = x.id.charAt(0);
- if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
- x.identifier = x.reserved = true;
- }
- return x;
- }
-
-
- function prefix(s, f) {
- var x = symbol(s, 150);
- reserveName(x);
- x.nud = (typeof f === 'function') ? f : function () {
- this.right = expression(150);
- this.arity = 'unary';
- if (this.id === '++' || this.id === '--') {
- if (option.plusplus) {
- warning("Unexpected use of '{a}'.", this, this.id);
- } else if ((!this.right.identifier || this.right.reserved) &&
- this.right.id !== '.' && this.right.id !== '[') {
- warning("Bad operand.", this);
- }
- }
- return this;
- };
- return x;
- }
-
-
- function type(s, f) {
- var x = delim(s);
- x.type = s;
- x.nud = f;
- return x;
- }
-
-
- function reserve(s, f) {
- var x = type(s, f);
- x.identifier = x.reserved = true;
- return x;
- }
-
-
- function reservevar(s, v) {
- return reserve(s, function () {
- if (typeof v === 'function') {
- v(this);
- }
- return this;
- });
- }
-
-
- function infix(s, f, p, w) {
- var x = symbol(s, p);
- reserveName(x);
- x.led = function (left) {
- if (!w) {
- nobreaknonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- }
- if (typeof f === 'function') {
- return f(left, this);
- } else {
- this.left = left;
- this.right = expression(p);
- return this;
- }
- };
- return x;
- }
-
-
- function relation(s, f) {
- var x = symbol(s, 100);
- x.led = function (left) {
- nobreaknonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- var right = expression(100);
- if ((left && left.id === 'NaN') || (right && right.id === 'NaN')) {
- warning("Use the isNaN function to compare with NaN.", this);
- } else if (f) {
- f.apply(this, [left, right]);
- }
- if (left.id === '!') {
- warning("Confusing use of '{a}'.", left, '!');
- }
- if (right.id === '!') {
- warning("Confusing use of '{a}'.", left, '!');
- }
- this.left = left;
- this.right = right;
- return this;
- };
- return x;
- }
-
-
- function isPoorRelation(node) {
- return node &&
- ((node.type === '(number)' && +node.value === 0) ||
- (node.type === '(string)' && node.value === '') ||
- (node.type === 'null' && !option.eqnull) ||
- node.type === 'true' ||
- node.type === 'false' ||
- node.type === 'undefined');
- }
-
-
- function assignop(s, f) {
- symbol(s, 20).exps = true;
- return infix(s, function (left, that) {
- var l;
- that.left = left;
- if (predefined[left.value] === false &&
- scope[left.value]['(global)'] === true) {
- warning("Read only.", left);
- } else if (left['function']) {
- warning("'{a}' is a function.", left, left.value);
- }
- if (left) {
- if (left.id === '.' || left.id === '[') {
- if (!left.left || left.left.value === 'arguments') {
- warning('Bad assignment.', that);
- }
- that.right = expression(19);
- return that;
- } else if (left.identifier && !left.reserved) {
- if (funct[left.value] === 'exception') {
- warning("Do not assign to the exception parameter.", left);
- }
- that.right = expression(19);
- return that;
- }
- if (left === syntax['function']) {
- warning(
-"Expected an identifier in an assignment and instead saw a function invocation.",
- token);
- }
- }
- error("Bad assignment.", that);
- }, 20);
- }
-
-
- function bitwise(s, f, p) {
- var x = symbol(s, p);
- reserveName(x);
- x.led = (typeof f === 'function') ? f : function (left) {
- if (option.bitwise) {
- warning("Unexpected use of '{a}'.", this, this.id);
- }
- this.left = left;
- this.right = expression(p);
- return this;
- };
- return x;
- }
-
-
- function bitwiseassignop(s) {
- symbol(s, 20).exps = true;
- return infix(s, function (left, that) {
- if (option.bitwise) {
- warning("Unexpected use of '{a}'.", that, that.id);
- }
- nonadjacent(prevtoken, token);
- nonadjacent(token, nexttoken);
- if (left) {
- if (left.id === '.' || left.id === '[' ||
- (left.identifier && !left.reserved)) {
- expression(19);
- return that;
- }
- if (left === syntax['function']) {
- warning(
-"Expected an identifier in an assignment, and instead saw a function invocation.",
- token);
- }
- return that;
- }
- error("Bad assignment.", that);
- }, 20);
- }
-
-
- function suffix(s, f) {
- var x = symbol(s, 150);
- x.led = function (left) {
- if (option.plusplus) {
- warning("Unexpected use of '{a}'.", this, this.id);
- } else if ((!left.identifier || left.reserved) &&
- left.id !== '.' && left.id !== '[') {
- warning("Bad operand.", this);
- }
- this.left = left;
- return this;
- };
- return x;
- }
-
-
- // fnparam means that this identifier is being defined as a function
- // argument (see identifier())
- function optionalidentifier(fnparam) {
- if (nexttoken.identifier) {
- advance();
- if (token.reserved && !option.es5) {
- // `undefined` as a function param is a common pattern to protect
- // against the case when somebody does `undefined = true` and
- // help with minification. More info: https://gist.github.com/315916
- if (!fnparam || token.value != 'undefined') {
- warning("Expected an identifier and instead saw '{a}' (a reserved word).",
- token, token.id);
- }
- }
- return token.value;
- }
- }
-
- // fnparam means that this identifier is being defined as a function
- // argument
- function identifier(fnparam) {
- var i = optionalidentifier(fnparam);
- if (i) {
- return i;
- }
- if (token.id === 'function' && nexttoken.id === '(') {
- warning("Missing name in function declaration.");
- } else {
- error("Expected an identifier and instead saw '{a}'.",
- nexttoken, nexttoken.value);
- }
- }
-
-
- function reachable(s) {
- var i = 0, t;
- if (nexttoken.id !== ';' || noreach) {
- return;
- }
- for (;;) {
- t = peek(i);
- if (t.reach) {
- return;
- }
- if (t.id !== '(endline)') {
- if (t.id === 'function') {
- warning(
-"Inner functions should be listed at the top of the outer function.", t);
- break;
- }
- warning("Unreachable '{a}' after '{b}'.", t, t.value, s);
- break;
- }
- i += 1;
- }
- }
-
-
- function statement(noindent) {
- var i = indent, r, s = scope, t = nexttoken;
-
-// We don't like the empty statement.
-
- if (t.id === ';') {
- warning("Unnecessary semicolon.", t);
- advance(';');
- return;
- }
-
-// Is this a labelled statement?
-
- if (t.identifier && !t.reserved && peek().id === ':') {
- advance();
- advance(':');
- scope = Object.create(s);
- addlabel(t.value, 'label');
- if (!nexttoken.labelled) {
- warning("Label '{a}' on {b} statement.",
- nexttoken, t.value, nexttoken.value);
- }
- if (jx.test(t.value + ':')) {
- warning("Label '{a}' looks like a javascript url.",
- t, t.value);
- }
- nexttoken.label = t.value;
- t = nexttoken;
- }
-
-// Parse the statement.
-
- if (!noindent) {
- indentation();
- }
- r = expression(0, true);
-
-// Look for the final semicolon.
-
- if (!t.block) {
- if (!option.expr && (!r || !r.exps)) {
- warning("Expected an assignment or function call and instead saw an expression.", token);
- } else if (option.nonew && r.id === '(' && r.left.id === 'new') {
- warning("Do not use 'new' for side effects.");
- }
- if (nexttoken.id !== ';') {
- if (!option.asi) {
- warningAt("Missing semicolon.", token.line, token.from + token.value.length);
- }
- } else {
- adjacent(token, nexttoken);
- advance(';');
- nonadjacent(token, nexttoken);
- }
- }
-
-// Restore the indentation.
-
- indent = i;
- scope = s;
- return r;
- }
-
-
- function use_strict() {
- if (nexttoken.value === 'use strict') {
- if (strict_mode) {
- warning("Unnecessary \"use strict\".");
- }
- advance();
- advance(';');
- strict_mode = true;
- option.newcap = true;
- option.undef = true;
- return true;
- } else {
- return false;
- }
- }
-
-
- function statements(begin) {
- var a = [], f, p;
-
- while (!nexttoken.reach && nexttoken.id !== '(end)') {
- if (nexttoken.id === ';') {
- warning("Unnecessary semicolon.");
- advance(';');
- } else {
- a.push(statement());
- }
- }
- return a;
- }
-
-
- /*
- * Parses a single block. A block is a sequence of statements wrapped in
- * braces.
- *
- * ordinary - true for everything but function bodies and try blocks.
- * stmt - true if block can be a single statement (e.g. in if/for/while).
- */
- function block(ordinary, stmt) {
- var a,
- b = inblock,
- old_indent = indent,
- m = strict_mode,
- s = scope,
- t;
-
- inblock = ordinary;
- scope = Object.create(scope);
- nonadjacent(token, nexttoken);
- t = nexttoken;
-
- if (nexttoken.id === '{') {
- advance('{');
- if (nexttoken.id !== '}' || token.line !== nexttoken.line) {
- indent += option.indent;
- while (!ordinary && nexttoken.from > indent) {
- indent += option.indent;
- }
- if (!ordinary && !use_strict() && !m && option.strict &&
- funct['(context)']['(global)']) {
- warning("Missing \"use strict\" statement.");
- }
- a = statements();
- strict_mode = m;
- indent -= option.indent;
- indentation();
- }
- advance('}', t);
- indent = old_indent;
- } else if (!ordinary) {
- error("Expected '{a}' and instead saw '{b}'.",
- nexttoken, '{', nexttoken.value);
- } else {
- if (!stmt || option.curly)
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, '{', nexttoken.value);
-
- noreach = true;
- a = [statement()];
- noreach = false;
- }
- funct['(verb)'] = null;
- scope = s;
- inblock = b;
- if (ordinary && option.noempty && (!a || a.length === 0)) {
- warning("Empty block.");
- }
- return a;
- }
-
-
- function countMember(m) {
- if (membersOnly && typeof membersOnly[m] !== 'boolean') {
- warning("Unexpected /*member '{a}'.", token, m);
- }
- if (typeof member[m] === 'number') {
- member[m] += 1;
- } else {
- member[m] = 1;
- }
- }
-
-
- function note_implied(token) {
- var name = token.value, line = token.line, a = implied[name];
- if (typeof a === 'function') {
- a = false;
- }
- if (!a) {
- a = [line];
- implied[name] = a;
- } else if (a[a.length - 1] !== line) {
- a.push(line);
- }
- }
-
-// Build the syntax table by declaring the syntactic elements of the language.
-
- type('(number)', function () {
- return this;
- });
- type('(string)', function () {
- return this;
- });
-
- syntax['(identifier)'] = {
- type: '(identifier)',
- lbp: 0,
- identifier: true,
- nud: function () {
- var v = this.value,
- s = scope[v],
- f;
- if (typeof s === 'function') {
-
-// Protection against accidental inheritance.
-
- s = undefined;
- } else if (typeof s === 'boolean') {
- f = funct;
- funct = functions[0];
- addlabel(v, 'var');
- s = funct;
- funct = f;
- }
-
-// The name is in scope and defined in the current function.
-
- if (funct === s) {
-
-// Change 'unused' to 'var', and reject labels.
-
- switch (funct[v]) {
- case 'unused':
- funct[v] = 'var';
- break;
- case 'unction':
- funct[v] = 'function';
- this['function'] = true;
- break;
- case 'function':
- this['function'] = true;
- break;
- case 'label':
- warning("'{a}' is a statement label.", token, v);
- break;
- }
-
-// The name is not defined in the function. If we are in the global scope,
-// then we have an undefined variable.
-//
-// Operators typeof and delete do not raise runtime errors even if the base
-// object of a reference is null so no need to display warning if we're
-// inside of typeof or delete.
-
- } else if (funct['(global)']) {
- if (anonname != 'typeof' && anonname != 'delete' &&
- option.undef && typeof predefined[v] !== 'boolean') {
- warning("'{a}' is not defined.", token, v);
-
<TRUNCATED>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[10/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
index 43920d9..0d58db0 100644
--- a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
@@ -1,1302 +1,1302 @@
-//
-// showdown.js -- A javascript port of Markdown.
-//
-// Copyright (c) 2007 John Fraser.
-//
-// Original Markdown Copyright (c) 2004-2005 John Gruber
-// <http://daringfireball.net/projects/markdown/>
-//
-// Redistributable under a BSD-style open source license.
-// See license.txt for more information.
-//
-// The full source distribution is at:
-//
-// A A L
-// T C A
-// T K B
-//
-// <http://www.attacklab.net/>
-//
-
-//
-// Wherever possible, Showdown is a straight, line-by-line port
-// of the Perl version of Markdown.
-//
-// This is not a normal parser design; it's basically just a
-// series of string substitutions. It's hard to read and
-// maintain this way, but keeping Showdown close to the original
-// design makes it easier to port new features.
-//
-// More importantly, Showdown behaves like markdown.pl in most
-// edge cases. So web applications can do client-side preview
-// in Javascript, and then build identical HTML on the server.
-//
-// This port needs the new RegExp functionality of ECMA 262,
-// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers
-// should do fine. Even with the new regular expression features,
-// We do a lot of work to emulate Perl's regex functionality.
-// The tricky changes in this file mostly have the "attacklab:"
-// label. Major or self-explanatory changes don't.
-//
-// Smart diff tools like Araxis Merge will be able to match up
-// this file with markdown.pl in a useful way. A little tweaking
-// helps: in a copy of markdown.pl, replace "#" with "//" and
-// replace "$text" with "text". Be sure to ignore whitespace
-// and line endings.
-//
-
-
-//
-// Showdown usage:
-//
-// var text = "Markdown *rocks*.";
-//
-// var converter = new Showdown.converter();
-// var html = converter.makeHtml(text);
-//
-// alert(html);
-//
-// Note: move the sample code to the bottom of this
-// file before uncommenting it.
-//
-
-
-//
-// Showdown namespace
-//
-var Showdown = {};
-
-//
-// converter
-//
-// Wraps all "globals" so that the only thing
-// exposed is makeHtml().
-//
-Showdown.converter = function() {
-
-//
-// Globals:
-//
-
-// Global hashes, used by various utility routines
-var g_urls;
-var g_titles;
-var g_html_blocks;
-
-// Used to track when we're inside an ordered or unordered list
-// (see _ProcessListItems() for details):
-var g_list_level = 0;
-
-
-this.makeHtml = function(text) {
-//
-// Main function. The order in which other subs are called here is
-// essential. Link and image substitutions need to happen before
-// _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the <a>
-// and <img> tags get encoded.
-//
-
- // Clear the global hashes. If we don't clear these, you get conflicts
- // from other articles when generating a page which contains more than
- // one article (e.g. an index page that shows the N most recent
- // articles):
- g_urls = new Array();
- g_titles = new Array();
- g_html_blocks = new Array();
-
- // attacklab: Replace ~ with ~T
- // This lets us use tilde as an escape char to avoid md5 hashes
- // The choice of character is arbitray; anything that isn't
- // magic in Markdown will work.
- text = text.replace(/~/g,"~T");
-
- // attacklab: Replace $ with ~D
- // RegExp interprets $ as a special character
- // when it's in a replacement string
- text = text.replace(/\$/g,"~D");
-
- // Standardize line endings
- text = text.replace(/\r\n/g,"\n"); // DOS to Unix
- text = text.replace(/\r/g,"\n"); // Mac to Unix
-
- // Make sure text begins and ends with a couple of newlines:
- text = "\n\n" + text + "\n\n";
-
- // Convert all tabs to spaces.
- text = _Detab(text);
-
- // Strip any lines consisting only of spaces and tabs.
- // This makes subsequent regexen easier to write, because we can
- // match consecutive blank lines with /\n+/ instead of something
- // contorted like /[ \t]*\n+/ .
- text = text.replace(/^[ \t]+$/mg,"");
-
- // Turn block-level HTML blocks into hash entries
- text = _HashHTMLBlocks(text);
-
- // Strip link definitions, store in hashes.
- text = _StripLinkDefinitions(text);
-
- text = _RunBlockGamut(text);
-
- text = _UnescapeSpecialChars(text);
-
- // attacklab: Restore dollar signs
- text = text.replace(/~D/g,"$$");
-
- // attacklab: Restore tildes
- text = text.replace(/~T/g,"~");
-
- return text;
-}
-
-
-var _StripLinkDefinitions = function(text) {
-//
-// Strips link definitions from text, stores the URLs and titles in
-// hash references.
-//
-
- // Link defs are in the form: ^[id]: url "optional title"
-
- /*
- var text = text.replace(/
- ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1
- [ \t]*
- \n? // maybe *one* newline
- [ \t]*
- <?(\S+?)>? // url = $2
- [ \t]*
- \n? // maybe one newline
- [ \t]*
- (?:
- (\n*) // any lines skipped = $3 attacklab: lookbehind removed
- ["(]
- (.+?) // title = $4
- [")]
- [ \t]*
- )? // title is optional
- (?:\n+|$)
- /gm,
- function(){...});
- */
- var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,
- function (wholeMatch,m1,m2,m3,m4) {
- m1 = m1.toLowerCase();
- g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive
- if (m3) {
- // Oops, found blank lines, so it's not a title.
- // Put back the parenthetical statement we stole.
- return m3+m4;
- } else if (m4) {
- g_titles[m1] = m4.replace(/"/g,""");
- }
-
- // Completely remove the definition from the text
- return "";
- }
- );
-
- return text;
-}
-
-
-var _HashHTMLBlocks = function(text) {
- // attacklab: Double up blank lines to reduce lookaround
- text = text.replace(/\n/g,"\n\n");
-
- // Hashify HTML blocks:
- // We only want to do this for block-level HTML tags, such as headers,
- // lists, and tables. That's because we still want to wrap <p>s around
- // "paragraphs" that are wrapped in non-block-level tags, such as anchors,
- // phrase emphasis, and spans. The list of tags we're looking for is
- // hard-coded:
- var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del"
- var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math"
-
- // First, look for nested blocks, e.g.:
- // <div>
- // <div>
- // tags for inner block must be indented.
- // </div>
- // </div>
- //
- // The outermost tags must start at the left margin for this to match, and
- // the inner nested divs must be indented.
- // We need to do this before the next, more liberal match, because the next
- // match will start at the first `<div>` and stop at the first `</div>`.
-
- // attacklab: This regex can be expensive when it fails.
- /*
- var text = text.replace(/
- ( // save in $1
- ^ // start of line (with /m)
- <($block_tags_a) // start tag = $2
- \b // word break
- // attacklab: hack around khtml/pcre bug...
- [^\r]*?\n // any number of lines, minimally matching
- </\2> // the matching end tag
- [ \t]* // trailing spaces/tabs
- (?=\n+) // followed by a newline
- ) // attacklab: there are sentinel newlines at end of document
- /gm,function(){...}};
- */
- text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement);
-
- //
- // Now match more liberally, simply from `\n<tag>` to `</tag>\n`
- //
-
- /*
- var text = text.replace(/
- ( // save in $1
- ^ // start of line (with /m)
- <($block_tags_b) // start tag = $2
- \b // word break
- // attacklab: hack around khtml/pcre bug...
- [^\r]*? // any number of lines, minimally matching
- .*</\2> // the matching end tag
- [ \t]* // trailing spaces/tabs
- (?=\n+) // followed by a newline
- ) // attacklab: there are sentinel newlines at end of document
- /gm,function(){...}};
- */
- text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);
-
- // Special case just for <hr />. It was easier to make a special case than
- // to make the other regex more complicated.
-
- /*
- text = text.replace(/
- ( // save in $1
- \n\n // Starting after a blank line
- [ ]{0,3}
- (<(hr) // start tag = $2
- \b // word break
- ([^<>])*? //
- \/?>) // the matching end tag
- [ \t]*
- (?=\n{2,}) // followed by a blank line
- )
- /g,hashElement);
- */
- text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement);
-
- // Special case for standalone HTML comments:
-
- /*
- text = text.replace(/
- ( // save in $1
- \n\n // Starting after a blank line
- [ ]{0,3} // attacklab: g_tab_width - 1
- <!
- (--[^\r]*?--\s*)+
- >
- [ \t]*
- (?=\n{2,}) // followed by a blank line
- )
- /g,hashElement);
- */
- text = text.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,hashElement);
-
- // PHP and ASP-style processor instructions (<?...?> and <%...%>)
-
- /*
- text = text.replace(/
- (?:
- \n\n // Starting after a blank line
- )
- ( // save in $1
- [ ]{0,3} // attacklab: g_tab_width - 1
- (?:
- <([?%]) // $2
- [^\r]*?
- \2>
- )
- [ \t]*
- (?=\n{2,}) // followed by a blank line
- )
- /g,hashElement);
- */
- text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement);
-
- // attacklab: Undo double lines (see comment at top of this function)
- text = text.replace(/\n\n/g,"\n");
- return text;
-}
-
-var hashElement = function(wholeMatch,m1) {
- var blockText = m1;
-
- // Undo double lines
- blockText = blockText.replace(/\n\n/g,"\n");
- blockText = blockText.replace(/^\n/,"");
-
- // strip trailing blank lines
- blockText = blockText.replace(/\n+$/g,"");
-
- // Replace the element text with a marker ("~KxK" where x is its key)
- blockText = "\n\n~K" + (g_html_blocks.push(blockText)-1) + "K\n\n";
-
- return blockText;
-};
-
-var _RunBlockGamut = function(text) {
-//
-// These are all the transformations that form block-level
-// tags like paragraphs, headers, and list items.
-//
- text = _DoHeaders(text);
-
- // Do Horizontal Rules:
- var key = hashBlock("<hr />");
- text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key);
- text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key);
- text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
-
- text = _DoLists(text);
- text = _DoCodeBlocks(text);
- text = _DoBlockQuotes(text);
-
- // We already ran _HashHTMLBlocks() before, in Markdown(), but that
- // was to escape raw HTML in the original Markdown source. This time,
- // we're escaping the markup we've just created, so that we don't wrap
- // <p> tags around block-level tags.
- text = _HashHTMLBlocks(text);
- text = _FormParagraphs(text);
-
- return text;
-}
-
-
-var _RunSpanGamut = function(text) {
-//
-// These are all the transformations that occur *within* block-level
-// tags like paragraphs, headers, and list items.
-//
-
- text = _DoCodeSpans(text);
- text = _EscapeSpecialCharsWithinTagAttributes(text);
- text = _EncodeBackslashEscapes(text);
-
- // Process anchor and image tags. Images must come first,
- // because ![foo][f] looks like an anchor.
- text = _DoImages(text);
- text = _DoAnchors(text);
-
- // Make links out of things like `<http://example.com/>`
- // Must come after _DoAnchors(), because you can use < and >
- // delimiters in inline links like [this](<url>).
- text = _DoAutoLinks(text);
- text = _EncodeAmpsAndAngles(text);
- text = _DoItalicsAndBold(text);
-
- // Do hard breaks:
- text = text.replace(/ +\n/g," <br />\n");
-
- return text;
-}
-
-var _EscapeSpecialCharsWithinTagAttributes = function(text) {
-//
-// Within tags -- meaning between < and > -- encode [\ ` * _] so they
-// don't conflict with their use in Markdown for code, italics and strong.
-//
-
- // Build a regex to find HTML tags and comments. See Friedl's
- // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
- var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;
-
- text = text.replace(regex, function(wholeMatch) {
- var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`");
- tag = escapeCharacters(tag,"\\`*_");
- return tag;
- });
-
- return text;
-}
-
-var _DoAnchors = function(text) {
-//
-// Turn Markdown link shortcuts into XHTML <a> tags.
-//
- //
- // First, handle reference-style links: [link text] [id]
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- (
- (?:
- \[[^\]]*\] // allow brackets nested one level
- |
- [^\[] // or anything else
- )*
- )
- \]
-
- [ ]? // one optional space
- (?:\n[ ]*)? // one optional newline followed by spaces
-
- \[
- (.*?) // id = $3
- \]
- )()()()() // pad remaining backreferences
- /g,_DoAnchors_callback);
- */
- text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag);
-
- //
- // Next, inline-style links: [link text](url "optional title")
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- (
- (?:
- \[[^\]]*\] // allow brackets nested one level
- |
- [^\[\]] // or anything else
- )
- )
- \]
- \( // literal paren
- [ \t]*
- () // no id, so leave $3 empty
- <?(.*?)>? // href = $4
- [ \t]*
- ( // $5
- (['"]) // quote char = $6
- (.*?) // Title = $7
- \6 // matching quote
- [ \t]* // ignore any spaces/tabs between closing quote and )
- )? // title is optional
- \)
- )
- /g,writeAnchorTag);
- */
- text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag);
-
- //
- // Last, handle reference-style shortcuts: [link text]
- // These must come last in case you've also got [link test][1]
- // or [link test](/foo)
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- ([^\[\]]+) // link text = $2; can't contain '[' or ']'
- \]
- )()()()()() // pad rest of backreferences
- /g, writeAnchorTag);
- */
- text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
-
- return text;
-}
-
-var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
- if (m7 == undefined) m7 = "";
- var whole_match = m1;
- var link_text = m2;
- var link_id = m3.toLowerCase();
- var url = m4;
- var title = m7;
-
- if (url == "") {
- if (link_id == "") {
- // lower-case and turn embedded newlines into spaces
- link_id = link_text.toLowerCase().replace(/ ?\n/g," ");
- }
- url = "#"+link_id;
-
- if (g_urls[link_id] != undefined) {
- url = g_urls[link_id];
- if (g_titles[link_id] != undefined) {
- title = g_titles[link_id];
- }
- }
- else {
- if (whole_match.search(/\(\s*\)$/m)>-1) {
- // Special case for explicit empty url
- url = "";
- } else {
- return whole_match;
- }
- }
- }
-
- url = escapeCharacters(url,"*_");
- var result = "<a href=\"" + url + "\"";
-
- if (title != "") {
- title = title.replace(/"/g,""");
- title = escapeCharacters(title,"*_");
- result += " title=\"" + title + "\"";
- }
-
- result += ">" + link_text + "</a>";
-
- return result;
-}
-
-
-var _DoImages = function(text) {
-//
-// Turn Markdown image shortcuts into <img> tags.
-//
-
- //
- // First, handle reference-style labeled images: ![alt text][id]
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- !\[
- (.*?) // alt text = $2
- \]
-
- [ ]? // one optional space
- (?:\n[ ]*)? // one optional newline followed by spaces
-
- \[
- (.*?) // id = $3
- \]
- )()()()() // pad rest of backreferences
- /g,writeImageTag);
- */
- text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag);
-
- //
- // Next, handle inline images: 
- // Don't forget: encode * and _
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- !\[
- (.*?) // alt text = $2
- \]
- \s? // One optional whitespace character
- \( // literal paren
- [ \t]*
- () // no id, so leave $3 empty
- <?(\S+?)>? // src url = $4
- [ \t]*
- ( // $5
- (['"]) // quote char = $6
- (.*?) // title = $7
- \6 // matching quote
- [ \t]*
- )? // title is optional
- \)
- )
- /g,writeImageTag);
- */
- text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag);
-
- return text;
-}
-
-var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
- var whole_match = m1;
- var alt_text = m2;
- var link_id = m3.toLowerCase();
- var url = m4;
- var title = m7;
-
- if (!title) title = "";
-
- if (url == "") {
- if (link_id == "") {
- // lower-case and turn embedded newlines into spaces
- link_id = alt_text.toLowerCase().replace(/ ?\n/g," ");
- }
- url = "#"+link_id;
-
- if (g_urls[link_id] != undefined) {
- url = g_urls[link_id];
- if (g_titles[link_id] != undefined) {
- title = g_titles[link_id];
- }
- }
- else {
- return whole_match;
- }
- }
-
- alt_text = alt_text.replace(/"/g,""");
- url = escapeCharacters(url,"*_");
- var result = "<img src=\"" + url + "\" alt=\"" + alt_text + "\"";
-
- // attacklab: Markdown.pl adds empty title attributes to images.
- // Replicate this bug.
-
- //if (title != "") {
- title = title.replace(/"/g,""");
- title = escapeCharacters(title,"*_");
- result += " title=\"" + title + "\"";
- //}
-
- result += " />";
-
- return result;
-}
-
-
-var _DoHeaders = function(text) {
-
- // Setext-style headers:
- // Header 1
- // ========
- //
- // Header 2
- // --------
- //
- text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,
- function(wholeMatch,m1){return hashBlock('<h1 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h1>");});
-
- text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,
- function(matchFound,m1){return hashBlock('<h2 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h2>");});
-
- // atx-style headers:
- // # Header 1
- // ## Header 2
- // ## Header 2 with closing hashes ##
- // ...
- // ###### Header 6
- //
-
- /*
- text = text.replace(/
- ^(\#{1,6}) // $1 = string of #'s
- [ \t]*
- (.+?) // $2 = Header text
- [ \t]*
- \#* // optional closing #'s (not counted)
- \n+
- /gm, function() {...});
- */
-
- text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
- function(wholeMatch,m1,m2) {
- var h_level = m1.length;
- return hashBlock("<h" + h_level + ' id="' + headerId(m2) + '">' + _RunSpanGamut(m2) + "</h" + h_level + ">");
- });
-
- function headerId(m) {
- return m.replace(/[^\w]/g, '').toLowerCase();
- }
- return text;
-}
-
-// This declaration keeps Dojo compressor from outputting garbage:
-var _ProcessListItems;
-
-var _DoLists = function(text) {
-//
-// Form HTML ordered (numbered) and unordered (bulleted) lists.
-//
-
- // attacklab: add sentinel to hack around khtml/safari bug:
- // http://bugs.webkit.org/show_bug.cgi?id=11231
- text += "~0";
-
- // Re-usable pattern to match any entirel ul or ol list:
-
- /*
- var whole_list = /
- ( // $1 = whole list
- ( // $2
- [ ]{0,3} // attacklab: g_tab_width - 1
- ([*+-]|\d+[.]) // $3 = first list item marker
- [ \t]+
- )
- [^\r]+?
- ( // $4
- ~0 // sentinel for workaround; should be $
- |
- \n{2,}
- (?=\S)
- (?! // Negative lookahead for another list item marker
- [ \t]*
- (?:[*+-]|\d+[.])[ \t]+
- )
- )
- )/g
- */
- var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
-
- if (g_list_level) {
- text = text.replace(whole_list,function(wholeMatch,m1,m2) {
- var list = m1;
- var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol";
-
- // Turn double returns into triple returns, so that we can make a
- // paragraph for the last item in a list, if necessary:
- list = list.replace(/\n{2,}/g,"\n\n\n");;
- var result = _ProcessListItems(list);
-
- // Trim any trailing whitespace, to put the closing `</$list_type>`
- // up on the preceding line, to get it past the current stupid
- // HTML block parser. This is a hack to work around the terrible
- // hack that is the HTML block parser.
- result = result.replace(/\s+$/,"");
- result = "<"+list_type+">" + result + "</"+list_type+">\n";
- return result;
- });
- } else {
- whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
- text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) {
- var runup = m1;
- var list = m2;
-
- var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol";
- // Turn double returns into triple returns, so that we can make a
- // paragraph for the last item in a list, if necessary:
- var list = list.replace(/\n{2,}/g,"\n\n\n");;
- var result = _ProcessListItems(list);
- result = runup + "<"+list_type+">\n" + result + "</"+list_type+">\n";
- return result;
- });
- }
-
- // attacklab: strip sentinel
- text = text.replace(/~0/,"");
-
- return text;
-}
-
-_ProcessListItems = function(list_str) {
-//
-// Process the contents of a single ordered or unordered list, splitting it
-// into individual list items.
-//
- // The $g_list_level global keeps track of when we're inside a list.
- // Each time we enter a list, we increment it; when we leave a list,
- // we decrement. If it's zero, we're not in a list anymore.
- //
- // We do this because when we're not inside a list, we want to treat
- // something like this:
- //
- // I recommend upgrading to version
- // 8. Oops, now this line is treated
- // as a sub-list.
- //
- // As a single paragraph, despite the fact that the second line starts
- // with a digit-period-space sequence.
- //
- // Whereas when we're inside a list (or sub-list), that line will be
- // treated as the start of a sub-list. What a kludge, huh? This is
- // an aspect of Markdown's syntax that's hard to parse perfectly
- // without resorting to mind-reading. Perhaps the solution is to
- // change the syntax rules such that sub-lists must start with a
- // starting cardinal number; e.g. "1." or "a.".
-
- g_list_level++;
-
- // trim trailing blank lines:
- list_str = list_str.replace(/\n{2,}$/,"\n");
-
- // attacklab: add sentinel to emulate \z
- list_str += "~0";
-
- /*
- list_str = list_str.replace(/
- (\n)? // leading line = $1
- (^[ \t]*) // leading whitespace = $2
- ([*+-]|\d+[.]) [ \t]+ // list marker = $3
- ([^\r]+? // list item text = $4
- (\n{1,2}))
- (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+))
- /gm, function(){...});
- */
- list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
- function(wholeMatch,m1,m2,m3,m4){
- var item = m4;
- var leading_line = m1;
- var leading_space = m2;
-
- if (leading_line || (item.search(/\n{2,}/)>-1)) {
- item = _RunBlockGamut(_Outdent(item));
- }
- else {
- // Recursion for sub-lists:
- item = _DoLists(_Outdent(item));
- item = item.replace(/\n$/,""); // chomp(item)
- item = _RunSpanGamut(item);
- }
-
- return "<li>" + item + "</li>\n";
- }
- );
-
- // attacklab: strip sentinel
- list_str = list_str.replace(/~0/g,"");
-
- g_list_level--;
- return list_str;
-}
-
-
-var _DoCodeBlocks = function(text) {
-//
-// Process Markdown `<pre><code>` blocks.
-//
-
- /*
- text = text.replace(text,
- /(?:\n\n|^)
- ( // $1 = the code block -- one or more lines, starting with a space/tab
- (?:
- (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
- .*\n+
- )+
- )
- (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
- /g,function(){...});
- */
-
- // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
- text += "~0";
-
- text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
- function(wholeMatch,m1,m2) {
- var codeblock = m1;
- var nextChar = m2;
-
- codeblock = _EncodeCode( _Outdent(codeblock));
- codeblock = _Detab(codeblock);
- codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
- codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
-
- codeblock = "<pre><code>" + codeblock + "\n</code></pre>";
-
- return hashBlock(codeblock) + nextChar;
- }
- );
-
- // attacklab: strip sentinel
- text = text.replace(/~0/,"");
-
- return text;
-}
-
-var hashBlock = function(text) {
- text = text.replace(/(^\n+|\n+$)/g,"");
- return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n";
-}
-
-
-var _DoCodeSpans = function(text) {
-//
-// * Backtick quotes are used for <code></code> spans.
-//
-// * You can use multiple backticks as the delimiters if you want to
-// include literal backticks in the code span. So, this input:
-//
-// Just type ``foo `bar` baz`` at the prompt.
-//
-// Will translate to:
-//
-// <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
-//
-// There's no arbitrary limit to the number of backticks you
-// can use as delimters. If you need three consecutive backticks
-// in your code, use four for delimiters, etc.
-//
-// * You can use spaces to get literal backticks at the edges:
-//
-// ... type `` `bar` `` ...
-//
-// Turns to:
-//
-// ... type <code>`bar`</code> ...
-//
-
- /*
- text = text.replace(/
- (^|[^\\]) // Character before opening ` can't be a backslash
- (`+) // $2 = Opening run of `
- ( // $3 = The code block
- [^\r]*?
- [^`] // attacklab: work around lack of lookbehind
- )
- \2 // Matching closer
- (?!`)
- /gm, function(){...});
- */
-
- text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
- function(wholeMatch,m1,m2,m3,m4) {
- var c = m3;
- c = c.replace(/^([ \t]*)/g,""); // leading whitespace
- c = c.replace(/[ \t]*$/g,""); // trailing whitespace
- c = _EncodeCode(c);
- return m1+"<code>"+c+"</code>";
- });
-
- return text;
-}
-
-
-var _EncodeCode = function(text) {
-//
-// Encode/escape certain characters inside Markdown code runs.
-// The point is that in code, these characters are literals,
-// and lose their special Markdown meanings.
-//
- // Encode all ampersands; HTML entities are not
- // entities within a Markdown code span.
- text = text.replace(/&/g,"&");
-
- // Do the angle bracket song and dance:
- text = text.replace(/</g,"<");
- text = text.replace(/>/g,">");
-
- // Now, escape characters that are magic in Markdown:
- text = escapeCharacters(text,"\*_{}[]\\",false);
-
-// jj the line above breaks this:
-//---
-
-//* Item
-
-// 1. Subitem
-
-// special char: *
-//---
-
- return text;
-}
-
-
-var _DoItalicsAndBold = function(text) {
-
- // <strong> must go first:
- text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
- "<strong>$2</strong>");
-
- text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,
- "<em>$2</em>");
-
- return text;
-}
-
-
-var _DoBlockQuotes = function(text) {
-
- /*
- text = text.replace(/
- ( // Wrap whole match in $1
- (
- ^[ \t]*>[ \t]? // '>' at the start of a line
- .+\n // rest of the first line
- (.+\n)* // subsequent consecutive lines
- \n* // blanks
- )+
- )
- /gm, function(){...});
- */
-
- text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
- function(wholeMatch,m1) {
- var bq = m1;
-
- // attacklab: hack around Konqueror 3.5.4 bug:
- // "----------bug".replace(/^-/g,"") == "bug"
-
- bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting
-
- // attacklab: clean up hack
- bq = bq.replace(/~0/g,"");
-
- bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines
- bq = _RunBlockGamut(bq); // recurse
-
- bq = bq.replace(/(^|\n)/g,"$1 ");
- // These leading spaces screw with <pre> content, so we need to fix that:
- bq = bq.replace(
- /(\s*<pre>[^\r]+?<\/pre>)/gm,
- function(wholeMatch,m1) {
- var pre = m1;
- // attacklab: hack around Konqueror 3.5.4 bug:
- pre = pre.replace(/^ /mg,"~0");
- pre = pre.replace(/~0/g,"");
- return pre;
- });
-
- return hashBlock("<blockquote>\n" + bq + "\n</blockquote>");
- });
- return text;
-}
-
-
-var _FormParagraphs = function(text) {
-//
-// Params:
-// $text - string to process with html <p> tags
-//
-
- // Strip leading and trailing lines:
- text = text.replace(/^\n+/g,"");
- text = text.replace(/\n+$/g,"");
-
- var grafs = text.split(/\n{2,}/g);
- var grafsOut = new Array();
-
- //
- // Wrap <p> tags.
- //
- var end = grafs.length;
- for (var i=0; i<end; i++) {
- var str = grafs[i];
-
- // if this is an HTML marker, copy it
- if (str.search(/~K(\d+)K/g) >= 0) {
- grafsOut.push(str);
- }
- else if (str.search(/\S/) >= 0) {
- str = _RunSpanGamut(str);
- str = str.replace(/^([ \t]*)/g,"<p>");
- str += "</p>"
- grafsOut.push(str);
- }
-
- }
-
- //
- // Unhashify HTML blocks
- //
- end = grafsOut.length;
- for (var i=0; i<end; i++) {
- // if this is a marker for an html block...
- while (grafsOut[i].search(/~K(\d+)K/) >= 0) {
- var blockText = g_html_blocks[RegExp.$1];
- blockText = blockText.replace(/\$/g,"$$$$"); // Escape any dollar signs
- grafsOut[i] = grafsOut[i].replace(/~K\d+K/,blockText);
- }
- }
-
- return grafsOut.join("\n\n");
-}
-
-
-var _EncodeAmpsAndAngles = function(text) {
-// Smart processing for ampersands and angle brackets that need to be encoded.
-
- // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
- // http://bumppo.net/projects/amputator/
- text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&");
-
- // Encode naked <'s
- text = text.replace(/<(?![a-z\/?\$!])/gi,"<");
-
- return text;
-}
-
-
-var _EncodeBackslashEscapes = function(text) {
-//
-// Parameter: String.
-// Returns: The string, with after processing the following backslash
-// escape sequences.
-//
-
- // attacklab: The polite way to do this is with the new
- // escapeCharacters() function:
- //
- // text = escapeCharacters(text,"\\",true);
- // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
- //
- // ...but we're sidestepping its use of the (slow) RegExp constructor
- // as an optimization for Firefox. This function gets called a LOT.
-
- text = text.replace(/\\(\\)/g,escapeCharacters_callback);
- text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback);
- return text;
-}
-
-
-var _DoAutoLinks = function(text) {
-
- text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"<a href=\"$1\">$1</a>");
-
- // Email addresses: <ad...@domain.foo>
-
- /*
- text = text.replace(/
- <
- (?:mailto:)?
- (
- [-.\w]+
- \@
- [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
- )
- >
- /gi, _DoAutoLinks_callback());
- */
- text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
- function(wholeMatch,m1) {
- return _EncodeEmailAddress( _UnescapeSpecialChars(m1) );
- }
- );
-
- return text;
-}
-
-
-var _EncodeEmailAddress = function(addr) {
-//
-// Input: an email address, e.g. "foo@example.com"
-//
-// Output: the email address as a mailto link, with each character
-// of the address encoded as either a decimal or hex entity, in
-// the hopes of foiling most address harvesting spam bots. E.g.:
-//
-// <a href="mailto:foo@e
-// xample.com">foo
-// @example.com</a>
-//
-// Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
-// mailing list: <http://tinyurl.com/yu7ue>
-//
-
- // attacklab: why can't javascript speak hex?
- function char2hex(ch) {
- var hexDigits = '0123456789ABCDEF';
- var dec = ch.charCodeAt(0);
- return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15));
- }
-
- var encode = [
- function(ch){return "&#"+ch.charCodeAt(0)+";";},
- function(ch){return "&#x"+char2hex(ch)+";";},
- function(ch){return ch;}
- ];
-
- addr = "mailto:" + addr;
-
- addr = addr.replace(/./g, function(ch) {
- if (ch == "@") {
- // this *must* be encoded. I insist.
- ch = encode[Math.floor(Math.random()*2)](ch);
- } else if (ch !=":") {
- // leave ':' alone (to spot mailto: later)
- var r = Math.random();
- // roughly 10% raw, 45% hex, 45% dec
- ch = (
- r > .9 ? encode[2](ch) :
- r > .45 ? encode[1](ch) :
- encode[0](ch)
- );
- }
- return ch;
- });
-
- addr = "<a href=\"" + addr + "\">" + addr + "</a>";
- addr = addr.replace(/">.+:/g,"\">"); // strip the mailto: from the visible part
-
- return addr;
-}
-
-
-var _UnescapeSpecialChars = function(text) {
-//
-// Swap back in all the special characters we've hidden.
-//
- text = text.replace(/~E(\d+)E/g,
- function(wholeMatch,m1) {
- var charCodeToReplace = parseInt(m1);
- return String.fromCharCode(charCodeToReplace);
- }
- );
- return text;
-}
-
-
-var _Outdent = function(text) {
-//
-// Remove one level of line-leading tabs or spaces
-//
-
- // attacklab: hack around Konqueror 3.5.4 bug:
- // "----------bug".replace(/^-/g,"") == "bug"
-
- text = text.replace(/^(\t|[ ]{1,4})/gm,"~0"); // attacklab: g_tab_width
-
- // attacklab: clean up hack
- text = text.replace(/~0/g,"")
-
- return text;
-}
-
-var _Detab = function(text) {
-// attacklab: Detab's completely rewritten for speed.
-// In perl we could fix it by anchoring the regexp with \G.
-// In javascript we're less fortunate.
-
- // expand first n-1 tabs
- text = text.replace(/\t(?=\t)/g," "); // attacklab: g_tab_width
-
- // replace the nth with two sentinels
- text = text.replace(/\t/g,"~A~B");
-
- // use the sentinel to anchor our regex so it doesn't explode
- text = text.replace(/~B(.+?)~A/g,
- function(wholeMatch,m1,m2) {
- var leadingText = m1;
- var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width
-
- // there *must* be a better way to do this:
- for (var i=0; i<numSpaces; i++) leadingText+=" ";
-
- return leadingText;
- }
- );
-
- // clean up sentinels
- text = text.replace(/~A/g," "); // attacklab: g_tab_width
- text = text.replace(/~B/g,"");
-
- return text;
-}
-
-
-//
-// attacklab: Utility functions
-//
-
-
-var escapeCharacters = function(text, charsToEscape, afterBackslash) {
- // First we have to escape the escape characters so that
- // we can build a character class out of them
- var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g,"\\$1") + "])";
-
- if (afterBackslash) {
- regexString = "\\\\" + regexString;
- }
-
- var regex = new RegExp(regexString,"g");
- text = text.replace(regex,escapeCharacters_callback);
-
- return text;
-}
-
-
-var escapeCharacters_callback = function(wholeMatch,m1) {
- var charCodeToEscape = m1.charCodeAt(0);
- return "~E"+charCodeToEscape+"E";
-}
-
-} // end of Showdown.converter
-
-// export
+//
+// showdown.js -- A javascript port of Markdown.
+//
+// Copyright (c) 2007 John Fraser.
+//
+// Original Markdown Copyright (c) 2004-2005 John Gruber
+// <http://daringfireball.net/projects/markdown/>
+//
+// Redistributable under a BSD-style open source license.
+// See license.txt for more information.
+//
+// The full source distribution is at:
+//
+// A A L
+// T C A
+// T K B
+//
+// <http://www.attacklab.net/>
+//
+
+//
+// Wherever possible, Showdown is a straight, line-by-line port
+// of the Perl version of Markdown.
+//
+// This is not a normal parser design; it's basically just a
+// series of string substitutions. It's hard to read and
+// maintain this way, but keeping Showdown close to the original
+// design makes it easier to port new features.
+//
+// More importantly, Showdown behaves like markdown.pl in most
+// edge cases. So web applications can do client-side preview
+// in Javascript, and then build identical HTML on the server.
+//
+// This port needs the new RegExp functionality of ECMA 262,
+// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers
+// should do fine. Even with the new regular expression features,
+// We do a lot of work to emulate Perl's regex functionality.
+// The tricky changes in this file mostly have the "attacklab:"
+// label. Major or self-explanatory changes don't.
+//
+// Smart diff tools like Araxis Merge will be able to match up
+// this file with markdown.pl in a useful way. A little tweaking
+// helps: in a copy of markdown.pl, replace "#" with "//" and
+// replace "$text" with "text". Be sure to ignore whitespace
+// and line endings.
+//
+
+
+//
+// Showdown usage:
+//
+// var text = "Markdown *rocks*.";
+//
+// var converter = new Showdown.converter();
+// var html = converter.makeHtml(text);
+//
+// alert(html);
+//
+// Note: move the sample code to the bottom of this
+// file before uncommenting it.
+//
+
+
+//
+// Showdown namespace
+//
+var Showdown = {};
+
+//
+// converter
+//
+// Wraps all "globals" so that the only thing
+// exposed is makeHtml().
+//
+Showdown.converter = function() {
+
+//
+// Globals:
+//
+
+// Global hashes, used by various utility routines
+var g_urls;
+var g_titles;
+var g_html_blocks;
+
+// Used to track when we're inside an ordered or unordered list
+// (see _ProcessListItems() for details):
+var g_list_level = 0;
+
+
+this.makeHtml = function(text) {
+//
+// Main function. The order in which other subs are called here is
+// essential. Link and image substitutions need to happen before
+// _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the <a>
+// and <img> tags get encoded.
+//
+
+ // Clear the global hashes. If we don't clear these, you get conflicts
+ // from other articles when generating a page which contains more than
+ // one article (e.g. an index page that shows the N most recent
+ // articles):
+ g_urls = new Array();
+ g_titles = new Array();
+ g_html_blocks = new Array();
+
+ // attacklab: Replace ~ with ~T
+ // This lets us use tilde as an escape char to avoid md5 hashes
+ // The choice of character is arbitray; anything that isn't
+ // magic in Markdown will work.
+ text = text.replace(/~/g,"~T");
+
+ // attacklab: Replace $ with ~D
+ // RegExp interprets $ as a special character
+ // when it's in a replacement string
+ text = text.replace(/\$/g,"~D");
+
+ // Standardize line endings
+ text = text.replace(/\r\n/g,"\n"); // DOS to Unix
+ text = text.replace(/\r/g,"\n"); // Mac to Unix
+
+ // Make sure text begins and ends with a couple of newlines:
+ text = "\n\n" + text + "\n\n";
+
+ // Convert all tabs to spaces.
+ text = _Detab(text);
+
+ // Strip any lines consisting only of spaces and tabs.
+ // This makes subsequent regexen easier to write, because we can
+ // match consecutive blank lines with /\n+/ instead of something
+ // contorted like /[ \t]*\n+/ .
+ text = text.replace(/^[ \t]+$/mg,"");
+
+ // Turn block-level HTML blocks into hash entries
+ text = _HashHTMLBlocks(text);
+
+ // Strip link definitions, store in hashes.
+ text = _StripLinkDefinitions(text);
+
+ text = _RunBlockGamut(text);
+
+ text = _UnescapeSpecialChars(text);
+
+ // attacklab: Restore dollar signs
+ text = text.replace(/~D/g,"$$");
+
+ // attacklab: Restore tildes
+ text = text.replace(/~T/g,"~");
+
+ return text;
+}
+
+
+var _StripLinkDefinitions = function(text) {
+//
+// Strips link definitions from text, stores the URLs and titles in
+// hash references.
+//
+
+ // Link defs are in the form: ^[id]: url "optional title"
+
+ /*
+ var text = text.replace(/
+ ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1
+ [ \t]*
+ \n? // maybe *one* newline
+ [ \t]*
+ <?(\S+?)>? // url = $2
+ [ \t]*
+ \n? // maybe one newline
+ [ \t]*
+ (?:
+ (\n*) // any lines skipped = $3 attacklab: lookbehind removed
+ ["(]
+ (.+?) // title = $4
+ [")]
+ [ \t]*
+ )? // title is optional
+ (?:\n+|$)
+ /gm,
+ function(){...});
+ */
+ var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,
+ function (wholeMatch,m1,m2,m3,m4) {
+ m1 = m1.toLowerCase();
+ g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive
+ if (m3) {
+ // Oops, found blank lines, so it's not a title.
+ // Put back the parenthetical statement we stole.
+ return m3+m4;
+ } else if (m4) {
+ g_titles[m1] = m4.replace(/"/g,""");
+ }
+
+ // Completely remove the definition from the text
+ return "";
+ }
+ );
+
+ return text;
+}
+
+
+var _HashHTMLBlocks = function(text) {
+ // attacklab: Double up blank lines to reduce lookaround
+ text = text.replace(/\n/g,"\n\n");
+
+ // Hashify HTML blocks:
+ // We only want to do this for block-level HTML tags, such as headers,
+ // lists, and tables. That's because we still want to wrap <p>s around
+ // "paragraphs" that are wrapped in non-block-level tags, such as anchors,
+ // phrase emphasis, and spans. The list of tags we're looking for is
+ // hard-coded:
+ var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del"
+ var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math"
+
+ // First, look for nested blocks, e.g.:
+ // <div>
+ // <div>
+ // tags for inner block must be indented.
+ // </div>
+ // </div>
+ //
+ // The outermost tags must start at the left margin for this to match, and
+ // the inner nested divs must be indented.
+ // We need to do this before the next, more liberal match, because the next
+ // match will start at the first `<div>` and stop at the first `</div>`.
+
+ // attacklab: This regex can be expensive when it fails.
+ /*
+ var text = text.replace(/
+ ( // save in $1
+ ^ // start of line (with /m)
+ <($block_tags_a) // start tag = $2
+ \b // word break
+ // attacklab: hack around khtml/pcre bug...
+ [^\r]*?\n // any number of lines, minimally matching
+ </\2> // the matching end tag
+ [ \t]* // trailing spaces/tabs
+ (?=\n+) // followed by a newline
+ ) // attacklab: there are sentinel newlines at end of document
+ /gm,function(){...}};
+ */
+ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement);
+
+ //
+ // Now match more liberally, simply from `\n<tag>` to `</tag>\n`
+ //
+
+ /*
+ var text = text.replace(/
+ ( // save in $1
+ ^ // start of line (with /m)
+ <($block_tags_b) // start tag = $2
+ \b // word break
+ // attacklab: hack around khtml/pcre bug...
+ [^\r]*? // any number of lines, minimally matching
+ .*</\2> // the matching end tag
+ [ \t]* // trailing spaces/tabs
+ (?=\n+) // followed by a newline
+ ) // attacklab: there are sentinel newlines at end of document
+ /gm,function(){...}};
+ */
+ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);
+
+ // Special case just for <hr />. It was easier to make a special case than
+ // to make the other regex more complicated.
+
+ /*
+ text = text.replace(/
+ ( // save in $1
+ \n\n // Starting after a blank line
+ [ ]{0,3}
+ (<(hr) // start tag = $2
+ \b // word break
+ ([^<>])*? //
+ \/?>) // the matching end tag
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // Special case for standalone HTML comments:
+
+ /*
+ text = text.replace(/
+ ( // save in $1
+ \n\n // Starting after a blank line
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ <!
+ (--[^\r]*?--\s*)+
+ >
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // PHP and ASP-style processor instructions (<?...?> and <%...%>)
+
+ /*
+ text = text.replace(/
+ (?:
+ \n\n // Starting after a blank line
+ )
+ ( // save in $1
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ (?:
+ <([?%]) // $2
+ [^\r]*?
+ \2>
+ )
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // attacklab: Undo double lines (see comment at top of this function)
+ text = text.replace(/\n\n/g,"\n");
+ return text;
+}
+
+var hashElement = function(wholeMatch,m1) {
+ var blockText = m1;
+
+ // Undo double lines
+ blockText = blockText.replace(/\n\n/g,"\n");
+ blockText = blockText.replace(/^\n/,"");
+
+ // strip trailing blank lines
+ blockText = blockText.replace(/\n+$/g,"");
+
+ // Replace the element text with a marker ("~KxK" where x is its key)
+ blockText = "\n\n~K" + (g_html_blocks.push(blockText)-1) + "K\n\n";
+
+ return blockText;
+};
+
+var _RunBlockGamut = function(text) {
+//
+// These are all the transformations that form block-level
+// tags like paragraphs, headers, and list items.
+//
+ text = _DoHeaders(text);
+
+ // Do Horizontal Rules:
+ var key = hashBlock("<hr />");
+ text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key);
+ text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key);
+ text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
+
+ text = _DoLists(text);
+ text = _DoCodeBlocks(text);
+ text = _DoBlockQuotes(text);
+
+ // We already ran _HashHTMLBlocks() before, in Markdown(), but that
+ // was to escape raw HTML in the original Markdown source. This time,
+ // we're escaping the markup we've just created, so that we don't wrap
+ // <p> tags around block-level tags.
+ text = _HashHTMLBlocks(text);
+ text = _FormParagraphs(text);
+
+ return text;
+}
+
+
+var _RunSpanGamut = function(text) {
+//
+// These are all the transformations that occur *within* block-level
+// tags like paragraphs, headers, and list items.
+//
+
+ text = _DoCodeSpans(text);
+ text = _EscapeSpecialCharsWithinTagAttributes(text);
+ text = _EncodeBackslashEscapes(text);
+
+ // Process anchor and image tags. Images must come first,
+ // because ![foo][f] looks like an anchor.
+ text = _DoImages(text);
+ text = _DoAnchors(text);
+
+ // Make links out of things like `<http://example.com/>`
+ // Must come after _DoAnchors(), because you can use < and >
+ // delimiters in inline links like [this](<url>).
+ text = _DoAutoLinks(text);
+ text = _EncodeAmpsAndAngles(text);
+ text = _DoItalicsAndBold(text);
+
+ // Do hard breaks:
+ text = text.replace(/ +\n/g," <br />\n");
+
+ return text;
+}
+
+var _EscapeSpecialCharsWithinTagAttributes = function(text) {
+//
+// Within tags -- meaning between < and > -- encode [\ ` * _] so they
+// don't conflict with their use in Markdown for code, italics and strong.
+//
+
+ // Build a regex to find HTML tags and comments. See Friedl's
+ // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
+ var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;
+
+ text = text.replace(regex, function(wholeMatch) {
+ var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`");
+ tag = escapeCharacters(tag,"\\`*_");
+ return tag;
+ });
+
+ return text;
+}
+
+var _DoAnchors = function(text) {
+//
+// Turn Markdown link shortcuts into XHTML <a> tags.
+//
+ //
+ // First, handle reference-style links: [link text] [id]
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ (
+ (?:
+ \[[^\]]*\] // allow brackets nested one level
+ |
+ [^\[] // or anything else
+ )*
+ )
+ \]
+
+ [ ]? // one optional space
+ (?:\n[ ]*)? // one optional newline followed by spaces
+
+ \[
+ (.*?) // id = $3
+ \]
+ )()()()() // pad remaining backreferences
+ /g,_DoAnchors_callback);
+ */
+ text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag);
+
+ //
+ // Next, inline-style links: [link text](url "optional title")
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ (
+ (?:
+ \[[^\]]*\] // allow brackets nested one level
+ |
+ [^\[\]] // or anything else
+ )
+ )
+ \]
+ \( // literal paren
+ [ \t]*
+ () // no id, so leave $3 empty
+ <?(.*?)>? // href = $4
+ [ \t]*
+ ( // $5
+ (['"]) // quote char = $6
+ (.*?) // Title = $7
+ \6 // matching quote
+ [ \t]* // ignore any spaces/tabs between closing quote and )
+ )? // title is optional
+ \)
+ )
+ /g,writeAnchorTag);
+ */
+ text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag);
+
+ //
+ // Last, handle reference-style shortcuts: [link text]
+ // These must come last in case you've also got [link test][1]
+ // or [link test](/foo)
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ ([^\[\]]+) // link text = $2; can't contain '[' or ']'
+ \]
+ )()()()()() // pad rest of backreferences
+ /g, writeAnchorTag);
+ */
+ text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
+
+ return text;
+}
+
+var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
+ if (m7 == undefined) m7 = "";
+ var whole_match = m1;
+ var link_text = m2;
+ var link_id = m3.toLowerCase();
+ var url = m4;
+ var title = m7;
+
+ if (url == "") {
+ if (link_id == "") {
+ // lower-case and turn embedded newlines into spaces
+ link_id = link_text.toLowerCase().replace(/ ?\n/g," ");
+ }
+ url = "#"+link_id;
+
+ if (g_urls[link_id] != undefined) {
+ url = g_urls[link_id];
+ if (g_titles[link_id] != undefined) {
+ title = g_titles[link_id];
+ }
+ }
+ else {
+ if (whole_match.search(/\(\s*\)$/m)>-1) {
+ // Special case for explicit empty url
+ url = "";
+ } else {
+ return whole_match;
+ }
+ }
+ }
+
+ url = escapeCharacters(url,"*_");
+ var result = "<a href=\"" + url + "\"";
+
+ if (title != "") {
+ title = title.replace(/"/g,""");
+ title = escapeCharacters(title,"*_");
+ result += " title=\"" + title + "\"";
+ }
+
+ result += ">" + link_text + "</a>";
+
+ return result;
+}
+
+
+var _DoImages = function(text) {
+//
+// Turn Markdown image shortcuts into <img> tags.
+//
+
+ //
+ // First, handle reference-style labeled images: ![alt text][id]
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ !\[
+ (.*?) // alt text = $2
+ \]
+
+ [ ]? // one optional space
+ (?:\n[ ]*)? // one optional newline followed by spaces
+
+ \[
+ (.*?) // id = $3
+ \]
+ )()()()() // pad rest of backreferences
+ /g,writeImageTag);
+ */
+ text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag);
+
+ //
+ // Next, handle inline images: 
+ // Don't forget: encode * and _
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ !\[
+ (.*?) // alt text = $2
+ \]
+ \s? // One optional whitespace character
+ \( // literal paren
+ [ \t]*
+ () // no id, so leave $3 empty
+ <?(\S+?)>? // src url = $4
+ [ \t]*
+ ( // $5
+ (['"]) // quote char = $6
+ (.*?) // title = $7
+ \6 // matching quote
+ [ \t]*
+ )? // title is optional
+ \)
+ )
+ /g,writeImageTag);
+ */
+ text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag);
+
+ return text;
+}
+
+var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
+ var whole_match = m1;
+ var alt_text = m2;
+ var link_id = m3.toLowerCase();
+ var url = m4;
+ var title = m7;
+
+ if (!title) title = "";
+
+ if (url == "") {
+ if (link_id == "") {
+ // lower-case and turn embedded newlines into spaces
+ link_id = alt_text.toLowerCase().replace(/ ?\n/g," ");
+ }
+ url = "#"+link_id;
+
+ if (g_urls[link_id] != undefined) {
+ url = g_urls[link_id];
+ if (g_titles[link_id] != undefined) {
+ title = g_titles[link_id];
+ }
+ }
+ else {
+ return whole_match;
+ }
+ }
+
+ alt_text = alt_text.replace(/"/g,""");
+ url = escapeCharacters(url,"*_");
+ var result = "<img src=\"" + url + "\" alt=\"" + alt_text + "\"";
+
+ // attacklab: Markdown.pl adds empty title attributes to images.
+ // Replicate this bug.
+
+ //if (title != "") {
+ title = title.replace(/"/g,""");
+ title = escapeCharacters(title,"*_");
+ result += " title=\"" + title + "\"";
+ //}
+
+ result += " />";
+
+ return result;
+}
+
+
+var _DoHeaders = function(text) {
+
+ // Setext-style headers:
+ // Header 1
+ // ========
+ //
+ // Header 2
+ // --------
+ //
+ text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,
+ function(wholeMatch,m1){return hashBlock('<h1 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h1>");});
+
+ text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,
+ function(matchFound,m1){return hashBlock('<h2 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h2>");});
+
+ // atx-style headers:
+ // # Header 1
+ // ## Header 2
+ // ## Header 2 with closing hashes ##
+ // ...
+ // ###### Header 6
+ //
+
+ /*
+ text = text.replace(/
+ ^(\#{1,6}) // $1 = string of #'s
+ [ \t]*
+ (.+?) // $2 = Header text
+ [ \t]*
+ \#* // optional closing #'s (not counted)
+ \n+
+ /gm, function() {...});
+ */
+
+ text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
+ function(wholeMatch,m1,m2) {
+ var h_level = m1.length;
+ return hashBlock("<h" + h_level + ' id="' + headerId(m2) + '">' + _RunSpanGamut(m2) + "</h" + h_level + ">");
+ });
+
+ function headerId(m) {
+ return m.replace(/[^\w]/g, '').toLowerCase();
+ }
+ return text;
+}
+
+// This declaration keeps Dojo compressor from outputting garbage:
+var _ProcessListItems;
+
+var _DoLists = function(text) {
+//
+// Form HTML ordered (numbered) and unordered (bulleted) lists.
+//
+
+ // attacklab: add sentinel to hack around khtml/safari bug:
+ // http://bugs.webkit.org/show_bug.cgi?id=11231
+ text += "~0";
+
+ // Re-usable pattern to match any entirel ul or ol list:
+
+ /*
+ var whole_list = /
+ ( // $1 = whole list
+ ( // $2
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ ([*+-]|\d+[.]) // $3 = first list item marker
+ [ \t]+
+ )
+ [^\r]+?
+ ( // $4
+ ~0 // sentinel for workaround; should be $
+ |
+ \n{2,}
+ (?=\S)
+ (?! // Negative lookahead for another list item marker
+ [ \t]*
+ (?:[*+-]|\d+[.])[ \t]+
+ )
+ )
+ )/g
+ */
+ var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
+
+ if (g_list_level) {
+ text = text.replace(whole_list,function(wholeMatch,m1,m2) {
+ var list = m1;
+ var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol";
+
+ // Turn double returns into triple returns, so that we can make a
+ // paragraph for the last item in a list, if necessary:
+ list = list.replace(/\n{2,}/g,"\n\n\n");;
+ var result = _ProcessListItems(list);
+
+ // Trim any trailing whitespace, to put the closing `</$list_type>`
+ // up on the preceding line, to get it past the current stupid
+ // HTML block parser. This is a hack to work around the terrible
+ // hack that is the HTML block parser.
+ result = result.replace(/\s+$/,"");
+ result = "<"+list_type+">" + result + "</"+list_type+">\n";
+ return result;
+ });
+ } else {
+ whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
+ text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) {
+ var runup = m1;
+ var list = m2;
+
+ var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol";
+ // Turn double returns into triple returns, so that we can make a
+ // paragraph for the last item in a list, if necessary:
+ var list = list.replace(/\n{2,}/g,"\n\n\n");;
+ var result = _ProcessListItems(list);
+ result = runup + "<"+list_type+">\n" + result + "</"+list_type+">\n";
+ return result;
+ });
+ }
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/,"");
+
+ return text;
+}
+
+_ProcessListItems = function(list_str) {
+//
+// Process the contents of a single ordered or unordered list, splitting it
+// into individual list items.
+//
+ // The $g_list_level global keeps track of when we're inside a list.
+ // Each time we enter a list, we increment it; when we leave a list,
+ // we decrement. If it's zero, we're not in a list anymore.
+ //
+ // We do this because when we're not inside a list, we want to treat
+ // something like this:
+ //
+ // I recommend upgrading to version
+ // 8. Oops, now this line is treated
+ // as a sub-list.
+ //
+ // As a single paragraph, despite the fact that the second line starts
+ // with a digit-period-space sequence.
+ //
+ // Whereas when we're inside a list (or sub-list), that line will be
+ // treated as the start of a sub-list. What a kludge, huh? This is
+ // an aspect of Markdown's syntax that's hard to parse perfectly
+ // without resorting to mind-reading. Perhaps the solution is to
+ // change the syntax rules such that sub-lists must start with a
+ // starting cardinal number; e.g. "1." or "a.".
+
+ g_list_level++;
+
+ // trim trailing blank lines:
+ list_str = list_str.replace(/\n{2,}$/,"\n");
+
+ // attacklab: add sentinel to emulate \z
+ list_str += "~0";
+
+ /*
+ list_str = list_str.replace(/
+ (\n)? // leading line = $1
+ (^[ \t]*) // leading whitespace = $2
+ ([*+-]|\d+[.]) [ \t]+ // list marker = $3
+ ([^\r]+? // list item text = $4
+ (\n{1,2}))
+ (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+))
+ /gm, function(){...});
+ */
+ list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
+ function(wholeMatch,m1,m2,m3,m4){
+ var item = m4;
+ var leading_line = m1;
+ var leading_space = m2;
+
+ if (leading_line || (item.search(/\n{2,}/)>-1)) {
+ item = _RunBlockGamut(_Outdent(item));
+ }
+ else {
+ // Recursion for sub-lists:
+ item = _DoLists(_Outdent(item));
+ item = item.replace(/\n$/,""); // chomp(item)
+ item = _RunSpanGamut(item);
+ }
+
+ return "<li>" + item + "</li>\n";
+ }
+ );
+
+ // attacklab: strip sentinel
+ list_str = list_str.replace(/~0/g,"");
+
+ g_list_level--;
+ return list_str;
+}
+
+
+var _DoCodeBlocks = function(text) {
+//
+// Process Markdown `<pre><code>` blocks.
+//
+
+ /*
+ text = text.replace(text,
+ /(?:\n\n|^)
+ ( // $1 = the code block -- one or more lines, starting with a space/tab
+ (?:
+ (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
+ .*\n+
+ )+
+ )
+ (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
+ /g,function(){...});
+ */
+
+ // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
+ text += "~0";
+
+ text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
+ function(wholeMatch,m1,m2) {
+ var codeblock = m1;
+ var nextChar = m2;
+
+ codeblock = _EncodeCode( _Outdent(codeblock));
+ codeblock = _Detab(codeblock);
+ codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
+ codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
+
+ codeblock = "<pre><code>" + codeblock + "\n</code></pre>";
+
+ return hashBlock(codeblock) + nextChar;
+ }
+ );
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/,"");
+
+ return text;
+}
+
+var hashBlock = function(text) {
+ text = text.replace(/(^\n+|\n+$)/g,"");
+ return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n";
+}
+
+
+var _DoCodeSpans = function(text) {
+//
+// * Backtick quotes are used for <code></code> spans.
+//
+// * You can use multiple backticks as the delimiters if you want to
+// include literal backticks in the code span. So, this input:
+//
+// Just type ``foo `bar` baz`` at the prompt.
+//
+// Will translate to:
+//
+// <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
+//
+// There's no arbitrary limit to the number of backticks you
+// can use as delimters. If you need three consecutive backticks
+// in your code, use four for delimiters, etc.
+//
+// * You can use spaces to get literal backticks at the edges:
+//
+// ... type `` `bar` `` ...
+//
+// Turns to:
+//
+// ... type <code>`bar`</code> ...
+//
+
+ /*
+ text = text.replace(/
+ (^|[^\\]) // Character before opening ` can't be a backslash
+ (`+) // $2 = Opening run of `
+ ( // $3 = The code block
+ [^\r]*?
+ [^`] // attacklab: work around lack of lookbehind
+ )
+ \2 // Matching closer
+ (?!`)
+ /gm, function(){...});
+ */
+
+ text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
+ function(wholeMatch,m1,m2,m3,m4) {
+ var c = m3;
+ c = c.replace(/^([ \t]*)/g,""); // leading whitespace
+ c = c.replace(/[ \t]*$/g,""); // trailing whitespace
+ c = _EncodeCode(c);
+ return m1+"<code>"+c+"</code>";
+ });
+
+ return text;
+}
+
+
+var _EncodeCode = function(text) {
+//
+// Encode/escape certain characters inside Markdown code runs.
+// The point is that in code, these characters are literals,
+// and lose their special Markdown meanings.
+//
+ // Encode all ampersands; HTML entities are not
+ // entities within a Markdown code span.
+ text = text.replace(/&/g,"&");
+
+ // Do the angle bracket song and dance:
+ text = text.replace(/</g,"<");
+ text = text.replace(/>/g,">");
+
+ // Now, escape characters that are magic in Markdown:
+ text = escapeCharacters(text,"\*_{}[]\\",false);
+
+// jj the line above breaks this:
+//---
+
+//* Item
+
+// 1. Subitem
+
+// special char: *
+//---
+
+ return text;
+}
+
+
+var _DoItalicsAndBold = function(text) {
+
+ // <strong> must go first:
+ text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
+ "<strong>$2</strong>");
+
+ text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,
+ "<em>$2</em>");
+
+ return text;
+}
+
+
+var _DoBlockQuotes = function(text) {
+
+ /*
+ text = text.replace(/
+ ( // Wrap whole match in $1
+ (
+ ^[ \t]*>[ \t]? // '>' at the start of a line
+ .+\n // rest of the first line
+ (.+\n)* // subsequent consecutive lines
+ \n* // blanks
+ )+
+ )
+ /gm, function(){...});
+ */
+
+ text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
+ function(wholeMatch,m1) {
+ var bq = m1;
+
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ // "----------bug".replace(/^-/g,"") == "bug"
+
+ bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting
+
+ // attacklab: clean up hack
+ bq = bq.replace(/~0/g,"");
+
+ bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines
+ bq = _RunBlockGamut(bq); // recurse
+
+ bq = bq.replace(/(^|\n)/g,"$1 ");
+ // These leading spaces screw with <pre> content, so we need to fix that:
+ bq = bq.replace(
+ /(\s*<pre>[^\r]+?<\/pre>)/gm,
+ function(wholeMatch,m1) {
+ var pre = m1;
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ pre = pre.replace(/^ /mg,"~0");
+ pre = pre.replace(/~0/g,"");
+ return pre;
+ });
+
+ return hashBlock("<blockquote>\n" + bq + "\n</blockquote>");
+ });
+ return text;
+}
+
+
+var _FormParagraphs = function(text) {
+//
+// Params:
+// $text - string to process with html <p> tags
+//
+
+ // Strip leading and trailing lines:
+ text = text.replace(/^\n+/g,"");
+ text = text.replace(/\n+$/g,"");
+
+ var grafs = text.split(/\n{2,}/g);
+ var grafsOut = new Array();
+
+ //
+ // Wrap <p> tags.
+ //
+ var end = grafs.length;
+ for (var i=0; i<end; i++) {
+ var str = grafs[i];
+
+ // if this is an HTML marker, copy it
+ if (str.search(/~K(\d+)K/g) >= 0) {
+ grafsOut.push(str);
+ }
+ else if (str.search(/\S/) >= 0) {
+ str = _RunSpanGamut(str);
+ str = str.replace(/^([ \t]*)/g,"<p>");
+ str += "</p>"
+ grafsOut.push(str);
+ }
+
+ }
+
+ //
+ // Unhashify HTML blocks
+ //
+ end = grafsOut.length;
+ for (var i=0; i<end; i++) {
+ // if this is a marker for an html block...
+ while (grafsOut[i].search(/~K(\d+)K/) >= 0) {
+ var blockText = g_html_blocks[RegExp.$1];
+ blockText = blockText.replace(/\$/g,"$$$$"); // Escape any dollar signs
+ grafsOut[i] = grafsOut[i].replace(/~K\d+K/,blockText);
+ }
+ }
+
+ return grafsOut.join("\n\n");
+}
+
+
+var _EncodeAmpsAndAngles = function(text) {
+// Smart processing for ampersands and angle brackets that need to be encoded.
+
+ // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
+ // http://bumppo.net/projects/amputator/
+ text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&");
+
+ // Encode naked <'s
+ text = text.replace(/<(?![a-z\/?\$!])/gi,"<");
+
+ return text;
+}
+
+
+var _EncodeBackslashEscapes = function(text) {
+//
+// Parameter: String.
+// Returns: The string, with after processing the following backslash
+// escape sequences.
+//
+
+ // attacklab: The polite way to do this is with the new
+ // escapeCharacters() function:
+ //
+ // text = escapeCharacters(text,"\\",true);
+ // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
+ //
+ // ...but we're sidestepping its use of the (slow) RegExp constructor
+ // as an optimization for Firefox. This function gets called a LOT.
+
+ text = text.replace(/\\(\\)/g,escapeCharacters_callback);
+ text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback);
+ return text;
+}
+
+
+var _DoAutoLinks = function(text) {
+
+ text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"<a href=\"$1\">$1</a>");
+
+ // Email addresses: <ad...@domain.foo>
+
+ /*
+ text = text.replace(/
+ <
+ (?:mailto:)?
+ (
+ [-.\w]+
+ \@
+ [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
+ )
+ >
+ /gi, _DoAutoLinks_callback());
+ */
+ text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
+ function(wholeMatch,m1) {
+ return _EncodeEmailAddress( _UnescapeSpecialChars(m1) );
+ }
+ );
+
+ return text;
+}
+
+
+var _EncodeEmailAddress = function(addr) {
+//
+// Input: an email address, e.g. "foo@example.com"
+//
+// Output: the email address as a mailto link, with each character
+// of the address encoded as either a decimal or hex entity, in
+// the hopes of foiling most address harvesting spam bots. E.g.:
+//
+// <a href="mailto:foo@e
+// xample.com">foo
+// @example.com</a>
+//
+// Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
+// mailing list: <http://tinyurl.com/yu7ue>
+//
+
+ // attacklab: why can't javascript speak hex?
+ function char2hex(ch) {
+ var hexDigits = '0123456789ABCDEF';
+ var dec = ch.charCodeAt(0);
+ return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15));
+ }
+
+ var encode = [
+ function(ch){return "&#"+ch.charCodeAt(0)+";";},
+ function(ch){return "&#x"+char2hex(ch)+";";},
+ function(ch){return ch;}
+ ];
+
+ addr = "mailto:" + addr;
+
+ addr = addr.replace(/./g, function(ch) {
+ if (ch == "@") {
+ // this *must* be encoded. I insist.
+ ch = encode[Math.floor(Math.random()*2)](ch);
+ } else if (ch !=":") {
+ // leave ':' alone (to spot mailto: later)
+ var r = Math.random();
+ // roughly 10% raw, 45% hex, 45% dec
+ ch = (
+ r > .9 ? encode[2](ch) :
+ r > .45 ? encode[1](ch) :
+ encode[0](ch)
+ );
+ }
+ return ch;
+ });
+
+ addr = "<a href=\"" + addr + "\">" + addr + "</a>";
+ addr = addr.replace(/">.+:/g,"\">"); // strip the mailto: from the visible part
+
+ return addr;
+}
+
+
+var _UnescapeSpecialChars = function(text) {
+//
+// Swap back in all the special characters we've hidden.
+//
+ text = text.replace(/~E(\d+)E/g,
+ function(wholeMatch,m1) {
+ var charCodeToReplace = parseInt(m1);
+ return String.fromCharCode(charCodeToReplace);
+ }
+ );
+ return text;
+}
+
+
+var _Outdent = function(text) {
+//
+// Remove one level of line-leading tabs or spaces
+//
+
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ // "----------bug".replace(/^-/g,"") == "bug"
+
+ text = text.replace(/^(\t|[ ]{1,4})/gm,"~0"); // attacklab: g_tab_width
+
+ // attacklab: clean up hack
+ text = text.replace(/~0/g,"")
+
+ return text;
+}
+
+var _Detab = function(text) {
+// attacklab: Detab's completely rewritten for speed.
+// In perl we could fix it by anchoring the regexp with \G.
+// In javascript we're less fortunate.
+
+ // expand first n-1 tabs
+ text = text.replace(/\t(?=\t)/g," "); // attacklab: g_tab_width
+
+ // replace the nth with two sentinels
+ text = text.replace(/\t/g,"~A~B");
+
+ // use the sentinel to anchor our regex so it doesn't explode
+ text = text.replace(/~B(.+?)~A/g,
+ function(wholeMatch,m1,m2) {
+ var leadingText = m1;
+ var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width
+
+ // there *must* be a better way to do this:
+ for (var i=0; i<numSpaces; i++) leadingText+=" ";
+
+ return leadingText;
+ }
+ );
+
+ // clean up sentinels
+ text = text.replace(/~A/g," "); // attacklab: g_tab_width
+ text = text.replace(/~B/g,"");
+
+ return text;
+}
+
+
+//
+// attacklab: Utility functions
+//
+
+
+var escapeCharacters = function(text, charsToEscape, afterBackslash) {
+ // First we have to escape the escape characters so that
+ // we can build a character class out of them
+ var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g,"\\$1") + "])";
+
+ if (afterBackslash) {
+ regexString = "\\\\" + regexString;
+ }
+
+ var regex = new RegExp(regexString,"g");
+ text = text.replace(regex,escapeCharacters_callback);
+
+ return text;
+}
+
+
+var escapeCharacters_callback = function(wholeMatch,m1) {
+ var charCodeToEscape = m1.charCodeAt(0);
+ return "~E"+charCodeToEscape+"E";
+}
+
+} // end of Showdown.converter
+
+// export
if (typeof exports != 'undefined') exports.Showdown = Showdown;
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[03/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js b/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
index 11e1f0a..b4c02d3 100644
--- a/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
+++ b/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
@@ -1,480 +1,480 @@
-/*
- http://www.JSON.org/json2.js
- 2011-02-23
-
- Public Domain.
-
- NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
-
- See http://www.JSON.org/js.html
-
-
- This code should be minified before deployment.
- See http://javascript.crockford.com/jsmin.html
-
- USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
- NOT CONTROL.
-
-
- This file creates a global JSON object containing two methods: stringify
- and parse.
-
- JSON.stringify(value, replacer, space)
- value any JavaScript value, usually an object or array.
-
- replacer an optional parameter that determines how object
- values are stringified for objects. It can be a
- function or an array of strings.
-
- space an optional parameter that specifies the indentation
- of nested structures. If it is omitted, the text will
- be packed without extra whitespace. If it is a number,
- it will specify the number of spaces to indent at each
- level. If it is a string (such as '\t' or ' '),
- it contains the characters used to indent at each level.
-
- This method produces a JSON text from a JavaScript value.
-
- When an object value is found, if the object contains a toJSON
- method, its toJSON method will be called and the result will be
- stringified. A toJSON method does not serialize: it returns the
- value represented by the name/value pair that should be serialized,
- or undefined if nothing should be serialized. The toJSON method
- will be passed the key associated with the value, and this will be
- bound to the value
-
- For example, this would serialize Dates as ISO strings.
-
- Date.prototype.toJSON = function (key) {
- function f(n) {
- // Format integers to have at least two digits.
- return n < 10 ? '0' + n : n;
- }
-
- return this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z';
- };
-
- You can provide an optional replacer method. It will be passed the
- key and value of each member, with this bound to the containing
- object. The value that is returned from your method will be
- serialized. If your method returns undefined, then the member will
- be excluded from the serialization.
-
- If the replacer parameter is an array of strings, then it will be
- used to select the members to be serialized. It filters the results
- such that only members with keys listed in the replacer array are
- stringified.
-
- Values that do not have JSON representations, such as undefined or
- functions, will not be serialized. Such values in objects will be
- dropped; in arrays they will be replaced with null. You can use
- a replacer function to replace those with JSON values.
- JSON.stringify(undefined) returns undefined.
-
- The optional space parameter produces a stringification of the
- value that is filled with line breaks and indentation to make it
- easier to read.
-
- If the space parameter is a non-empty string, then that string will
- be used for indentation. If the space parameter is a number, then
- the indentation will be that many spaces.
-
- Example:
-
- text = JSON.stringify(['e', {pluribus: 'unum'}]);
- // text is '["e",{"pluribus":"unum"}]'
-
-
- text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
- // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
-
- text = JSON.stringify([new Date()], function (key, value) {
- return this[key] instanceof Date ?
- 'Date(' + this[key] + ')' : value;
- });
- // text is '["Date(---current time---)"]'
-
-
- JSON.parse(text, reviver)
- This method parses a JSON text to produce an object or array.
- It can throw a SyntaxError exception.
-
- The optional reviver parameter is a function that can filter and
- transform the results. It receives each of the keys and values,
- and its return value is used instead of the original value.
- If it returns what it received, then the structure is not modified.
- If it returns undefined then the member is deleted.
-
- Example:
-
- // Parse the text. Values that look like ISO date strings will
- // be converted to Date objects.
-
- myData = JSON.parse(text, function (key, value) {
- var a;
- if (typeof value === 'string') {
- a =
-/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
- if (a) {
- return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
- +a[5], +a[6]));
- }
- }
- return value;
- });
-
- myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
- var d;
- if (typeof value === 'string' &&
- value.slice(0, 5) === 'Date(' &&
- value.slice(-1) === ')') {
- d = new Date(value.slice(5, -1));
- if (d) {
- return d;
- }
- }
- return value;
- });
-
-
- This is a reference implementation. You are free to copy, modify, or
- redistribute.
-*/
-
-/*jslint evil: true, strict: false, regexp: false */
-
-/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
- call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
- getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
- lastIndex, length, parse, prototype, push, replace, slice, stringify,
- test, toJSON, toString, valueOf
-*/
-
-
-// Create a JSON object only if one does not already exist. We create the
-// methods in a closure to avoid creating global variables.
-
-var JSON;
-if (!JSON) {
- JSON = {};
-}
-
-(function () {
- "use strict";
-
- function f(n) {
- // Format integers to have at least two digits.
- return n < 10 ? '0' + n : n;
- }
-
- if (typeof Date.prototype.toJSON !== 'function') {
-
- Date.prototype.toJSON = function (key) {
-
- return isFinite(this.valueOf()) ?
- this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z' : null;
- };
-
- String.prototype.toJSON =
- Number.prototype.toJSON =
- Boolean.prototype.toJSON = function (key) {
- return this.valueOf();
- };
- }
-
- var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- gap,
- indent,
- meta = { // table of character substitutions
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '\\': '\\\\'
- },
- rep;
-
-
- function quote(string) {
-
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can safely slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe escape
-// sequences.
-
- escapable.lastIndex = 0;
- return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
- var c = meta[a];
- return typeof c === 'string' ? c :
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- }) + '"' : '"' + string + '"';
- }
-
-
- function str(key, holder) {
-
-// Produce a string from holder[key].
-
- var i, // The loop counter.
- k, // The member key.
- v, // The member value.
- length,
- mind = gap,
- partial,
- value = holder[key];
-
-// If the value has a toJSON method, call it to obtain a replacement value.
-
- if (value && typeof value === 'object' &&
- typeof value.toJSON === 'function') {
- value = value.toJSON(key);
- }
-
-// If we were called with a replacer function, then call the replacer to
-// obtain a replacement value.
-
- if (typeof rep === 'function') {
- value = rep.call(holder, key, value);
- }
-
-// What happens next depends on the value's type.
-
- switch (typeof value) {
- case 'string':
- return quote(value);
-
- case 'number':
-
-// JSON numbers must be finite. Encode non-finite numbers as null.
-
- return isFinite(value) ? String(value) : 'null';
-
- case 'boolean':
- case 'null':
-
-// If the value is a boolean or null, convert it to a string. Note:
-// typeof null does not produce 'null'. The case is included here in
-// the remote chance that this gets fixed someday.
-
- return String(value);
-
-// If the type is 'object', we might be dealing with an object or an array or
-// null.
-
- case 'object':
-
-// Due to a specification blunder in ECMAScript, typeof null is 'object',
-// so watch out for that case.
-
- if (!value) {
- return 'null';
- }
-
-// Make an array to hold the partial results of stringifying this object value.
-
- gap += indent;
- partial = [];
-
-// Is the value an array?
-
- if (Object.prototype.toString.apply(value) === '[object Array]') {
-
-// The value is an array. Stringify every element. Use null as a placeholder
-// for non-JSON values.
-
- length = value.length;
- for (i = 0; i < length; i += 1) {
- partial[i] = str(i, value) || 'null';
- }
-
-// Join all of the elements together, separated with commas, and wrap them in
-// brackets.
-
- v = partial.length === 0 ? '[]' : gap ?
- '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
- '[' + partial.join(',') + ']';
- gap = mind;
- return v;
- }
-
-// If the replacer is an array, use it to select the members to be stringified.
-
- if (rep && typeof rep === 'object') {
- length = rep.length;
- for (i = 0; i < length; i += 1) {
- if (typeof rep[i] === 'string') {
- k = rep[i];
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
- }
- }
- }
- } else {
-
-// Otherwise, iterate through all of the keys in the object.
-
- for (k in value) {
- if (Object.prototype.hasOwnProperty.call(value, k)) {
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
- }
- }
- }
- }
-
-// Join all of the member texts together, separated with commas,
-// and wrap them in braces.
-
- v = partial.length === 0 ? '{}' : gap ?
- '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
- '{' + partial.join(',') + '}';
- gap = mind;
- return v;
- }
- }
-
-// If the JSON object does not yet have a stringify method, give it one.
-
- if (typeof JSON.stringify !== 'function') {
- JSON.stringify = function (value, replacer, space) {
-
-// The stringify method takes a value and an optional replacer, and an optional
-// space parameter, and returns a JSON text. The replacer can be a function
-// that can replace values, or an array of strings that will select the keys.
-// A default replacer method can be provided. Use of the space parameter can
-// produce text that is more easily readable.
-
- var i;
- gap = '';
- indent = '';
-
-// If the space parameter is a number, make an indent string containing that
-// many spaces.
-
- if (typeof space === 'number') {
- for (i = 0; i < space; i += 1) {
- indent += ' ';
- }
-
-// If the space parameter is a string, it will be used as the indent string.
-
- } else if (typeof space === 'string') {
- indent = space;
- }
-
-// If there is a replacer, it must be a function or an array.
-// Otherwise, throw an error.
-
- rep = replacer;
- if (replacer && typeof replacer !== 'function' &&
- (typeof replacer !== 'object' ||
- typeof replacer.length !== 'number')) {
- throw new Error('JSON.stringify');
- }
-
-// Make a fake root object containing our value under the key of ''.
-// Return the result of stringifying the value.
-
- return str('', {'': value});
- };
- }
-
-
-// If the JSON object does not yet have a parse method, give it one.
-
- if (typeof JSON.parse !== 'function') {
- JSON.parse = function (text, reviver) {
-
-// The parse method takes a text and an optional reviver function, and returns
-// a JavaScript value if the text is a valid JSON text.
-
- var j;
-
- function walk(holder, key) {
-
-// The walk method is used to recursively walk the resulting structure so
-// that modifications can be made.
-
- var k, v, value = holder[key];
- if (value && typeof value === 'object') {
- for (k in value) {
- if (Object.prototype.hasOwnProperty.call(value, k)) {
- v = walk(value, k);
- if (v !== undefined) {
- value[k] = v;
- } else {
- delete value[k];
- }
- }
- }
- }
- return reviver.call(holder, key, value);
- }
-
-
-// Parsing happens in four stages. In the first stage, we replace certain
-// Unicode characters with escape sequences. JavaScript handles many characters
-// incorrectly, either silently deleting them, or treating them as line endings.
-
- text = String(text);
- cx.lastIndex = 0;
- if (cx.test(text)) {
- text = text.replace(cx, function (a) {
- return '\\u' +
- ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- });
- }
-
-// In the second stage, we run the text against regular expressions that look
-// for non-JSON patterns. We are especially concerned with '()' and 'new'
-// because they can cause invocation, and '=' because it can cause mutation.
-// But just to be safe, we want to reject all unexpected forms.
-
-// We split the second stage into 4 regexp operations in order to work around
-// crippling inefficiencies in IE's and Safari's regexp engines. First we
-// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
-// replace all simple value tokens with ']' characters. Third, we delete all
-// open brackets that follow a colon or comma or that begin the text. Finally,
-// we look to see that the remaining characters are only whitespace or ']' or
-// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
-
- if (/^[\],:{}\s]*$/
- .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
- .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
- .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
-
-// In the third stage we use the eval function to compile the text into a
-// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
-// in JavaScript: it can begin a block or an object literal. We wrap the text
-// in parens to eliminate the ambiguity.
-
- j = eval('(' + text + ')');
-
-// In the optional fourth stage, we recursively walk the new structure, passing
-// each name/value pair to a reviver function for possible transformation.
-
- return typeof reviver === 'function' ?
- walk({'': j}, '') : j;
- }
-
-// If the text is not JSON parseable, then a SyntaxError is thrown.
-
- throw new SyntaxError('JSON.parse');
- };
- }
-}());
+/*
+ http://www.JSON.org/json2.js
+ 2011-02-23
+
+ Public Domain.
+
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+ See http://www.JSON.org/js.html
+
+
+ This code should be minified before deployment.
+ See http://javascript.crockford.com/jsmin.html
+
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+ NOT CONTROL.
+
+
+ This file creates a global JSON object containing two methods: stringify
+ and parse.
+
+ JSON.stringify(value, replacer, space)
+ value any JavaScript value, usually an object or array.
+
+ replacer an optional parameter that determines how object
+ values are stringified for objects. It can be a
+ function or an array of strings.
+
+ space an optional parameter that specifies the indentation
+ of nested structures. If it is omitted, the text will
+ be packed without extra whitespace. If it is a number,
+ it will specify the number of spaces to indent at each
+ level. If it is a string (such as '\t' or ' '),
+ it contains the characters used to indent at each level.
+
+ This method produces a JSON text from a JavaScript value.
+
+ When an object value is found, if the object contains a toJSON
+ method, its toJSON method will be called and the result will be
+ stringified. A toJSON method does not serialize: it returns the
+ value represented by the name/value pair that should be serialized,
+ or undefined if nothing should be serialized. The toJSON method
+ will be passed the key associated with the value, and this will be
+ bound to the value
+
+ For example, this would serialize Dates as ISO strings.
+
+ Date.prototype.toJSON = function (key) {
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ return this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z';
+ };
+
+ You can provide an optional replacer method. It will be passed the
+ key and value of each member, with this bound to the containing
+ object. The value that is returned from your method will be
+ serialized. If your method returns undefined, then the member will
+ be excluded from the serialization.
+
+ If the replacer parameter is an array of strings, then it will be
+ used to select the members to be serialized. It filters the results
+ such that only members with keys listed in the replacer array are
+ stringified.
+
+ Values that do not have JSON representations, such as undefined or
+ functions, will not be serialized. Such values in objects will be
+ dropped; in arrays they will be replaced with null. You can use
+ a replacer function to replace those with JSON values.
+ JSON.stringify(undefined) returns undefined.
+
+ The optional space parameter produces a stringification of the
+ value that is filled with line breaks and indentation to make it
+ easier to read.
+
+ If the space parameter is a non-empty string, then that string will
+ be used for indentation. If the space parameter is a number, then
+ the indentation will be that many spaces.
+
+ Example:
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
+ // text is '["e",{"pluribus":"unum"}]'
+
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+ text = JSON.stringify([new Date()], function (key, value) {
+ return this[key] instanceof Date ?
+ 'Date(' + this[key] + ')' : value;
+ });
+ // text is '["Date(---current time---)"]'
+
+
+ JSON.parse(text, reviver)
+ This method parses a JSON text to produce an object or array.
+ It can throw a SyntaxError exception.
+
+ The optional reviver parameter is a function that can filter and
+ transform the results. It receives each of the keys and values,
+ and its return value is used instead of the original value.
+ If it returns what it received, then the structure is not modified.
+ If it returns undefined then the member is deleted.
+
+ Example:
+
+ // Parse the text. Values that look like ISO date strings will
+ // be converted to Date objects.
+
+ myData = JSON.parse(text, function (key, value) {
+ var a;
+ if (typeof value === 'string') {
+ a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+ if (a) {
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+ +a[5], +a[6]));
+ }
+ }
+ return value;
+ });
+
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+ var d;
+ if (typeof value === 'string' &&
+ value.slice(0, 5) === 'Date(' &&
+ value.slice(-1) === ')') {
+ d = new Date(value.slice(5, -1));
+ if (d) {
+ return d;
+ }
+ }
+ return value;
+ });
+
+
+ This is a reference implementation. You are free to copy, modify, or
+ redistribute.
+*/
+
+/*jslint evil: true, strict: false, regexp: false */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
+ test, toJSON, toString, valueOf
+*/
+
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+var JSON;
+if (!JSON) {
+ JSON = {};
+}
+
+(function () {
+ "use strict";
+
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ if (typeof Date.prototype.toJSON !== 'function') {
+
+ Date.prototype.toJSON = function (key) {
+
+ return isFinite(this.valueOf()) ?
+ this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z' : null;
+ };
+
+ String.prototype.toJSON =
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
+ }
+
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+
+ function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+ escapable.lastIndex = 0;
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string' ? c :
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' : '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+
+// Produce a string from holder[key].
+
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+ if (value && typeof value === 'object' &&
+ typeof value.toJSON === 'function') {
+ value = value.toJSON(key);
+ }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+// What happens next depends on the value's type.
+
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+ return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+ case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+ if (!value) {
+ return 'null';
+ }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+ gap += indent;
+ partial = [];
+
+// Is the value an array?
+
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+ v = partial.length === 0 ? '[]' : gap ?
+ '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
+ '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ if (typeof rep[i] === 'string') {
+ k = rep[i];
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+ v = partial.length === 0 ? '{}' : gap ?
+ '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
+ '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+ if (typeof JSON.stringify !== 'function') {
+ JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+ var i;
+ gap = '';
+ indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+ return str('', {'': value});
+ };
+ }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+ if (typeof JSON.parse !== 'function') {
+ JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+ var j;
+
+ function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+ var k, v, value = holder[key];
+ if (value && typeof value === 'object') {
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = walk(value, k);
+ if (v !== undefined) {
+ value[k] = v;
+ } else {
+ delete value[k];
+ }
+ }
+ }
+ }
+ return reviver.call(holder, key, value);
+ }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+ text = String(text);
+ cx.lastIndex = 0;
+ if (cx.test(text)) {
+ text = text.replace(cx, function (a) {
+ return '\\u' +
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ });
+ }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+ if (/^[\],:{}\s]*$/
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+ j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+ return typeof reviver === 'function' ?
+ walk({'': j}, '') : j;
+ }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+ throw new SyntaxError('JSON.parse');
+ };
+ }
+}());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[12/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/README.md
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/README.md b/node_modules/archiver/node_modules/zip-stream/README.md
index f12fdcf..ec0501b 100644
--- a/node_modules/archiver/node_modules/zip-stream/README.md
+++ b/node_modules/archiver/node_modules/zip-stream/README.md
@@ -1,105 +1,105 @@
-# zip-stream v0.5.1 [](https://travis-ci.org/archiverjs/node-zip-stream)
-
-zip-stream is a streaming zip archive generator based on the `ZipArchiveOutputStream` prototype found in the [compress-commons](https://www.npmjs.org/package/compress-commons) project.
-
-It was originally created to be a successor to [zipstream](https://npmjs.org/package/zipstream).
-
-[](https://nodei.co/npm/zip-stream/)
-
-### Install
-
-```bash
-npm install zip-stream --save
-```
-
-You can also use `npm install https://github.com/archiverjs/node-zip-stream/archive/master.tar.gz` to test upcoming versions.
-
-### Usage
-
-This module is meant to be wrapped internally by other modules and therefore lacks any queue management. This means you have to wait until the previous entry has been fully consumed to add another. Nested callbacks should be used to add multiple entries. There are modules like [async](https://npmjs.org/package/async) that ease the so called "callback hell".
-
-If you want a module that handles entry queueing and much more, you should check out [archiver](https://npmjs.org/package/archiver) which uses this module internally.
-
-```js
-var packer = require('zip-stream');
-var archive = new packer(); // OR new packer(options)
-
-archive.on('error', function(err) {
- throw err;
-});
-
-// pipe archive where you want it (ie fs, http, etc)
-// listen to the destination's end, close, or finish event
-
-archive.entry('string contents', { name: 'string.txt' }, function(err, entry) {
- if (err) throw err;
- archive.entry(null, { name: 'directory/' }, function(err, entry) {
- if (err) throw err;
- archive.finish();
- });
-});
-```
-
-### Instance API
-
-#### getBytesWritten()
-
-Returns the current number of bytes written to this stream.
-
-#### entry(input, data, callback(err, data))
-
-Appends an input source (text string, buffer, or stream) to the instance. When the instance has received, processed, and emitted the input, the callback is fired.
-
-#### finish()
-
-Finalizes the instance. You should listen to the destination stream's `end`/`close`/`finish` event to know when all output has been safely consumed. (`finalize` is aliased for back-compat)
-
-### Instance Options
-
-#### comment `string`
-
-Sets the zip comment.
-
-#### store `boolean`
-
-If true, all entry contents will be archived without compression by default.
-
-#### zlib `object`
-
-Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
-
-### Entry Data
-
-#### name `string` `required`
-
-Sets the entry name including internal path.
-
-#### type `string`
-
-Sets the entry type. Defaults to `file` or `directory` if name ends with trailing slash.
-
-#### date `string|Date`
-
-Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
-
-#### store `boolean`
-
-If true, entry contents will be archived without compression.
-
-#### comment `string`
-
-Sets the entry comment.
-
-#### mode `number`
-
-Sets the entry permissions.
-
-## Things of Interest
-
-- [Releases](https://github.com/archiverjs/node-zip-stream/releases)
-- [Contributing](https://github.com/archiverjs/node-zip-stream/blob/master/CONTRIBUTING.md)
-- [MIT License](https://github.com/archiverjs/node-zip-stream/blob/master/LICENSE-MIT)
-
-## Credits
-
+# zip-stream v0.5.1 [](https://travis-ci.org/archiverjs/node-zip-stream)
+
+zip-stream is a streaming zip archive generator based on the `ZipArchiveOutputStream` prototype found in the [compress-commons](https://www.npmjs.org/package/compress-commons) project.
+
+It was originally created to be a successor to [zipstream](https://npmjs.org/package/zipstream).
+
+[](https://nodei.co/npm/zip-stream/)
+
+### Install
+
+```bash
+npm install zip-stream --save
+```
+
+You can also use `npm install https://github.com/archiverjs/node-zip-stream/archive/master.tar.gz` to test upcoming versions.
+
+### Usage
+
+This module is meant to be wrapped internally by other modules and therefore lacks any queue management. This means you have to wait until the previous entry has been fully consumed to add another. Nested callbacks should be used to add multiple entries. There are modules like [async](https://npmjs.org/package/async) that ease the so called "callback hell".
+
+If you want a module that handles entry queueing and much more, you should check out [archiver](https://npmjs.org/package/archiver) which uses this module internally.
+
+```js
+var packer = require('zip-stream');
+var archive = new packer(); // OR new packer(options)
+
+archive.on('error', function(err) {
+ throw err;
+});
+
+// pipe archive where you want it (ie fs, http, etc)
+// listen to the destination's end, close, or finish event
+
+archive.entry('string contents', { name: 'string.txt' }, function(err, entry) {
+ if (err) throw err;
+ archive.entry(null, { name: 'directory/' }, function(err, entry) {
+ if (err) throw err;
+ archive.finish();
+ });
+});
+```
+
+### Instance API
+
+#### getBytesWritten()
+
+Returns the current number of bytes written to this stream.
+
+#### entry(input, data, callback(err, data))
+
+Appends an input source (text string, buffer, or stream) to the instance. When the instance has received, processed, and emitted the input, the callback is fired.
+
+#### finish()
+
+Finalizes the instance. You should listen to the destination stream's `end`/`close`/`finish` event to know when all output has been safely consumed. (`finalize` is aliased for back-compat)
+
+### Instance Options
+
+#### comment `string`
+
+Sets the zip comment.
+
+#### store `boolean`
+
+If true, all entry contents will be archived without compression by default.
+
+#### zlib `object`
+
+Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
+
+### Entry Data
+
+#### name `string` `required`
+
+Sets the entry name including internal path.
+
+#### type `string`
+
+Sets the entry type. Defaults to `file` or `directory` if name ends with trailing slash.
+
+#### date `string|Date`
+
+Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
+
+#### store `boolean`
+
+If true, entry contents will be archived without compression.
+
+#### comment `string`
+
+Sets the entry comment.
+
+#### mode `number`
+
+Sets the entry permissions.
+
+## Things of Interest
+
+- [Releases](https://github.com/archiverjs/node-zip-stream/releases)
+- [Contributing](https://github.com/archiverjs/node-zip-stream/blob/master/CONTRIBUTING.md)
+- [MIT License](https://github.com/archiverjs/node-zip-stream/blob/master/LICENSE-MIT)
+
+## Credits
+
Concept inspired by Antoine van Wel's [zipstream](https://npmjs.org/package/zipstream) module, which is no longer being updated.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/lib/util/index.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/lib/util/index.js b/node_modules/archiver/node_modules/zip-stream/lib/util/index.js
index 35aedfd..c8b3f73 100644
--- a/node_modules/archiver/node_modules/zip-stream/lib/util/index.js
+++ b/node_modules/archiver/node_modules/zip-stream/lib/util/index.js
@@ -1,103 +1,103 @@
-/**
- * node-zip-stream
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-zip-stream/blob/master/LICENSE-MIT
- */
-var fs = require('fs');
-var path = require('path');
-
-var Stream = require('stream').Stream;
-var PassThrough = require('readable-stream').PassThrough;
-
-var _ = require('lodash');
-
-var util = module.exports = {};
-
-util.convertDateTimeDos = function(input) {
- return new Date(
- ((input >> 25) & 0x7f) + 1980,
- ((input >> 21) & 0x0f) - 1,
- (input >> 16) & 0x1f,
- (input >> 11) & 0x1f,
- (input >> 5) & 0x3f,
- (input & 0x1f) << 1
- );
-};
-
-util.dateify = function(dateish) {
- dateish = dateish || new Date();
-
- if (dateish instanceof Date) {
- dateish = dateish;
- } else if (typeof dateish === 'string') {
- dateish = new Date(dateish);
- } else {
- dateish = new Date();
- }
-
- return dateish;
-};
-
-// this is slightly different from lodash version
-util.defaults = function(object, source, guard) {
- var args = arguments;
- args[0] = args[0] || {};
-
- return _.defaults.apply(_, args);
-};
-
-util.dosDateTime = function(d, utc) {
- d = (d instanceof Date) ? d : util.dateify(d);
- utc = utc || false;
-
- var year = utc ? d.getUTCFullYear() : d.getFullYear();
-
- if (year < 1980) {
- return 2162688; // 1980-1-1 00:00:00
- } else if (year >= 2044) {
- return 2141175677; // 2043-12-31 23:59:58
- }
-
- var val = {
- year: year,
- month: utc ? d.getUTCMonth() : d.getMonth(),
- date: utc ? d.getUTCDate() : d.getDate(),
- hours: utc ? d.getUTCHours() : d.getHours(),
- minutes: utc ? d.getUTCMinutes() : d.getMinutes(),
- seconds: utc ? d.getUTCSeconds() : d.getSeconds()
- };
-
- return ((val.year-1980) << 25) | ((val.month+1) << 21) | (val.date << 16) |
- (val.hours << 11) | (val.minutes << 5) | (val.seconds / 2);
-};
-
-util.isStream = function(source) {
- return source instanceof Stream;
-};
-
-util.normalizeInputSource = function(source) {
- if (source === null) {
- return new Buffer(0);
- } else if (typeof source === 'string') {
- return new Buffer(source);
- } else if (util.isStream(source) && !source._readableState) {
- var normalized = new PassThrough();
- source.pipe(normalized);
-
- return normalized;
- }
-
- return source;
-};
-
-util.sanitizePath = function() {
- var filepath = path.join.apply(path, arguments);
- return filepath.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
-};
-
-util.unixifyPath = function() {
- var filepath = path.join.apply(path, arguments);
- return filepath.replace(/\\/g, '/');
+/**
+ * node-zip-stream
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-zip-stream/blob/master/LICENSE-MIT
+ */
+var fs = require('fs');
+var path = require('path');
+
+var Stream = require('stream').Stream;
+var PassThrough = require('readable-stream').PassThrough;
+
+var _ = require('lodash');
+
+var util = module.exports = {};
+
+util.convertDateTimeDos = function(input) {
+ return new Date(
+ ((input >> 25) & 0x7f) + 1980,
+ ((input >> 21) & 0x0f) - 1,
+ (input >> 16) & 0x1f,
+ (input >> 11) & 0x1f,
+ (input >> 5) & 0x3f,
+ (input & 0x1f) << 1
+ );
+};
+
+util.dateify = function(dateish) {
+ dateish = dateish || new Date();
+
+ if (dateish instanceof Date) {
+ dateish = dateish;
+ } else if (typeof dateish === 'string') {
+ dateish = new Date(dateish);
+ } else {
+ dateish = new Date();
+ }
+
+ return dateish;
+};
+
+// this is slightly different from lodash version
+util.defaults = function(object, source, guard) {
+ var args = arguments;
+ args[0] = args[0] || {};
+
+ return _.defaults.apply(_, args);
+};
+
+util.dosDateTime = function(d, utc) {
+ d = (d instanceof Date) ? d : util.dateify(d);
+ utc = utc || false;
+
+ var year = utc ? d.getUTCFullYear() : d.getFullYear();
+
+ if (year < 1980) {
+ return 2162688; // 1980-1-1 00:00:00
+ } else if (year >= 2044) {
+ return 2141175677; // 2043-12-31 23:59:58
+ }
+
+ var val = {
+ year: year,
+ month: utc ? d.getUTCMonth() : d.getMonth(),
+ date: utc ? d.getUTCDate() : d.getDate(),
+ hours: utc ? d.getUTCHours() : d.getHours(),
+ minutes: utc ? d.getUTCMinutes() : d.getMinutes(),
+ seconds: utc ? d.getUTCSeconds() : d.getSeconds()
+ };
+
+ return ((val.year-1980) << 25) | ((val.month+1) << 21) | (val.date << 16) |
+ (val.hours << 11) | (val.minutes << 5) | (val.seconds / 2);
+};
+
+util.isStream = function(source) {
+ return source instanceof Stream;
+};
+
+util.normalizeInputSource = function(source) {
+ if (source === null) {
+ return new Buffer(0);
+ } else if (typeof source === 'string') {
+ return new Buffer(source);
+ } else if (util.isStream(source) && !source._readableState) {
+ var normalized = new PassThrough();
+ source.pipe(normalized);
+
+ return normalized;
+ }
+
+ return source;
+};
+
+util.sanitizePath = function() {
+ var filepath = path.join.apply(path, arguments);
+ return filepath.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
+};
+
+util.unixifyPath = function() {
+ var filepath = path.join.apply(path, arguments);
+ return filepath.replace(/\\/g, '/');
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/lib/zip-stream.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/lib/zip-stream.js b/node_modules/archiver/node_modules/zip-stream/lib/zip-stream.js
index cd64d8f..358567e 100644
--- a/node_modules/archiver/node_modules/zip-stream/lib/zip-stream.js
+++ b/node_modules/archiver/node_modules/zip-stream/lib/zip-stream.js
@@ -1,110 +1,110 @@
-/**
- * node-zip-stream
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-zip-stream/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-
-var ZipArchiveOutputStream = require('compress-commons').ZipArchiveOutputStream;
-var ZipArchiveEntry = require('compress-commons').ZipArchiveEntry;
-
-var util = require('./util');
-
-var ZipStream = module.exports = function(options) {
- if (!(this instanceof ZipStream)) {
- return new ZipStream(options);
- }
-
- options = this.options = options || {};
- options.zlib = options.zlib || {};
-
- ZipArchiveOutputStream.call(this, options);
-
- if (typeof options.level === 'number' && options.level >= 0) {
- options.zlib.level = options.level;
- delete options.level;
- }
-
- if (options.zlib.level && options.zlib.level === 0) {
- options.store = true;
- }
-
- if (options.comment && options.comment.length > 0) {
- this.setComment(options.comment);
- }
-};
-
-inherits(ZipStream, ZipArchiveOutputStream);
-
-ZipStream.prototype._normalizeFileData = function(data) {
- data = util.defaults(data, {
- type: 'file',
- name: null,
- date: null,
- mode: null,
- store: this.options.store,
- comment: ''
- });
-
- var isDir = data.type === 'directory';
-
- if (data.name) {
- data.name = util.sanitizePath(data.name);
-
- if (data.name.slice(-1) === '/') {
- isDir = true;
- data.type = 'directory';
- } else if (isDir) {
- data.name += '/';
- }
- }
-
- if (isDir) {
- data.store = true;
- }
-
- data.date = util.dateify(data.date);
-
- return data;
-};
-
-ZipStream.prototype.entry = function(source, data, callback) {
- if (typeof callback !== 'function') {
- callback = this._emitErrorCallback.bind(this);
- }
-
- data = this._normalizeFileData(data);
-
- if (data.type !== 'file' && data.type !== 'directory') {
- callback(new Error(data.type + ' entries not currently supported'));
- return;
- }
-
- if (typeof data.name !== 'string' || data.name.length === 0) {
- callback(new Error('entry name must be a non-empty string value'));
- return;
- }
-
- var entry = new ZipArchiveEntry(data.name);
- entry.setTime(data.date);
-
- if (data.store) {
- entry.setMethod(0);
- }
-
- if (data.comment.length > 0) {
- entry.setComment(data.comment);
- }
-
- if (typeof data.mode === 'number') {
- entry.setUnixMode(data.mode);
- }
-
- return ZipArchiveOutputStream.prototype.entry.call(this, entry, source, callback);
-};
-
-ZipStream.prototype.finalize = function() {
- this.finish();
+/**
+ * node-zip-stream
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-zip-stream/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+
+var ZipArchiveOutputStream = require('compress-commons').ZipArchiveOutputStream;
+var ZipArchiveEntry = require('compress-commons').ZipArchiveEntry;
+
+var util = require('./util');
+
+var ZipStream = module.exports = function(options) {
+ if (!(this instanceof ZipStream)) {
+ return new ZipStream(options);
+ }
+
+ options = this.options = options || {};
+ options.zlib = options.zlib || {};
+
+ ZipArchiveOutputStream.call(this, options);
+
+ if (typeof options.level === 'number' && options.level >= 0) {
+ options.zlib.level = options.level;
+ delete options.level;
+ }
+
+ if (options.zlib.level && options.zlib.level === 0) {
+ options.store = true;
+ }
+
+ if (options.comment && options.comment.length > 0) {
+ this.setComment(options.comment);
+ }
+};
+
+inherits(ZipStream, ZipArchiveOutputStream);
+
+ZipStream.prototype._normalizeFileData = function(data) {
+ data = util.defaults(data, {
+ type: 'file',
+ name: null,
+ date: null,
+ mode: null,
+ store: this.options.store,
+ comment: ''
+ });
+
+ var isDir = data.type === 'directory';
+
+ if (data.name) {
+ data.name = util.sanitizePath(data.name);
+
+ if (data.name.slice(-1) === '/') {
+ isDir = true;
+ data.type = 'directory';
+ } else if (isDir) {
+ data.name += '/';
+ }
+ }
+
+ if (isDir) {
+ data.store = true;
+ }
+
+ data.date = util.dateify(data.date);
+
+ return data;
+};
+
+ZipStream.prototype.entry = function(source, data, callback) {
+ if (typeof callback !== 'function') {
+ callback = this._emitErrorCallback.bind(this);
+ }
+
+ data = this._normalizeFileData(data);
+
+ if (data.type !== 'file' && data.type !== 'directory') {
+ callback(new Error(data.type + ' entries not currently supported'));
+ return;
+ }
+
+ if (typeof data.name !== 'string' || data.name.length === 0) {
+ callback(new Error('entry name must be a non-empty string value'));
+ return;
+ }
+
+ var entry = new ZipArchiveEntry(data.name);
+ entry.setTime(data.date);
+
+ if (data.store) {
+ entry.setMethod(0);
+ }
+
+ if (data.comment.length > 0) {
+ entry.setComment(data.comment);
+ }
+
+ if (typeof data.mode === 'number') {
+ entry.setUnixMode(data.mode);
+ }
+
+ return ZipArchiveOutputStream.prototype.entry.call(this, entry, source, callback);
+};
+
+ZipStream.prototype.finalize = function() {
+ this.finish();
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/LICENSE-MIT
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/LICENSE-MIT b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/LICENSE-MIT
index 819b403..56420a6 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/LICENSE-MIT
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/LICENSE-MIT
@@ -1,22 +1,22 @@
-Copyright (c) 2014 Chris Talkington, contributors.
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+Copyright (c) 2014 Chris Talkington, contributors.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/README.md
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/README.md b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/README.md
index 0124a0e..145d46d 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/README.md
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/README.md
@@ -1,25 +1,25 @@
-# Compress Commons v0.2.7 [](https://travis-ci.org/archiverjs/node-compress-commons)
-
-Compress Commons is a library that defines a common interface for working with archive formats within node.
-
-[](https://nodei.co/npm/compress-commons/)
-
-## Install
-
-```bash
-npm install compress-commons --save
-```
-
-You can also use `npm install https://github.com/archiverjs/node-compress-commons/archive/master.tar.gz` to test upcoming versions.
-
-## Things of Interest
-
-- [Changelog](https://github.com/archiverjs/node-compress-commons/releases)
-- [Contributing](https://github.com/archiverjs/node-compress-commons/blob/master/CONTRIBUTING.md)
-- [MIT License](https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT)
-
-## Credits
-
-Concept inspired by [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™.
-
+# Compress Commons v0.2.7 [](https://travis-ci.org/archiverjs/node-compress-commons)
+
+Compress Commons is a library that defines a common interface for working with archive formats within node.
+
+[](https://nodei.co/npm/compress-commons/)
+
+## Install
+
+```bash
+npm install compress-commons --save
+```
+
+You can also use `npm install https://github.com/archiverjs/node-compress-commons/archive/master.tar.gz` to test upcoming versions.
+
+## Things of Interest
+
+- [Changelog](https://github.com/archiverjs/node-compress-commons/releases)
+- [Contributing](https://github.com/archiverjs/node-compress-commons/blob/master/CONTRIBUTING.md)
+- [MIT License](https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT)
+
+## Credits
+
+Concept inspired by [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™.
+
Some logic derived from [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™ and [OpenJDK 7](http://openjdk.java.net/).
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-entry.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-entry.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-entry.js
index 3c6f8b8..4985e2c 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-entry.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-entry.js
@@ -1,16 +1,16 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var ArchiveEntry = module.exports = function() {};
-
-ArchiveEntry.prototype.getName = function() {};
-
-ArchiveEntry.prototype.getSize = function() {};
-
-ArchiveEntry.prototype.getLastModifiedDate = function() {};
-
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var ArchiveEntry = module.exports = function() {};
+
+ArchiveEntry.prototype.getName = function() {};
+
+ArchiveEntry.prototype.getSize = function() {};
+
+ArchiveEntry.prototype.getLastModifiedDate = function() {};
+
ArchiveEntry.prototype.isDirectory = function() {};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-output-stream.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-output-stream.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-output-stream.js
index b2325bc..8a3233a 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-output-stream.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/archive-output-stream.js
@@ -1,118 +1,118 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-var Transform = require('readable-stream').Transform;
-
-var ArchiveEntry = require('./archive-entry');
-var util = require('../util');
-
-var ArchiveOutputStream = module.exports = function(options) {
- if (!(this instanceof ArchiveOutputStream)) {
- return new ArchiveOutputStream(options);
- }
-
- Transform.call(this, options);
-
- this.offset = 0;
- this._archive = {
- finish: false,
- finished: false,
- processing: false
- };
-};
-
-inherits(ArchiveOutputStream, Transform);
-
-ArchiveOutputStream.prototype._appendBuffer = function(zae, source, callback) {
- // scaffold only
-};
-
-ArchiveOutputStream.prototype._appendStream = function(zae, source, callback) {
- // scaffold only
-};
-
-ArchiveOutputStream.prototype._emitErrorCallback = function(err) {
- if (err) {
- this.emit('error', err);
- }
-};
-
-ArchiveOutputStream.prototype._finish = function(ae) {
- // scaffold only
-};
-
-ArchiveOutputStream.prototype._normalizeEntry = function(ae) {
- // scaffold only
-};
-
-ArchiveOutputStream.prototype._transform = function(chunk, encoding, callback) {
- callback(null, chunk);
-};
-
-ArchiveOutputStream.prototype.entry = function(ae, source, callback) {
- source = source || null;
-
- if (typeof callback !== 'function') {
- callback = this._emitErrorCallback.bind(this);
- }
-
- if (!(ae instanceof ArchiveEntry)) {
- callback(new Error('not a valid instance of ArchiveEntry'));
- return;
- }
-
- if (this._archive.finish || this._archive.finished) {
- callback(new Error('unacceptable entry after finish'));
- return;
- }
-
- if (this._archive.processing) {
- callback(new Error('already processing an entry'));
- return;
- }
-
- this._archive.processing = true;
- this._normalizeEntry(ae);
- this._entry = ae;
-
- source = util.normalizeInputSource(source);
-
- if (Buffer.isBuffer(source)) {
- this._appendBuffer(ae, source, callback);
- } else if (util.isStream(source)) {
- source.on('error', callback);
- this._appendStream(ae, source, callback);
- } else {
- this._archive.processing = false;
- callback(new Error('input source must be valid Stream or Buffer instance'));
- return;
- }
-
- return this;
-};
-
-ArchiveOutputStream.prototype.finish = function() {
- if (this._archive.processing) {
- this._archive.finish = true;
- return;
- }
-
- this._finish();
-};
-
-ArchiveOutputStream.prototype.getBytesWritten = function() {
- return this.offset;
-};
-
-ArchiveOutputStream.prototype.write = function(chunk, cb) {
- if (chunk) {
- this.offset += chunk.length;
- }
-
- return Transform.prototype.write.call(this, chunk, cb);
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+var Transform = require('readable-stream').Transform;
+
+var ArchiveEntry = require('./archive-entry');
+var util = require('../util');
+
+var ArchiveOutputStream = module.exports = function(options) {
+ if (!(this instanceof ArchiveOutputStream)) {
+ return new ArchiveOutputStream(options);
+ }
+
+ Transform.call(this, options);
+
+ this.offset = 0;
+ this._archive = {
+ finish: false,
+ finished: false,
+ processing: false
+ };
+};
+
+inherits(ArchiveOutputStream, Transform);
+
+ArchiveOutputStream.prototype._appendBuffer = function(zae, source, callback) {
+ // scaffold only
+};
+
+ArchiveOutputStream.prototype._appendStream = function(zae, source, callback) {
+ // scaffold only
+};
+
+ArchiveOutputStream.prototype._emitErrorCallback = function(err) {
+ if (err) {
+ this.emit('error', err);
+ }
+};
+
+ArchiveOutputStream.prototype._finish = function(ae) {
+ // scaffold only
+};
+
+ArchiveOutputStream.prototype._normalizeEntry = function(ae) {
+ // scaffold only
+};
+
+ArchiveOutputStream.prototype._transform = function(chunk, encoding, callback) {
+ callback(null, chunk);
+};
+
+ArchiveOutputStream.prototype.entry = function(ae, source, callback) {
+ source = source || null;
+
+ if (typeof callback !== 'function') {
+ callback = this._emitErrorCallback.bind(this);
+ }
+
+ if (!(ae instanceof ArchiveEntry)) {
+ callback(new Error('not a valid instance of ArchiveEntry'));
+ return;
+ }
+
+ if (this._archive.finish || this._archive.finished) {
+ callback(new Error('unacceptable entry after finish'));
+ return;
+ }
+
+ if (this._archive.processing) {
+ callback(new Error('already processing an entry'));
+ return;
+ }
+
+ this._archive.processing = true;
+ this._normalizeEntry(ae);
+ this._entry = ae;
+
+ source = util.normalizeInputSource(source);
+
+ if (Buffer.isBuffer(source)) {
+ this._appendBuffer(ae, source, callback);
+ } else if (util.isStream(source)) {
+ source.on('error', callback);
+ this._appendStream(ae, source, callback);
+ } else {
+ this._archive.processing = false;
+ callback(new Error('input source must be valid Stream or Buffer instance'));
+ return;
+ }
+
+ return this;
+};
+
+ArchiveOutputStream.prototype.finish = function() {
+ if (this._archive.processing) {
+ this._archive.finish = true;
+ return;
+ }
+
+ this._finish();
+};
+
+ArchiveOutputStream.prototype.getBytesWritten = function() {
+ return this.offset;
+};
+
+ArchiveOutputStream.prototype.write = function(chunk, cb) {
+ if (chunk) {
+ this.offset += chunk.length;
+ }
+
+ return Transform.prototype.write.call(this, chunk, cb);
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/constants.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/constants.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/constants.js
index 2514645..d82778f 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/constants.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/constants.js
@@ -1,71 +1,71 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-module.exports = {
- WORD: 4,
- DWORD: 8,
- EMPTY: new Buffer(0),
-
- SHORT: 2,
- SHORT_MASK: 0xffff,
- SHORT_SHIFT: 16,
- SHORT_ZERO: new Buffer(Array(2)),
- LONG: 4,
- LONG_ZERO: new Buffer(Array(4)),
-
- MIN_VERSION_INITIAL: 10,
- MIN_VERSION_DATA_DESCRIPTOR: 20,
- MIN_VERSION_ZIP64: 45,
- VERSION_MADEBY: 45,
-
- METHOD_STORED: 0,
- METHOD_DEFLATED: 8,
-
- PLATFORM_UNIX: 3,
- PLATFORM_FAT: 0,
-
- SIG_LFH: 0x04034b50,
- SIG_DD: 0x08074b50,
- SIG_CFH: 0x02014b50,
- SIG_EOCD: 0x06054b50,
- SIG_ZIP64_EOCD: 0x06064B50,
- SIG_ZIP64_EOCD_LOC: 0x07064B50,
-
- ZIP64_MAGIC_SHORT: 0xffff,
- ZIP64_MAGIC: 0xffffffff,
- ZIP64_EXTRA_ID: 0x0001,
-
- ZLIB_NO_COMPRESSION: 0,
- ZLIB_BEST_SPEED: 1,
- ZLIB_BEST_COMPRESSION: 9,
- ZLIB_DEFAULT_COMPRESSION: -1,
-
- MODE_MASK: 0xFFF,
- DEFAULT_FILE_MODE: 0100644, // 644 -rw-r--r-- = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
- DEFAULT_DIR_MODE: 040755, // 755 drwxr-xr-x = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
-
- EXT_FILE_ATTR_DIR: 010173200020, // 755 drwxr-xr-x = (((S_IFDIR | 0755) << 16) | S_DOS_D)
- EXT_FILE_ATTR_FILE: 020151000040, // 644 -rw-r--r-- = (((S_IFREG | 0644) << 16) | S_DOS_A) >>> 0
-
- // Unix file types
- S_IFMT: 0170000, // type of file mask
- S_IFIFO: 010000, // named pipe (fifo)
- S_IFCHR: 020000, // character special
- S_IFDIR: 040000, // directory
- S_IFBLK: 060000, // block special
- S_IFREG: 0100000, // regular
- S_IFLNK: 0120000, // symbolic link
- S_IFSOCK: 0140000, // socket
-
- // DOS file type flags
- S_DOS_A: 040, // Archive
- S_DOS_D: 020, // Directory
- S_DOS_V: 010, // Volume
- S_DOS_S: 04, // System
- S_DOS_H: 02, // Hidden
- S_DOS_R: 01 // Read Only
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+module.exports = {
+ WORD: 4,
+ DWORD: 8,
+ EMPTY: new Buffer(0),
+
+ SHORT: 2,
+ SHORT_MASK: 0xffff,
+ SHORT_SHIFT: 16,
+ SHORT_ZERO: new Buffer(Array(2)),
+ LONG: 4,
+ LONG_ZERO: new Buffer(Array(4)),
+
+ MIN_VERSION_INITIAL: 10,
+ MIN_VERSION_DATA_DESCRIPTOR: 20,
+ MIN_VERSION_ZIP64: 45,
+ VERSION_MADEBY: 45,
+
+ METHOD_STORED: 0,
+ METHOD_DEFLATED: 8,
+
+ PLATFORM_UNIX: 3,
+ PLATFORM_FAT: 0,
+
+ SIG_LFH: 0x04034b50,
+ SIG_DD: 0x08074b50,
+ SIG_CFH: 0x02014b50,
+ SIG_EOCD: 0x06054b50,
+ SIG_ZIP64_EOCD: 0x06064B50,
+ SIG_ZIP64_EOCD_LOC: 0x07064B50,
+
+ ZIP64_MAGIC_SHORT: 0xffff,
+ ZIP64_MAGIC: 0xffffffff,
+ ZIP64_EXTRA_ID: 0x0001,
+
+ ZLIB_NO_COMPRESSION: 0,
+ ZLIB_BEST_SPEED: 1,
+ ZLIB_BEST_COMPRESSION: 9,
+ ZLIB_DEFAULT_COMPRESSION: -1,
+
+ MODE_MASK: 0xFFF,
+ DEFAULT_FILE_MODE: 0100644, // 644 -rw-r--r-- = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
+ DEFAULT_DIR_MODE: 040755, // 755 drwxr-xr-x = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
+
+ EXT_FILE_ATTR_DIR: 010173200020, // 755 drwxr-xr-x = (((S_IFDIR | 0755) << 16) | S_DOS_D)
+ EXT_FILE_ATTR_FILE: 020151000040, // 644 -rw-r--r-- = (((S_IFREG | 0644) << 16) | S_DOS_A) >>> 0
+
+ // Unix file types
+ S_IFMT: 0170000, // type of file mask
+ S_IFIFO: 010000, // named pipe (fifo)
+ S_IFCHR: 020000, // character special
+ S_IFDIR: 040000, // directory
+ S_IFBLK: 060000, // block special
+ S_IFREG: 0100000, // regular
+ S_IFLNK: 0120000, // symbolic link
+ S_IFSOCK: 0140000, // socket
+
+ // DOS file type flags
+ S_DOS_A: 040, // Archive
+ S_DOS_D: 020, // Directory
+ S_DOS_V: 010, // Volume
+ S_DOS_S: 04, // System
+ S_DOS_H: 02, // Hidden
+ S_DOS_R: 01 // Read Only
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/general-purpose-bit.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/general-purpose-bit.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/general-purpose-bit.js
index dc21073..96f3702 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/general-purpose-bit.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/general-purpose-bit.js
@@ -1,101 +1,101 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var zipUtil = require('./util');
-
-var DATA_DESCRIPTOR_FLAG = 1 << 3;
-var ENCRYPTION_FLAG = 1 << 0;
-var NUMBER_OF_SHANNON_FANO_TREES_FLAG = 1 << 2;
-var SLIDING_DICTIONARY_SIZE_FLAG = 1 << 1;
-var STRONG_ENCRYPTION_FLAG = 1 << 6;
-var UFT8_NAMES_FLAG = 1 << 11;
-
-var GeneralPurposeBit = module.exports = function() {
- if (!(this instanceof GeneralPurposeBit)) {
- return new GeneralPurposeBit();
- }
-
- this.descriptor = false;
- this.encryption = false;
- this.utf8 = false;
- this.numberOfShannonFanoTrees = 0;
- this.strongEncryption = false;
- this.slidingDictionarySize = 0;
-
- return this;
-};
-
-GeneralPurposeBit.prototype.encode = function() {
- return zipUtil.getShortBytes(
- (this.descriptor ? DATA_DESCRIPTOR_FLAG : 0) |
- (this.utf8 ? UFT8_NAMES_FLAG : 0) |
- (this.encryption ? ENCRYPTION_FLAG : 0) |
- (this.strongEncryption ? STRONG_ENCRYPTION_FLAG : 0)
- );
-};
-
-GeneralPurposeBit.prototype.parse = function(buf, offset) {
- var flag = zipUtil.getShortBytesValue(buf, offset);
- var gbp = new GeneralPurposeBit();
-
- gbp.useDataDescriptor((flag & DATA_DESCRIPTOR_FLAG) !== 0);
- gbp.useUTF8ForNames((flag & UFT8_NAMES_FLAG) !== 0);
- gbp.useStrongEncryption((flag & STRONG_ENCRYPTION_FLAG) !== 0);
- gbp.useEncryption((flag & ENCRYPTION_FLAG) !== 0);
- gbp.setSlidingDictionarySize((flag & SLIDING_DICTIONARY_SIZE_FLAG) !== 0 ? 8192 : 4096);
- gbp.setNumberOfShannonFanoTrees((flag & NUMBER_OF_SHANNON_FANO_TREES_FLAG) !== 0 ? 3 : 2);
-
- return gbp;
-};
-
-GeneralPurposeBit.prototype.setNumberOfShannonFanoTrees = function(n) {
- this.numberOfShannonFanoTrees = n;
-};
-
-GeneralPurposeBit.prototype.getNumberOfShannonFanoTrees = function() {
- return this.numberOfShannonFanoTrees;
-};
-
-GeneralPurposeBit.prototype.setSlidingDictionarySize = function(n) {
- this.slidingDictionarySize = n;
-};
-
-GeneralPurposeBit.prototype.getSlidingDictionarySize = function() {
- return this.slidingDictionarySize;
-};
-
-GeneralPurposeBit.prototype.useDataDescriptor = function(b) {
- this.descriptor = b;
-};
-
-GeneralPurposeBit.prototype.usesDataDescriptor = function() {
- return this.descriptor;
-};
-
-GeneralPurposeBit.prototype.useEncryption = function(b) {
- this.encryption = b;
-};
-
-GeneralPurposeBit.prototype.usesEncryption = function() {
- return this.encryption;
-};
-
-GeneralPurposeBit.prototype.useStrongEncryption = function(b) {
- this.strongEncryption = b;
-};
-
-GeneralPurposeBit.prototype.usesStrongEncryption = function() {
- return this.strongEncryption;
-};
-
-GeneralPurposeBit.prototype.useUTF8ForNames = function(b) {
- this.utf8 = b;
-};
-
-GeneralPurposeBit.prototype.usesUTF8ForNames = function() {
- return this.utf8;
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var zipUtil = require('./util');
+
+var DATA_DESCRIPTOR_FLAG = 1 << 3;
+var ENCRYPTION_FLAG = 1 << 0;
+var NUMBER_OF_SHANNON_FANO_TREES_FLAG = 1 << 2;
+var SLIDING_DICTIONARY_SIZE_FLAG = 1 << 1;
+var STRONG_ENCRYPTION_FLAG = 1 << 6;
+var UFT8_NAMES_FLAG = 1 << 11;
+
+var GeneralPurposeBit = module.exports = function() {
+ if (!(this instanceof GeneralPurposeBit)) {
+ return new GeneralPurposeBit();
+ }
+
+ this.descriptor = false;
+ this.encryption = false;
+ this.utf8 = false;
+ this.numberOfShannonFanoTrees = 0;
+ this.strongEncryption = false;
+ this.slidingDictionarySize = 0;
+
+ return this;
+};
+
+GeneralPurposeBit.prototype.encode = function() {
+ return zipUtil.getShortBytes(
+ (this.descriptor ? DATA_DESCRIPTOR_FLAG : 0) |
+ (this.utf8 ? UFT8_NAMES_FLAG : 0) |
+ (this.encryption ? ENCRYPTION_FLAG : 0) |
+ (this.strongEncryption ? STRONG_ENCRYPTION_FLAG : 0)
+ );
+};
+
+GeneralPurposeBit.prototype.parse = function(buf, offset) {
+ var flag = zipUtil.getShortBytesValue(buf, offset);
+ var gbp = new GeneralPurposeBit();
+
+ gbp.useDataDescriptor((flag & DATA_DESCRIPTOR_FLAG) !== 0);
+ gbp.useUTF8ForNames((flag & UFT8_NAMES_FLAG) !== 0);
+ gbp.useStrongEncryption((flag & STRONG_ENCRYPTION_FLAG) !== 0);
+ gbp.useEncryption((flag & ENCRYPTION_FLAG) !== 0);
+ gbp.setSlidingDictionarySize((flag & SLIDING_DICTIONARY_SIZE_FLAG) !== 0 ? 8192 : 4096);
+ gbp.setNumberOfShannonFanoTrees((flag & NUMBER_OF_SHANNON_FANO_TREES_FLAG) !== 0 ? 3 : 2);
+
+ return gbp;
+};
+
+GeneralPurposeBit.prototype.setNumberOfShannonFanoTrees = function(n) {
+ this.numberOfShannonFanoTrees = n;
+};
+
+GeneralPurposeBit.prototype.getNumberOfShannonFanoTrees = function() {
+ return this.numberOfShannonFanoTrees;
+};
+
+GeneralPurposeBit.prototype.setSlidingDictionarySize = function(n) {
+ this.slidingDictionarySize = n;
+};
+
+GeneralPurposeBit.prototype.getSlidingDictionarySize = function() {
+ return this.slidingDictionarySize;
+};
+
+GeneralPurposeBit.prototype.useDataDescriptor = function(b) {
+ this.descriptor = b;
+};
+
+GeneralPurposeBit.prototype.usesDataDescriptor = function() {
+ return this.descriptor;
+};
+
+GeneralPurposeBit.prototype.useEncryption = function(b) {
+ this.encryption = b;
+};
+
+GeneralPurposeBit.prototype.usesEncryption = function() {
+ return this.encryption;
+};
+
+GeneralPurposeBit.prototype.useStrongEncryption = function(b) {
+ this.strongEncryption = b;
+};
+
+GeneralPurposeBit.prototype.usesStrongEncryption = function() {
+ return this.strongEncryption;
+};
+
+GeneralPurposeBit.prototype.useUTF8ForNames = function(b) {
+ this.utf8 = b;
+};
+
+GeneralPurposeBit.prototype.usesUTF8ForNames = function() {
+ return this.utf8;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/util.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/util.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/util.js
index 36c69a9..7fcab60 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/util.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/util.js
@@ -1,84 +1,84 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var Int64 = require('node-int64');
-var util = module.exports = {};
-
-util.dateToDos = function(d) {
- var year = d.getFullYear();
-
- if (year < 1980) {
- return 2162688; // 1980-1-1 00:00:00
- } else if (year >= 2044) {
- return 2141175677; // 2043-12-31 23:59:58
- }
-
- var val = {
- year: year,
- month: d.getMonth(),
- date: d.getDate(),
- hours: d.getHours(),
- minutes: d.getMinutes(),
- seconds: d.getSeconds()
- };
-
- return ((val.year - 1980) << 25) | ((val.month + 1) << 21) | (val.date << 16) |
- (val.hours << 11) | (val.minutes << 5) | (val.seconds / 2);
-};
-
-util.dosToDate = function(dos) {
- return new Date(
- ((dos >> 25) & 0x7f) + 1980,
- ((dos >> 21) & 0x0f) - 1,
- (dos >> 16) & 0x1f,
- (dos >> 11) & 0x1f,
- (dos >> 5) & 0x3f,
- (dos & 0x1f) << 1
- );
-};
-
-util.fromDosTime = function(buf) {
- return util.dosToDate(buf.readUInt32LE());
-};
-
-util.getEightBytes = function(v) {
- var buf = new Buffer(8);
- var i64 = new Int64(v);
-
- // BE to LE
- for(i = 0; i < 8; i++) {
- buf[i] = i64.buffer[7 - i];
- }
-
- return buf;
-};
-
-util.getShortBytes = function(v) {
- var buf = new Buffer(2);
- buf.writeUInt16LE(v, 0);
-
- return buf;
-};
-
-util.getShortBytesValue = function(buf, offset) {
- return buf.readUInt16LE(offset);
-};
-
-util.getLongBytes = function(v) {
- var buf = new Buffer(4);
- buf.writeUInt32LE(v, 0);
-
- return buf;
-};
-
-util.getLongBytesValue = function(buf, offset) {
- return buf.readUInt32LE(offset);
-};
-
-util.toDosTime = function(d) {
- return util.getLongBytes(util.dateToDos(d));
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var Int64 = require('node-int64');
+var util = module.exports = {};
+
+util.dateToDos = function(d) {
+ var year = d.getFullYear();
+
+ if (year < 1980) {
+ return 2162688; // 1980-1-1 00:00:00
+ } else if (year >= 2044) {
+ return 2141175677; // 2043-12-31 23:59:58
+ }
+
+ var val = {
+ year: year,
+ month: d.getMonth(),
+ date: d.getDate(),
+ hours: d.getHours(),
+ minutes: d.getMinutes(),
+ seconds: d.getSeconds()
+ };
+
+ return ((val.year - 1980) << 25) | ((val.month + 1) << 21) | (val.date << 16) |
+ (val.hours << 11) | (val.minutes << 5) | (val.seconds / 2);
+};
+
+util.dosToDate = function(dos) {
+ return new Date(
+ ((dos >> 25) & 0x7f) + 1980,
+ ((dos >> 21) & 0x0f) - 1,
+ (dos >> 16) & 0x1f,
+ (dos >> 11) & 0x1f,
+ (dos >> 5) & 0x3f,
+ (dos & 0x1f) << 1
+ );
+};
+
+util.fromDosTime = function(buf) {
+ return util.dosToDate(buf.readUInt32LE());
+};
+
+util.getEightBytes = function(v) {
+ var buf = new Buffer(8);
+ var i64 = new Int64(v);
+
+ // BE to LE
+ for(i = 0; i < 8; i++) {
+ buf[i] = i64.buffer[7 - i];
+ }
+
+ return buf;
+};
+
+util.getShortBytes = function(v) {
+ var buf = new Buffer(2);
+ buf.writeUInt16LE(v, 0);
+
+ return buf;
+};
+
+util.getShortBytesValue = function(buf, offset) {
+ return buf.readUInt16LE(offset);
+};
+
+util.getLongBytes = function(v) {
+ var buf = new Buffer(4);
+ buf.writeUInt32LE(v, 0);
+
+ return buf;
+};
+
+util.getLongBytesValue = function(buf, offset) {
+ return buf.readUInt32LE(offset);
+};
+
+util.toDosTime = function(d) {
+ return util.getLongBytes(util.dateToDos(d));
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-entry.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-entry.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-entry.js
index 9eecf00..cffb826 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-entry.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-entry.js
@@ -1,223 +1,223 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-
-var ArchiveEntry = require('../archive-entry');
-var GeneralPurposeBit = require('./general-purpose-bit');
-
-var constants = require('./constants');
-var zipUtil = require('./util');
-
-var ZipArchiveEntry = module.exports = function(name) {
- if (!(this instanceof ZipArchiveEntry)) {
- return new ZipArchiveEntry(name);
- }
-
- ArchiveEntry.call(this);
-
- this.platform = constants.PLATFORM_FAT;
- this.method = -1;
-
- this.name = null;
- this.size = -1;
- this.csize = -1;
- this.gpb = new GeneralPurposeBit();
- this.crc = 0;
- this.time = -1;
-
- this.minver = constants.MIN_VERSION_INITIAL;
- this.mode = -1;
- this.extra = null;
- this.exattr = 0;
- this.inattr = 0;
- this.comment = null;
-
- if (name) {
- this.setName(name);
- }
-};
-
-inherits(ZipArchiveEntry, ArchiveEntry);
-
-ZipArchiveEntry.prototype.getCentralDirectoryExtra = function() {
- return this.getExtra();
-};
-
-ZipArchiveEntry.prototype.getComment = function() {
- return this.comment !== null ? this.comment : '';
-};
-
-ZipArchiveEntry.prototype.getCompressedSize = function() {
- return this.csize;
-};
-
-ZipArchiveEntry.prototype.getCrc = function() {
- return this.crc;
-};
-
-ZipArchiveEntry.prototype.getExternalAttributes = function() {
- return this.exattr;
-};
-
-ZipArchiveEntry.prototype.getExtra = function() {
- return this.extra !== null ? this.extra : constants.EMPTY;
-};
-
-ZipArchiveEntry.prototype.getGeneralPurposeBit = function() {
- return this.gpb;
-};
-
-ZipArchiveEntry.prototype.getInternalAttributes = function() {
- return this.inattr;
-};
-
-ZipArchiveEntry.prototype.getLastModifiedDate = function() {
- return this.getTime();
-};
-
-ZipArchiveEntry.prototype.getLocalFileDataExtra = function() {
- return this.getExtra();
-};
-
-ZipArchiveEntry.prototype.getMethod = function() {
- return this.method;
-};
-
-ZipArchiveEntry.prototype.getName = function() {
- return this.name;
-};
-
-ZipArchiveEntry.prototype.getPlatform = function() {
- return this.platform;
-};
-
-ZipArchiveEntry.prototype.getSize = function() {
- return this.size;
-};
-
-ZipArchiveEntry.prototype.getTime = function() {
- return this.time !== -1 ? zipUtil.dosToDate(this.time) : -1;
-};
-
-ZipArchiveEntry.prototype.getTimeDos = function() {
- return this.time !== -1 ? this.time : 0;
-};
-
-ZipArchiveEntry.prototype.getUnixMode = function() {
- return this.platform !== constants.PLATFORM_UNIX ? 0 : ((this.getExternalAttributes() >> constants.SHORT_SHIFT) & constants.SHORT_MASK) & constants.MODE_MASK;
-};
-
-ZipArchiveEntry.prototype.getVersionNeededToExtract = function() {
- return this.minver;
-};
-
-ZipArchiveEntry.prototype.setComment = function(comment) {
- if (Buffer.byteLength(comment) !== comment.length) {
- this.getGeneralPurposeBit().useUTF8ForNames(true);
- }
-
- this.comment = comment;
-};
-
-ZipArchiveEntry.prototype.setCompressedSize = function(size) {
- if (size < 0) {
- throw new Error('invalid entry compressed size');
- }
-
- this.csize = size;
-};
-
-ZipArchiveEntry.prototype.setCrc = function(crc) {
- if (crc < 0) {
- throw new Error('invalid entry crc32');
- }
-
- this.crc = crc;
-};
-
-ZipArchiveEntry.prototype.setExternalAttributes = function(attr) {
- this.exattr = attr >>> 0;
-};
-
-ZipArchiveEntry.prototype.setExtra = function(extra) {
- this.extra = extra;
-};
-
-ZipArchiveEntry.prototype.setGeneralPurposeBit = function(gpb) {
- if (!(gpb instanceof GeneralPurposeBit)) {
- throw new Error('invalid entry GeneralPurposeBit');
- }
-
- this.gpb = gpb;
-};
-
-ZipArchiveEntry.prototype.setInternalAttributes = function(attr) {
- this.inattr = attr;
-};
-
-ZipArchiveEntry.prototype.setMethod = function(method) {
- if (method < 0) {
- throw new Error('invalid entry compression method');
- }
-
- this.method = method;
-};
-
-ZipArchiveEntry.prototype.setName = function(name) {
- name = name.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
-
- if (Buffer.byteLength(name) !== name.length) {
- this.getGeneralPurposeBit().useUTF8ForNames(true);
- }
-
- this.name = name;
-};
-
-ZipArchiveEntry.prototype.setPlatform = function(platform) {
- this.platform = platform;
-};
-
-ZipArchiveEntry.prototype.setSize = function(size) {
- if (size < 0) {
- throw new Error('invalid entry size');
- }
-
- this.size = size;
-};
-
-ZipArchiveEntry.prototype.setTime = function(time) {
- if (!(time instanceof Date)) {
- throw new Error('invalid entry time');
- }
-
- this.time = zipUtil.dateToDos(time);
-};
-
-ZipArchiveEntry.prototype.setUnixMode = function(mode) {
- mode &= ~constants.S_IFMT;
- mode |= this.isDirectory() ? constants.S_IFDIR : constants.S_IFREG;
-
- var extattr = 0;
- extattr |= (mode << constants.SHORT_SHIFT) | (this.isDirectory() ? constants.S_DOS_D : constants.S_DOS_A);
-
- this.setExternalAttributes(extattr);
- this.mode = mode & constants.MODE_MASK;
- this.platform = constants.PLATFORM_UNIX;
-};
-
-ZipArchiveEntry.prototype.setVersionNeededToExtract = function(minver) {
- this.minver = minver;
-};
-
-ZipArchiveEntry.prototype.isDirectory = function() {
- return this.getName().slice(-1) === '/';
-};
-
-ZipArchiveEntry.prototype.isZip64 = function() {
- return this.csize > constants.ZIP64_MAGIC || this.size > constants.ZIP64_MAGIC;
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+
+var ArchiveEntry = require('../archive-entry');
+var GeneralPurposeBit = require('./general-purpose-bit');
+
+var constants = require('./constants');
+var zipUtil = require('./util');
+
+var ZipArchiveEntry = module.exports = function(name) {
+ if (!(this instanceof ZipArchiveEntry)) {
+ return new ZipArchiveEntry(name);
+ }
+
+ ArchiveEntry.call(this);
+
+ this.platform = constants.PLATFORM_FAT;
+ this.method = -1;
+
+ this.name = null;
+ this.size = -1;
+ this.csize = -1;
+ this.gpb = new GeneralPurposeBit();
+ this.crc = 0;
+ this.time = -1;
+
+ this.minver = constants.MIN_VERSION_INITIAL;
+ this.mode = -1;
+ this.extra = null;
+ this.exattr = 0;
+ this.inattr = 0;
+ this.comment = null;
+
+ if (name) {
+ this.setName(name);
+ }
+};
+
+inherits(ZipArchiveEntry, ArchiveEntry);
+
+ZipArchiveEntry.prototype.getCentralDirectoryExtra = function() {
+ return this.getExtra();
+};
+
+ZipArchiveEntry.prototype.getComment = function() {
+ return this.comment !== null ? this.comment : '';
+};
+
+ZipArchiveEntry.prototype.getCompressedSize = function() {
+ return this.csize;
+};
+
+ZipArchiveEntry.prototype.getCrc = function() {
+ return this.crc;
+};
+
+ZipArchiveEntry.prototype.getExternalAttributes = function() {
+ return this.exattr;
+};
+
+ZipArchiveEntry.prototype.getExtra = function() {
+ return this.extra !== null ? this.extra : constants.EMPTY;
+};
+
+ZipArchiveEntry.prototype.getGeneralPurposeBit = function() {
+ return this.gpb;
+};
+
+ZipArchiveEntry.prototype.getInternalAttributes = function() {
+ return this.inattr;
+};
+
+ZipArchiveEntry.prototype.getLastModifiedDate = function() {
+ return this.getTime();
+};
+
+ZipArchiveEntry.prototype.getLocalFileDataExtra = function() {
+ return this.getExtra();
+};
+
+ZipArchiveEntry.prototype.getMethod = function() {
+ return this.method;
+};
+
+ZipArchiveEntry.prototype.getName = function() {
+ return this.name;
+};
+
+ZipArchiveEntry.prototype.getPlatform = function() {
+ return this.platform;
+};
+
+ZipArchiveEntry.prototype.getSize = function() {
+ return this.size;
+};
+
+ZipArchiveEntry.prototype.getTime = function() {
+ return this.time !== -1 ? zipUtil.dosToDate(this.time) : -1;
+};
+
+ZipArchiveEntry.prototype.getTimeDos = function() {
+ return this.time !== -1 ? this.time : 0;
+};
+
+ZipArchiveEntry.prototype.getUnixMode = function() {
+ return this.platform !== constants.PLATFORM_UNIX ? 0 : ((this.getExternalAttributes() >> constants.SHORT_SHIFT) & constants.SHORT_MASK) & constants.MODE_MASK;
+};
+
+ZipArchiveEntry.prototype.getVersionNeededToExtract = function() {
+ return this.minver;
+};
+
+ZipArchiveEntry.prototype.setComment = function(comment) {
+ if (Buffer.byteLength(comment) !== comment.length) {
+ this.getGeneralPurposeBit().useUTF8ForNames(true);
+ }
+
+ this.comment = comment;
+};
+
+ZipArchiveEntry.prototype.setCompressedSize = function(size) {
+ if (size < 0) {
+ throw new Error('invalid entry compressed size');
+ }
+
+ this.csize = size;
+};
+
+ZipArchiveEntry.prototype.setCrc = function(crc) {
+ if (crc < 0) {
+ throw new Error('invalid entry crc32');
+ }
+
+ this.crc = crc;
+};
+
+ZipArchiveEntry.prototype.setExternalAttributes = function(attr) {
+ this.exattr = attr >>> 0;
+};
+
+ZipArchiveEntry.prototype.setExtra = function(extra) {
+ this.extra = extra;
+};
+
+ZipArchiveEntry.prototype.setGeneralPurposeBit = function(gpb) {
+ if (!(gpb instanceof GeneralPurposeBit)) {
+ throw new Error('invalid entry GeneralPurposeBit');
+ }
+
+ this.gpb = gpb;
+};
+
+ZipArchiveEntry.prototype.setInternalAttributes = function(attr) {
+ this.inattr = attr;
+};
+
+ZipArchiveEntry.prototype.setMethod = function(method) {
+ if (method < 0) {
+ throw new Error('invalid entry compression method');
+ }
+
+ this.method = method;
+};
+
+ZipArchiveEntry.prototype.setName = function(name) {
+ name = name.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
+
+ if (Buffer.byteLength(name) !== name.length) {
+ this.getGeneralPurposeBit().useUTF8ForNames(true);
+ }
+
+ this.name = name;
+};
+
+ZipArchiveEntry.prototype.setPlatform = function(platform) {
+ this.platform = platform;
+};
+
+ZipArchiveEntry.prototype.setSize = function(size) {
+ if (size < 0) {
+ throw new Error('invalid entry size');
+ }
+
+ this.size = size;
+};
+
+ZipArchiveEntry.prototype.setTime = function(time) {
+ if (!(time instanceof Date)) {
+ throw new Error('invalid entry time');
+ }
+
+ this.time = zipUtil.dateToDos(time);
+};
+
+ZipArchiveEntry.prototype.setUnixMode = function(mode) {
+ mode &= ~constants.S_IFMT;
+ mode |= this.isDirectory() ? constants.S_IFDIR : constants.S_IFREG;
+
+ var extattr = 0;
+ extattr |= (mode << constants.SHORT_SHIFT) | (this.isDirectory() ? constants.S_DOS_D : constants.S_DOS_A);
+
+ this.setExternalAttributes(extattr);
+ this.mode = mode & constants.MODE_MASK;
+ this.platform = constants.PLATFORM_UNIX;
+};
+
+ZipArchiveEntry.prototype.setVersionNeededToExtract = function(minver) {
+ this.minver = minver;
+};
+
+ZipArchiveEntry.prototype.isDirectory = function() {
+ return this.getName().slice(-1) === '/';
+};
+
+ZipArchiveEntry.prototype.isZip64 = function() {
+ return this.csize > constants.ZIP64_MAGIC || this.size > constants.ZIP64_MAGIC;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js
index e527875..1dea040 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js
@@ -1,427 +1,427 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-var crc32 = require('buffer-crc32');
-var CRC32Stream = require('crc32-stream');
-var DeflateCRC32Stream = CRC32Stream.DeflateCRC32Stream;
-
-var ArchiveOutputStream = require('../archive-output-stream');
-var ZipArchiveEntry = require('./zip-archive-entry');
-var GeneralPurposeBit = require('./general-purpose-bit');
-
-var constants = require('./constants');
-var util = require('../../util');
-var zipUtil = require('./util');
-
-var ZipArchiveOutputStream = module.exports = function(options) {
- if (!(this instanceof ZipArchiveOutputStream)) {
- return new ZipArchiveOutputStream(options);
- }
-
- options = this.options = this._defaults(options);
-
- ArchiveOutputStream.call(this, options);
-
- this._entry = null;
- this._entries = [];
- this._archive = {
- centralLength: 0,
- centralOffset: 0,
- comment: '',
- finish: false,
- finished: false,
- processing: false
- };
-};
-
-inherits(ZipArchiveOutputStream, ArchiveOutputStream);
-
-ZipArchiveOutputStream.prototype._afterAppend = function(ae) {
- this._entries.push(ae);
-
- if (ae.getGeneralPurposeBit().usesDataDescriptor()) {
- this._writeDataDescriptor(ae);
- }
-
- this._archive.processing = false;
- this._entry = null;
-
- if (this._archive.finish && !this._archive.finished) {
- this._finish();
- }
-};
-
-ZipArchiveOutputStream.prototype._appendBuffer = function(ae, source, callback) {
- if (source.length === 0) {
- ae.setMethod(constants.METHOD_STORED);
- }
-
- var method = ae.getMethod();
-
- if (method === constants.METHOD_STORED) {
- ae.setSize(source.length);
- ae.setCompressedSize(source.length);
- ae.setCrc(crc32.unsigned(source));
- }
-
- this._writeLocalFileHeader(ae);
-
- if (method === constants.METHOD_STORED) {
- this.write(source);
- this._afterAppend(ae);
- callback(null, ae);
- return;
- } else if (method === constants.METHOD_DEFLATED) {
- this._smartStream(ae, callback).end(source);
- return;
- } else {
- callback(new Error('compression method ' + method + ' not implemented'));
- return;
- }
-};
-
-ZipArchiveOutputStream.prototype._appendStream = function(ae, source, callback) {
- ae.getGeneralPurposeBit().useDataDescriptor(true);
- ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR);
-
- this._writeLocalFileHeader(ae);
-
- var smart = this._smartStream(ae, callback);
- source.pipe(smart);
-};
-
-ZipArchiveOutputStream.prototype._defaults = function(o) {
- if (typeof o !== 'object') {
- o = {};
- }
-
- if (typeof o.zlib !== 'object') {
- o.zlib = {};
- }
-
- if (typeof o.zlib.level !== 'number') {
- o.zlib.level = constants.ZLIB_BEST_SPEED;
- }
-
- return o;
-};
-
-ZipArchiveOutputStream.prototype._finish = function() {
- this._archive.centralOffset = this.offset;
-
- this._entries.forEach(function(ae) {
- this._writeCentralFileHeader(ae);
- }.bind(this));
-
- this._archive.centralLength = this.offset - this._archive.centralOffset;
-
- if (this.isZip64()) {
- this._writeCentralDirectoryZip64();
- }
-
- this._writeCentralDirectoryEnd();
-
- this._archive.processing = false;
- this._archive.finish = true;
- this._archive.finished = true;
- this.end();
-};
-
-ZipArchiveOutputStream.prototype._normalizeEntry = function(ae) {
- if (ae.getMethod() === -1) {
- ae.setMethod(constants.METHOD_DEFLATED);
- }
-
- if (ae.getMethod() === constants.METHOD_DEFLATED) {
- ae.getGeneralPurposeBit().useDataDescriptor(true);
- ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR);
- }
-
- if (ae.getTime() === -1) {
- ae.setTime(new Date());
- }
-
- ae._offsets = {
- file: 0,
- data: 0,
- contents: 0,
- };
-};
-
-ZipArchiveOutputStream.prototype._smartStream = function(ae, callback) {
- var deflate = ae.getMethod() === constants.METHOD_DEFLATED;
- var process = deflate ? new DeflateCRC32Stream(this.options.zlib) : new CRC32Stream();
-
- function handleStuff(err) {
- ae.setCrc(process.digest());
- ae.setSize(process.size());
- ae.setCompressedSize(process.size(true));
- this._afterAppend(ae);
- callback(null, ae);
- }
-
- process.once('error', callback);
- process.once('end', handleStuff.bind(this));
-
- process.pipe(this, { end: false });
-
- return process;
-};
-
-ZipArchiveOutputStream.prototype._writeCentralDirectoryEnd = function() {
- var records = this._entries.length;
- var size = this._archive.centralLength;
- var offset = this._archive.centralOffset;
-
- if (this.isZip64()) {
- records = constants.ZIP64_MAGIC_SHORT;
- size = constants.ZIP64_MAGIC;
- offset = constants.ZIP64_MAGIC;
- }
-
- // signature
- this.write(zipUtil.getLongBytes(constants.SIG_EOCD));
-
- // disk numbers
- this.write(constants.SHORT_ZERO);
- this.write(constants.SHORT_ZERO);
-
- // number of entries
- this.write(zipUtil.getShortBytes(records));
- this.write(zipUtil.getShortBytes(records));
-
- // length and location of CD
- this.write(zipUtil.getLongBytes(size));
- this.write(zipUtil.getLongBytes(offset));
-
- // archive comment
- var comment = this.getComment();
- var commentLength = Buffer.byteLength(comment);
- this.write(zipUtil.getShortBytes(commentLength));
- this.write(comment);
-};
-
-ZipArchiveOutputStream.prototype._writeCentralDirectoryZip64 = function() {
- // signature
- this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD));
-
- // size of the ZIP64 EOCD record
- this.write(zipUtil.getEightBytes(56));
-
- // version made by
- this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64));
-
- // version to extract
- this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64));
-
- // disk numbers
- this.write(constants.LONG_ZERO);
- this.write(constants.LONG_ZERO);
-
- // number of entries
- this.write(zipUtil.getEightBytes(this._entries.length));
- this.write(zipUtil.getEightBytes(this._entries.length));
-
- // length and location of CD
- this.write(zipUtil.getEightBytes(this._archive.centralLength));
- this.write(zipUtil.getEightBytes(this._archive.centralOffset));
-
- // extensible data sector
- // not implemented at this time
-
- // end of central directory locator
- this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD_LOC));
-
- // disk number holding the ZIP64 EOCD record
- this.write(constants.LONG_ZERO);
-
- // relative offset of the ZIP64 EOCD record
- this.write(zipUtil.getEightBytes(this._archive.centralOffset + this._archive.centralLength));
-
- // total number of disks
- this.write(zipUtil.getLongBytes(1));
-};
-
-ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(ae) {
- var gpb = ae.getGeneralPurposeBit();
- var method = ae.getMethod();
- var offsets = ae._offsets;
-
- var size = ae.getSize();
- var compressedSize = ae.getCompressedSize();
-
- if (ae.isZip64() || offsets.file > constants.ZIP64_MAGIC) {
- size = constants.ZIP64_MAGIC;
- compressedSize = constants.ZIP64_MAGIC;
-
- ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64);
-
- var extraBuf = Buffer.concat([
- zipUtil.getShortBytes(constants.ZIP64_EXTRA_ID),
- zipUtil.getShortBytes(24),
- zipUtil.getEightBytes(ae.getSize()),
- zipUtil.getEightBytes(ae.getCompressedSize()),
- zipUtil.getEightBytes(offsets.file)
- ], 28);
-
- ae.setExtra(extraBuf);
- }
-
- // signature
- this.write(zipUtil.getLongBytes(constants.SIG_CFH));
-
- // version made by
- this.write(zipUtil.getShortBytes((ae.getPlatform() << 8) | constants.VERSION_MADEBY));
-
- // version to extract and general bit flag
- this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract()));
- this.write(gpb.encode());
-
- // compression method
- this.write(zipUtil.getShortBytes(method));
-
- // datetime
- this.write(zipUtil.getLongBytes(ae.getTimeDos()));
-
- // crc32 checksum
- this.write(zipUtil.getLongBytes(ae.getCrc()));
-
- // sizes
- this.write(zipUtil.getLongBytes(compressedSize));
- this.write(zipUtil.getLongBytes(size));
-
- var name = ae.getName();
- var comment = ae.getComment();
- var extra = ae.getCentralDirectoryExtra();
-
- if (gpb.usesUTF8ForNames()) {
- name = new Buffer(name);
- comment = new Buffer(comment);
- }
-
- // name length
- this.write(zipUtil.getShortBytes(name.length));
-
- // extra length
- this.write(zipUtil.getShortBytes(extra.length));
-
- // comments length
- this.write(zipUtil.getShortBytes(comment.length));
-
- // disk number start
- this.write(constants.SHORT_ZERO);
-
- // internal attributes
- this.write(zipUtil.getShortBytes(ae.getInternalAttributes()));
-
- // external attributes
- this.write(zipUtil.getLongBytes(ae.getExternalAttributes()));
-
- // relative offset of LFH
- if (offsets.file > constants.ZIP64_MAGIC) {
- this.write(zipUtil.getLongBytes(constants.ZIP64_MAGIC));
- } else {
- this.write(zipUtil.getLongBytes(offsets.file));
- }
-
- // name
- this.write(name);
-
- // extra
- this.write(extra);
-
- // comment
- this.write(comment);
-};
-
-ZipArchiveOutputStream.prototype._writeDataDescriptor = function(ae) {
- // signature
- this.write(zipUtil.getLongBytes(constants.SIG_DD));
-
- // crc32 checksum
- this.write(zipUtil.getLongBytes(ae.getCrc()));
-
- // sizes
- if (ae.isZip64()) {
- this.write(zipUtil.getEightBytes(ae.getCompressedSize()));
- this.write(zipUtil.getEightBytes(ae.getSize()));
- } else {
- this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
- this.write(zipUtil.getLongBytes(ae.getSize()));
- }
-};
-
-ZipArchiveOutputStream.prototype._writeLocalFileHeader = function(ae) {
- var gpb = ae.getGeneralPurposeBit();
- var method = ae.getMethod();
- var name = ae.getName();
- var extra = ae.getLocalFileDataExtra();
-
- if (ae.isZip64()) {
- gpb.useDataDescriptor(true);
- ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64);
- }
-
- if (gpb.usesUTF8ForNames()) {
- name = new Buffer(name);
- }
-
- ae._offsets.file = this.offset;
-
- // signature
- this.write(zipUtil.getLongBytes(constants.SIG_LFH));
-
- // version to extract and general bit flag
- this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract()));
- this.write(gpb.encode());
-
- // compression method
- this.write(zipUtil.getShortBytes(method));
-
- // datetime
- this.write(zipUtil.getLongBytes(ae.getTimeDos()));
-
- ae._offsets.data = this.offset;
-
- // crc32 checksum and sizes
- if (gpb.usesDataDescriptor()) {
- this.write(constants.LONG_ZERO);
- this.write(constants.LONG_ZERO);
- this.write(constants.LONG_ZERO);
- } else {
- this.write(zipUtil.getLongBytes(ae.getCrc()));
- this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
- this.write(zipUtil.getLongBytes(ae.getSize()));
- }
-
- // name length
- this.write(zipUtil.getShortBytes(name.length));
-
- // extra length
- this.write(zipUtil.getShortBytes(extra.length));
-
- // name
- this.write(name);
-
- // extra
- this.write(extra);
-
- ae._offsets.contents = this.offset;
-};
-
-ZipArchiveOutputStream.prototype.getComment = function(comment) {
- return this._archive.comment !== null ? this._archive.comment : '';
-};
-
-ZipArchiveOutputStream.prototype.isZip64 = function() {
- return this._entries.length > constants.ZIP64_MAGIC_SHORT || this._archive.centralLength > constants.ZIP64_MAGIC || this._archive.centralOffset > constants.ZIP64_MAGIC;
-};
-
-ZipArchiveOutputStream.prototype.setComment = function(comment) {
- this._archive.comment = comment;
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+var crc32 = require('buffer-crc32');
+var CRC32Stream = require('crc32-stream');
+var DeflateCRC32Stream = CRC32Stream.DeflateCRC32Stream;
+
+var ArchiveOutputStream = require('../archive-output-stream');
+var ZipArchiveEntry = require('./zip-archive-entry');
+var GeneralPurposeBit = require('./general-purpose-bit');
+
+var constants = require('./constants');
+var util = require('../../util');
+var zipUtil = require('./util');
+
+var ZipArchiveOutputStream = module.exports = function(options) {
+ if (!(this instanceof ZipArchiveOutputStream)) {
+ return new ZipArchiveOutputStream(options);
+ }
+
+ options = this.options = this._defaults(options);
+
+ ArchiveOutputStream.call(this, options);
+
+ this._entry = null;
+ this._entries = [];
+ this._archive = {
+ centralLength: 0,
+ centralOffset: 0,
+ comment: '',
+ finish: false,
+ finished: false,
+ processing: false
+ };
+};
+
+inherits(ZipArchiveOutputStream, ArchiveOutputStream);
+
+ZipArchiveOutputStream.prototype._afterAppend = function(ae) {
+ this._entries.push(ae);
+
+ if (ae.getGeneralPurposeBit().usesDataDescriptor()) {
+ this._writeDataDescriptor(ae);
+ }
+
+ this._archive.processing = false;
+ this._entry = null;
+
+ if (this._archive.finish && !this._archive.finished) {
+ this._finish();
+ }
+};
+
+ZipArchiveOutputStream.prototype._appendBuffer = function(ae, source, callback) {
+ if (source.length === 0) {
+ ae.setMethod(constants.METHOD_STORED);
+ }
+
+ var method = ae.getMethod();
+
+ if (method === constants.METHOD_STORED) {
+ ae.setSize(source.length);
+ ae.setCompressedSize(source.length);
+ ae.setCrc(crc32.unsigned(source));
+ }
+
+ this._writeLocalFileHeader(ae);
+
+ if (method === constants.METHOD_STORED) {
+ this.write(source);
+ this._afterAppend(ae);
+ callback(null, ae);
+ return;
+ } else if (method === constants.METHOD_DEFLATED) {
+ this._smartStream(ae, callback).end(source);
+ return;
+ } else {
+ callback(new Error('compression method ' + method + ' not implemented'));
+ return;
+ }
+};
+
+ZipArchiveOutputStream.prototype._appendStream = function(ae, source, callback) {
+ ae.getGeneralPurposeBit().useDataDescriptor(true);
+ ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR);
+
+ this._writeLocalFileHeader(ae);
+
+ var smart = this._smartStream(ae, callback);
+ source.pipe(smart);
+};
+
+ZipArchiveOutputStream.prototype._defaults = function(o) {
+ if (typeof o !== 'object') {
+ o = {};
+ }
+
+ if (typeof o.zlib !== 'object') {
+ o.zlib = {};
+ }
+
+ if (typeof o.zlib.level !== 'number') {
+ o.zlib.level = constants.ZLIB_BEST_SPEED;
+ }
+
+ return o;
+};
+
+ZipArchiveOutputStream.prototype._finish = function() {
+ this._archive.centralOffset = this.offset;
+
+ this._entries.forEach(function(ae) {
+ this._writeCentralFileHeader(ae);
+ }.bind(this));
+
+ this._archive.centralLength = this.offset - this._archive.centralOffset;
+
+ if (this.isZip64()) {
+ this._writeCentralDirectoryZip64();
+ }
+
+ this._writeCentralDirectoryEnd();
+
+ this._archive.processing = false;
+ this._archive.finish = true;
+ this._archive.finished = true;
+ this.end();
+};
+
+ZipArchiveOutputStream.prototype._normalizeEntry = function(ae) {
+ if (ae.getMethod() === -1) {
+ ae.setMethod(constants.METHOD_DEFLATED);
+ }
+
+ if (ae.getMethod() === constants.METHOD_DEFLATED) {
+ ae.getGeneralPurposeBit().useDataDescriptor(true);
+ ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR);
+ }
+
+ if (ae.getTime() === -1) {
+ ae.setTime(new Date());
+ }
+
+ ae._offsets = {
+ file: 0,
+ data: 0,
+ contents: 0,
+ };
+};
+
+ZipArchiveOutputStream.prototype._smartStream = function(ae, callback) {
+ var deflate = ae.getMethod() === constants.METHOD_DEFLATED;
+ var process = deflate ? new DeflateCRC32Stream(this.options.zlib) : new CRC32Stream();
+
+ function handleStuff(err) {
+ ae.setCrc(process.digest());
+ ae.setSize(process.size());
+ ae.setCompressedSize(process.size(true));
+ this._afterAppend(ae);
+ callback(null, ae);
+ }
+
+ process.once('error', callback);
+ process.once('end', handleStuff.bind(this));
+
+ process.pipe(this, { end: false });
+
+ return process;
+};
+
+ZipArchiveOutputStream.prototype._writeCentralDirectoryEnd = function() {
+ var records = this._entries.length;
+ var size = this._archive.centralLength;
+ var offset = this._archive.centralOffset;
+
+ if (this.isZip64()) {
+ records = constants.ZIP64_MAGIC_SHORT;
+ size = constants.ZIP64_MAGIC;
+ offset = constants.ZIP64_MAGIC;
+ }
+
+ // signature
+ this.write(zipUtil.getLongBytes(constants.SIG_EOCD));
+
+ // disk numbers
+ this.write(constants.SHORT_ZERO);
+ this.write(constants.SHORT_ZERO);
+
+ // number of entries
+ this.write(zipUtil.getShortBytes(records));
+ this.write(zipUtil.getShortBytes(records));
+
+ // length and location of CD
+ this.write(zipUtil.getLongBytes(size));
+ this.write(zipUtil.getLongBytes(offset));
+
+ // archive comment
+ var comment = this.getComment();
+ var commentLength = Buffer.byteLength(comment);
+ this.write(zipUtil.getShortBytes(commentLength));
+ this.write(comment);
+};
+
+ZipArchiveOutputStream.prototype._writeCentralDirectoryZip64 = function() {
+ // signature
+ this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD));
+
+ // size of the ZIP64 EOCD record
+ this.write(zipUtil.getEightBytes(56));
+
+ // version made by
+ this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64));
+
+ // version to extract
+ this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64));
+
+ // disk numbers
+ this.write(constants.LONG_ZERO);
+ this.write(constants.LONG_ZERO);
+
+ // number of entries
+ this.write(zipUtil.getEightBytes(this._entries.length));
+ this.write(zipUtil.getEightBytes(this._entries.length));
+
+ // length and location of CD
+ this.write(zipUtil.getEightBytes(this._archive.centralLength));
+ this.write(zipUtil.getEightBytes(this._archive.centralOffset));
+
+ // extensible data sector
+ // not implemented at this time
+
+ // end of central directory locator
+ this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD_LOC));
+
+ // disk number holding the ZIP64 EOCD record
+ this.write(constants.LONG_ZERO);
+
+ // relative offset of the ZIP64 EOCD record
+ this.write(zipUtil.getEightBytes(this._archive.centralOffset + this._archive.centralLength));
+
+ // total number of disks
+ this.write(zipUtil.getLongBytes(1));
+};
+
+ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(ae) {
+ var gpb = ae.getGeneralPurposeBit();
+ var method = ae.getMethod();
+ var offsets = ae._offsets;
+
+ var size = ae.getSize();
+ var compressedSize = ae.getCompressedSize();
+
+ if (ae.isZip64() || offsets.file > constants.ZIP64_MAGIC) {
+ size = constants.ZIP64_MAGIC;
+ compressedSize = constants.ZIP64_MAGIC;
+
+ ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64);
+
+ var extraBuf = Buffer.concat([
+ zipUtil.getShortBytes(constants.ZIP64_EXTRA_ID),
+ zipUtil.getShortBytes(24),
+ zipUtil.getEightBytes(ae.getSize()),
+ zipUtil.getEightBytes(ae.getCompressedSize()),
+ zipUtil.getEightBytes(offsets.file)
+ ], 28);
+
+ ae.setExtra(extraBuf);
+ }
+
+ // signature
+ this.write(zipUtil.getLongBytes(constants.SIG_CFH));
+
+ // version made by
+ this.write(zipUtil.getShortBytes((ae.getPlatform() << 8) | constants.VERSION_MADEBY));
+
+ // version to extract and general bit flag
+ this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract()));
+ this.write(gpb.encode());
+
+ // compression method
+ this.write(zipUtil.getShortBytes(method));
+
+ // datetime
+ this.write(zipUtil.getLongBytes(ae.getTimeDos()));
+
+ // crc32 checksum
+ this.write(zipUtil.getLongBytes(ae.getCrc()));
+
+ // sizes
+ this.write(zipUtil.getLongBytes(compressedSize));
+ this.write(zipUtil.getLongBytes(size));
+
+ var name = ae.getName();
+ var comment = ae.getComment();
+ var extra = ae.getCentralDirectoryExtra();
+
+ if (gpb.usesUTF8ForNames()) {
+ name = new Buffer(name);
+ comment = new Buffer(comment);
+ }
+
+ // name length
+ this.write(zipUtil.getShortBytes(name.length));
+
+ // extra length
+ this.write(zipUtil.getShortBytes(extra.length));
+
+ // comments length
+ this.write(zipUtil.getShortBytes(comment.length));
+
+ // disk number start
+ this.write(constants.SHORT_ZERO);
+
+ // internal attributes
+ this.write(zipUtil.getShortBytes(ae.getInternalAttributes()));
+
+ // external attributes
+ this.write(zipUtil.getLongBytes(ae.getExternalAttributes()));
+
+ // relative offset of LFH
+ if (offsets.file > constants.ZIP64_MAGIC) {
+ this.write(zipUtil.getLongBytes(constants.ZIP64_MAGIC));
+ } else {
+ this.write(zipUtil.getLongBytes(offsets.file));
+ }
+
+ // name
+ this.write(name);
+
+ // extra
+ this.write(extra);
+
+ // comment
+ this.write(comment);
+};
+
+ZipArchiveOutputStream.prototype._writeDataDescriptor = function(ae) {
+ // signature
+ this.write(zipUtil.getLongBytes(constants.SIG_DD));
+
+ // crc32 checksum
+ this.write(zipUtil.getLongBytes(ae.getCrc()));
+
+ // sizes
+ if (ae.isZip64()) {
+ this.write(zipUtil.getEightBytes(ae.getCompressedSize()));
+ this.write(zipUtil.getEightBytes(ae.getSize()));
+ } else {
+ this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
+ this.write(zipUtil.getLongBytes(ae.getSize()));
+ }
+};
+
+ZipArchiveOutputStream.prototype._writeLocalFileHeader = function(ae) {
+ var gpb = ae.getGeneralPurposeBit();
+ var method = ae.getMethod();
+ var name = ae.getName();
+ var extra = ae.getLocalFileDataExtra();
+
+ if (ae.isZip64()) {
+ gpb.useDataDescriptor(true);
+ ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64);
+ }
+
+ if (gpb.usesUTF8ForNames()) {
+ name = new Buffer(name);
+ }
+
+ ae._offsets.file = this.offset;
+
+ // signature
+ this.write(zipUtil.getLongBytes(constants.SIG_LFH));
+
+ // version to extract and general bit flag
+ this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract()));
+ this.write(gpb.encode());
+
+ // compression method
+ this.write(zipUtil.getShortBytes(method));
+
+ // datetime
+ this.write(zipUtil.getLongBytes(ae.getTimeDos()));
+
+ ae._offsets.data = this.offset;
+
+ // crc32 checksum and sizes
+ if (gpb.usesDataDescriptor()) {
+ this.write(constants.LONG_ZERO);
+ this.write(constants.LONG_ZERO);
+ this.write(constants.LONG_ZERO);
+ } else {
+ this.write(zipUtil.getLongBytes(ae.getCrc()));
+ this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
+ this.write(zipUtil.getLongBytes(ae.getSize()));
+ }
+
+ // name length
+ this.write(zipUtil.getShortBytes(name.length));
+
+ // extra length
+ this.write(zipUtil.getShortBytes(extra.length));
+
+ // name
+ this.write(name);
+
+ // extra
+ this.write(extra);
+
+ ae._offsets.contents = this.offset;
+};
+
+ZipArchiveOutputStream.prototype.getComment = function(comment) {
+ return this._archive.comment !== null ? this._archive.comment : '';
+};
+
+ZipArchiveOutputStream.prototype.isZip64 = function() {
+ return this._entries.length > constants.ZIP64_MAGIC_SHORT || this._archive.centralLength > constants.ZIP64_MAGIC || this._archive.centralOffset > constants.ZIP64_MAGIC;
+};
+
+ZipArchiveOutputStream.prototype.setComment = function(comment) {
+ this._archive.comment = comment;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/compress-commons.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/compress-commons.js b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/compress-commons.js
index fe3a581..0113bbb 100644
--- a/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/compress-commons.js
+++ b/node_modules/archiver/node_modules/zip-stream/node_modules/compress-commons/lib/compress-commons.js
@@ -1,13 +1,13 @@
-/**
- * node-compress-commons
- *
- * Copyright (c) 2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
- */
-module.exports = {
- ArchiveEntry: require('./archivers/archive-entry'),
- ZipArchiveEntry: require('./archivers/zip/zip-archive-entry'),
- ArchiveOutputStream: require('./archivers/archive-output-stream'),
- ZipArchiveOutputStream: require('./archivers/zip/zip-archive-output-stream')
+/**
+ * node-compress-commons
+ *
+ * Copyright (c) 2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/ctalkington/node-compress-commons/blob/master/LICENSE-MIT
+ */
+module.exports = {
+ ArchiveEntry: require('./archivers/archive-entry'),
+ ZipArchiveEntry: require('./archivers/zip/zip-archive-entry'),
+ ArchiveOutputStream: require('./archivers/archive-output-stream'),
+ ZipArchiveOutputStream: require('./archivers/zip/zip-archive-output-stream')
};
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[13/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
CB-9836 Add .gitattributes to prevent CRLF line endings in repos
Changes deps eols to LF
github: close #25
Project: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/commit/325bb661
Tree: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/tree/325bb661
Diff: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/diff/325bb661
Branch: refs/heads/master
Commit: 325bb661eebba83e0c8d19e86a155ffd5a043a0a
Parents: 3a1effe
Author: daserge <v-...@microsoft.com>
Authored: Thu Nov 5 02:51:29 2015 -0800
Committer: daserge <v-...@microsoft.com>
Committed: Fri Nov 13 03:48:57 2015 -0800
----------------------------------------------------------------------
.gitattributes | 96 +
node_modules/archiver/LICENSE-MIT | 42 +-
node_modules/archiver/README.md | 428 +-
node_modules/archiver/lib/archiver.js | 100 +-
node_modules/archiver/lib/core.js | 974 +--
node_modules/archiver/lib/plugins/json.js | 138 +-
node_modules/archiver/lib/plugins/tar.js | 190 +-
node_modules/archiver/lib/plugins/zip.js | 92 +-
node_modules/archiver/lib/util/file.js | 410 +-
node_modules/archiver/lib/util/index.js | 296 +-
.../node_modules/zip-stream/LICENSE-MIT | 42 +-
.../archiver/node_modules/zip-stream/README.md | 208 +-
.../node_modules/zip-stream/lib/util/index.js | 204 +-
.../node_modules/zip-stream/lib/zip-stream.js | 218 +-
.../node_modules/compress-commons/LICENSE-MIT | 42 +-
.../node_modules/compress-commons/README.md | 48 +-
.../lib/archivers/archive-entry.js | 30 +-
.../lib/archivers/archive-output-stream.js | 234 +-
.../lib/archivers/zip/constants.js | 140 +-
.../lib/archivers/zip/general-purpose-bit.js | 200 +-
.../compress-commons/lib/archivers/zip/util.js | 166 +-
.../lib/archivers/zip/zip-archive-entry.js | 444 +-
.../archivers/zip/zip-archive-output-stream.js | 852 +-
.../compress-commons/lib/compress-commons.js | 24 +-
.../compress-commons/lib/util/index.js | 58 +-
.../node_modules/crc32-stream/CHANGELOG | 34 +-
.../node_modules/crc32-stream/LICENSE-MIT | 42 +-
.../node_modules/crc32-stream/README.md | 160 +-
.../crc32-stream/lib/crc32-stream.js | 82 +-
.../crc32-stream/lib/deflate-crc32-stream.js | 132 +-
.../node_modules/crc32-stream/lib/index.js | 18 +-
.../node_modules/JSONSelect/site/js/json2.js | 960 +--
.../node_modules/JSONSelect/site/js/showdown.js | 2602 +++---
.../JSONSelect/src/build/lib/jshint.js | 7708 +++++++++---------
.../node_modules/JSONSelect/site/js/json2.js | 960 +--
.../node_modules/JSONSelect/site/js/showdown.js | 2602 +++---
.../JSONSelect/src/build/lib/jshint.js | 7708 +++++++++---------
.../node_modules/archiver/LICENSE-MIT | 42 +-
.../zip-folder/node_modules/archiver/README.md | 330 +-
.../node_modules/archiver/lib/archiver.js | 82 +-
.../archiver/lib/modules/core/index.js | 636 +-
.../archiver/lib/modules/json/index.js | 140 +-
.../archiver/lib/modules/tar/index.js | 166 +-
.../archiver/lib/modules/zip/index.js | 76 +-
.../node_modules/archiver/lib/util/file.js | 410 +-
.../node_modules/archiver/lib/util/index.js | 204 +-
.../node_modules/zip-stream/LICENSE-MIT | 42 +-
.../archiver/node_modules/zip-stream/README.md | 208 +-
.../node_modules/zip-stream/lib/util/index.js | 204 +-
.../node_modules/zip-stream/lib/zip-stream.js | 218 +-
.../node_modules/compress-commons/LICENSE-MIT | 42 +-
.../node_modules/compress-commons/README.md | 50 +-
.../lib/archivers/archive-entry.js | 30 +-
.../lib/archivers/archive-output-stream.js | 224 +-
.../lib/archivers/zip/constants.js | 132 +-
.../lib/archivers/zip/general-purpose-bit.js | 200 +-
.../compress-commons/lib/archivers/zip/util.js | 140 +-
.../lib/archivers/zip/zip-archive-entry.js | 444 +-
.../archivers/zip/zip-archive-output-stream.js | 672 +-
.../compress-commons/lib/compress-commons.js | 24 +-
.../compress-commons/lib/util/index.js | 58 +-
.../node_modules/crc32-stream/CHANGELOG | 34 +-
.../node_modules/crc32-stream/LICENSE-MIT | 42 +-
.../node_modules/crc32-stream/README.md | 160 +-
.../crc32-stream/lib/crc32-stream.js | 82 +-
.../crc32-stream/lib/deflate-crc32-stream.js | 132 +-
.../node_modules/crc32-stream/lib/index.js | 18 +-
.../node_modules/JSONSelect/site/js/json2.js | 960 +--
.../node_modules/JSONSelect/site/js/showdown.js | 2602 +++---
.../JSONSelect/src/build/lib/jshint.js | 7708 +++++++++---------
70 files changed, 22646 insertions(+), 22550 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/.gitattributes
----------------------------------------------------------------------
diff --git a/.gitattributes b/.gitattributes
new file mode 100755
index 0000000..e6209c0
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,96 @@
+* text eol=lf
+
+# source code
+*.php text
+*.css text
+*.sass text
+*.scss text
+*.less text
+*.styl text
+*.js text
+*.coffee text
+*.json text
+*.htm text
+*.html text
+*.xml text
+*.svg text
+*.txt text
+*.ini text
+*.inc text
+*.pl text
+*.rb text
+*.py text
+*.scm text
+*.sql text
+*.sh text
+*.bat text
+
+# templates
+*.ejs text
+*.hbt text
+*.jade text
+*.haml text
+*.hbs text
+*.dot text
+*.tmpl text
+*.phtml text
+
+# server config
+.htaccess text
+
+# git config
+.gitattributes text
+.gitignore text
+.gitconfig text
+
+# code analysis config
+.jshintrc text
+.jscsrc text
+.jshintignore text
+.csslintrc text
+
+# misc config
+*.yaml text
+*.yml text
+.editorconfig text
+
+# build config
+*.npmignore text
+*.bowerrc text
+
+# Heroku
+Procfile text
+.slugignore text
+
+# Documentation
+*.md text
+LICENSE text
+AUTHORS text
+
+
+#
+## These files are binary and should be left untouched
+#
+
+# (binary is a macro for -text -diff)
+*.png binary
+*.jpg binary
+*.jpeg binary
+*.gif binary
+*.ico binary
+*.mov binary
+*.mp4 binary
+*.mp3 binary
+*.flv binary
+*.fla binary
+*.swf binary
+*.gz binary
+*.zip binary
+*.7z binary
+*.ttf binary
+*.eot binary
+*.woff binary
+*.pyc binary
+*.pdf binary
+*.tt binary
+*.tgz binary
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/LICENSE-MIT
----------------------------------------------------------------------
diff --git a/node_modules/archiver/LICENSE-MIT b/node_modules/archiver/LICENSE-MIT
index bc56a8a..88caf87 100644
--- a/node_modules/archiver/LICENSE-MIT
+++ b/node_modules/archiver/LICENSE-MIT
@@ -1,22 +1,22 @@
-Copyright (c) 2012-2014 Chris Talkington, contributors.
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+Copyright (c) 2012-2014 Chris Talkington, contributors.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/README.md
----------------------------------------------------------------------
diff --git a/node_modules/archiver/README.md b/node_modules/archiver/README.md
index 94e6a1f..5d969b9 100644
--- a/node_modules/archiver/README.md
+++ b/node_modules/archiver/README.md
@@ -1,215 +1,215 @@
-# Archiver v0.14.3 [](https://travis-ci.org/archiverjs/node-archiver)
-
-a streaming interface for archive generation
-
-[](https://nodei.co/npm/archiver/)
-
-## Install
-
-```bash
-npm install archiver --save
-```
-
-You can also use `npm install https://github.com/archiverjs/node-archiver/archive/master.tar.gz` to test upcoming versions.
-
-## Archiver
-
-#### create(format, options)
-
-Creates an Archiver instance based on the format (zip, tar, etc) passed. Parameters can be passed directly to `Archiver` constructor for convenience.
-
-#### registerFormat(format, module)
-
-Registers an archive format. Format modules are essentially transform streams with a few required methods. They will be further documented once a formal spec is in place.
-
-### Instance Methods
-
-Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) methods.
-
-#### abort()
-
-Aborts the archiving process, taking a best-effort approach, by:
-
-* removing any pending queue tasks
-* allowing any active queue workers to finish
-* detaching internal module pipes
-* ending both sides of the Transform stream
-
-*It will NOT drain any remaining sources.*
-
-#### append(input, data)
-
-Appends an input source (text string, buffer, or stream) to the instance. When the instance has received, processed, and emitted the input, the `entry` event is fired.
-
-Replaced `#addFile` in v0.5.
-
-```js
-archive.append('string', { name:'string.txt' });
-archive.append(new Buffer('string'), { name:'buffer.txt' });
-archive.append(fs.createReadStream('mydir/file.txt'), { name:'stream.txt' });
-archive.append(null, { name:'dir/' });
-```
-
-#### bulk(mappings)
-
-Appends multiple entries from passed array of src-dest mappings. A [lazystream](https://github.com/jpommerening/node-lazystream) wrapper is used to prevent issues with open file limits.
-
-Globbing patterns are supported through use of the bundled [file-utils](https://github.com/SBoudrias/file-utils) module.
-
-The `data` property can be set (per src-dest mapping) to define data for matched entries.
-
-```js
-archive.bulk([
- { src: ['mydir/**'], data: { date: new Date() } },
- { expand: true, cwd: 'mydir', src: ['**'], dest: 'newdir' }
-]);
-```
-
-For more detail on this feature, please see [BULK.md](https://github.com/archiverjs/node-archiver/blob/master/BULK.md).
-
-#### directory(dirpath[, destpath, data])
-
-Appends a directory and its files, recusively, given its dirpath. This is meant to be a simplier approach to something previously only possible with `bulk`. The use of `destpath` allows one to define a custom destination path within the resulting archive and `data` allows for setting data on each entry appended.
-
-```js
-// mydir/ -> archive.ext/mydir/
-archive.directory('mydir');
-
-// mydir/ -> archive.ext/abc/
-archive.directory('mydir', 'abc');
-
-// mydir/ -> archive.ext/
-archive.directory('mydir', false, { date: new Date() });
-```
-
-#### file(filepath, data)
-
-Appends a file given its filepath using a [lazystream](https://github.com/jpommerening/node-lazystream) wrapper to prevent issues with open file limits. When the instance has received, processed, and emitted the file, the `entry` event is fired.
-
-```js
-archive.file('mydir/file.txt', { name:'file.txt' });
-```
-
-#### finalize()
-
-Finalizes the instance and prevents further appending to the archive structure (queue will continue til drained). The `end`, `close` or `finish` events on the destination stream may fire right after calling this method so you should set listeners beforehand to properly detect stream completion.
-
-*You must call this method to get a valid archive and end the instance stream.*
-
-#### pointer()
-
-Returns the current byte length emitted by archiver. Use this in your end callback to log generated size.
-
-## Events
-
-Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) events.
-
-#### entry
-
-Fired when the entry's input has been processed and appended to the archive. Passes entry data as first argument.
-
-## Zip
-
-### Options
-
-#### comment `string`
-
-Sets the zip comment.
-
-#### statConcurrency `number`
-
-Sets the number of workers used to process the internal fs stat queue. Defaults to 4.
-
-#### store `boolean`
-
-If true, all entries will be archived without compression. Defaults to `false`.
-
-#### zlib `object`
-
-Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
-
-### Entry Data
-
-#### name `string` `required`
-
-Sets the entry name including internal path.
-
-#### date `string|Date`
-
-Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
-
-When using the `bulk` or `file` methods, fs stat data is used as the default value.
-
-#### store `boolean`
-
-If true, this entry will be archived without compression. Defaults to global `store` option.
-
-#### comment `string`
-
-Sets the entry comment.
-
-#### mode `number`
-
-Sets the entry permissions. Defaults to octal 0755 (directory) or 0644 (file).
-
-When using the `bulk` or `file` methods, fs stat data is used as the default value.
-
-#### stats `fs.Stats`
-
-Sets the fs stat data for this entry. This allows for reduction of fs stat calls when stat data is already known.
-
-## Tar
-
-### Options
-
-#### gzip `boolean`
-
-Compresses the tar archive using gzip, default is false.
-
-#### gzipOptions `object`
-
-Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
-
-#### statConcurrency `number`
-
-Sets the number of workers used to process the internal fs stat queue. Defaults to 4.
-
-### Entry Data
-
-#### name `string` `required`
-
-Sets the entry name including internal path.
-
-#### date `string|Date`
-
-Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
-
-When using the `bulk` or `file` methods, fs stat data is used as the default value.
-
-#### mode `number`
-
-Sets the entry permissions. Defaults to octal 0755 (directory) or 0644 (file).
-
-When using the `bulk` or `file` methods, fs stat data is used as the default value.
-
-#### stats `fs.Stats`
-
-Sets the fs stat data for this entry. This allows for reduction of fs stat calls when stat data is already known.
-
-## Custom Formats
-
-Archiver ships with out of the box support for TAR and ZIP archives. You can register additional formats with `registerFormat`.
-
-## Libraries
-
-Archiver makes use of several libraries/modules to avoid duplication of efforts.
-
-- [zip-stream](https://npmjs.org/package/zip-stream)
-- [tar-stream](https://npmjs.org/package/tar-stream)
-
-## Things of Interest
-
-- [Examples](https://github.com/archiverjs/node-archiver/blob/master/examples)
-- [Changelog](https://github.com/archiverjs/node-archiver/releases)
-- [Contributing](https://github.com/archiverjs/node-archiver/blob/master/CONTRIBUTING.md)
+# Archiver v0.14.3 [](https://travis-ci.org/archiverjs/node-archiver)
+
+a streaming interface for archive generation
+
+[](https://nodei.co/npm/archiver/)
+
+## Install
+
+```bash
+npm install archiver --save
+```
+
+You can also use `npm install https://github.com/archiverjs/node-archiver/archive/master.tar.gz` to test upcoming versions.
+
+## Archiver
+
+#### create(format, options)
+
+Creates an Archiver instance based on the format (zip, tar, etc) passed. Parameters can be passed directly to `Archiver` constructor for convenience.
+
+#### registerFormat(format, module)
+
+Registers an archive format. Format modules are essentially transform streams with a few required methods. They will be further documented once a formal spec is in place.
+
+### Instance Methods
+
+Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) methods.
+
+#### abort()
+
+Aborts the archiving process, taking a best-effort approach, by:
+
+* removing any pending queue tasks
+* allowing any active queue workers to finish
+* detaching internal module pipes
+* ending both sides of the Transform stream
+
+*It will NOT drain any remaining sources.*
+
+#### append(input, data)
+
+Appends an input source (text string, buffer, or stream) to the instance. When the instance has received, processed, and emitted the input, the `entry` event is fired.
+
+Replaced `#addFile` in v0.5.
+
+```js
+archive.append('string', { name:'string.txt' });
+archive.append(new Buffer('string'), { name:'buffer.txt' });
+archive.append(fs.createReadStream('mydir/file.txt'), { name:'stream.txt' });
+archive.append(null, { name:'dir/' });
+```
+
+#### bulk(mappings)
+
+Appends multiple entries from passed array of src-dest mappings. A [lazystream](https://github.com/jpommerening/node-lazystream) wrapper is used to prevent issues with open file limits.
+
+Globbing patterns are supported through use of the bundled [file-utils](https://github.com/SBoudrias/file-utils) module.
+
+The `data` property can be set (per src-dest mapping) to define data for matched entries.
+
+```js
+archive.bulk([
+ { src: ['mydir/**'], data: { date: new Date() } },
+ { expand: true, cwd: 'mydir', src: ['**'], dest: 'newdir' }
+]);
+```
+
+For more detail on this feature, please see [BULK.md](https://github.com/archiverjs/node-archiver/blob/master/BULK.md).
+
+#### directory(dirpath[, destpath, data])
+
+Appends a directory and its files, recusively, given its dirpath. This is meant to be a simplier approach to something previously only possible with `bulk`. The use of `destpath` allows one to define a custom destination path within the resulting archive and `data` allows for setting data on each entry appended.
+
+```js
+// mydir/ -> archive.ext/mydir/
+archive.directory('mydir');
+
+// mydir/ -> archive.ext/abc/
+archive.directory('mydir', 'abc');
+
+// mydir/ -> archive.ext/
+archive.directory('mydir', false, { date: new Date() });
+```
+
+#### file(filepath, data)
+
+Appends a file given its filepath using a [lazystream](https://github.com/jpommerening/node-lazystream) wrapper to prevent issues with open file limits. When the instance has received, processed, and emitted the file, the `entry` event is fired.
+
+```js
+archive.file('mydir/file.txt', { name:'file.txt' });
+```
+
+#### finalize()
+
+Finalizes the instance and prevents further appending to the archive structure (queue will continue til drained). The `end`, `close` or `finish` events on the destination stream may fire right after calling this method so you should set listeners beforehand to properly detect stream completion.
+
+*You must call this method to get a valid archive and end the instance stream.*
+
+#### pointer()
+
+Returns the current byte length emitted by archiver. Use this in your end callback to log generated size.
+
+## Events
+
+Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) events.
+
+#### entry
+
+Fired when the entry's input has been processed and appended to the archive. Passes entry data as first argument.
+
+## Zip
+
+### Options
+
+#### comment `string`
+
+Sets the zip comment.
+
+#### statConcurrency `number`
+
+Sets the number of workers used to process the internal fs stat queue. Defaults to 4.
+
+#### store `boolean`
+
+If true, all entries will be archived without compression. Defaults to `false`.
+
+#### zlib `object`
+
+Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
+
+### Entry Data
+
+#### name `string` `required`
+
+Sets the entry name including internal path.
+
+#### date `string|Date`
+
+Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
+
+When using the `bulk` or `file` methods, fs stat data is used as the default value.
+
+#### store `boolean`
+
+If true, this entry will be archived without compression. Defaults to global `store` option.
+
+#### comment `string`
+
+Sets the entry comment.
+
+#### mode `number`
+
+Sets the entry permissions. Defaults to octal 0755 (directory) or 0644 (file).
+
+When using the `bulk` or `file` methods, fs stat data is used as the default value.
+
+#### stats `fs.Stats`
+
+Sets the fs stat data for this entry. This allows for reduction of fs stat calls when stat data is already known.
+
+## Tar
+
+### Options
+
+#### gzip `boolean`
+
+Compresses the tar archive using gzip, default is false.
+
+#### gzipOptions `object`
+
+Passed to node's [zlib](http://nodejs.org/api/zlib.html#zlib_options) module to control compression. Options may vary by node version.
+
+#### statConcurrency `number`
+
+Sets the number of workers used to process the internal fs stat queue. Defaults to 4.
+
+### Entry Data
+
+#### name `string` `required`
+
+Sets the entry name including internal path.
+
+#### date `string|Date`
+
+Sets the entry date. This can be any valid date string or instance. Defaults to current time in locale.
+
+When using the `bulk` or `file` methods, fs stat data is used as the default value.
+
+#### mode `number`
+
+Sets the entry permissions. Defaults to octal 0755 (directory) or 0644 (file).
+
+When using the `bulk` or `file` methods, fs stat data is used as the default value.
+
+#### stats `fs.Stats`
+
+Sets the fs stat data for this entry. This allows for reduction of fs stat calls when stat data is already known.
+
+## Custom Formats
+
+Archiver ships with out of the box support for TAR and ZIP archives. You can register additional formats with `registerFormat`.
+
+## Libraries
+
+Archiver makes use of several libraries/modules to avoid duplication of efforts.
+
+- [zip-stream](https://npmjs.org/package/zip-stream)
+- [tar-stream](https://npmjs.org/package/tar-stream)
+
+## Things of Interest
+
+- [Examples](https://github.com/archiverjs/node-archiver/blob/master/examples)
+- [Changelog](https://github.com/archiverjs/node-archiver/releases)
+- [Contributing](https://github.com/archiverjs/node-archiver/blob/master/CONTRIBUTING.md)
- [MIT License](https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/lib/archiver.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/lib/archiver.js b/node_modules/archiver/lib/archiver.js
index 73a80e8..d07f636 100644
--- a/node_modules/archiver/lib/archiver.js
+++ b/node_modules/archiver/lib/archiver.js
@@ -1,51 +1,51 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
- */
-var ArchiverCore = require('./core');
-var formats = {};
-
-var archiver = module.exports = function(format, options) {
- return archiver.create(format, options);
-};
-
-archiver.create = function(format, options) {
- if (formats[format]) {
- var instance = new ArchiverCore(options);
- instance.setFormat(format);
- instance.setModule(new formats[format](options));
-
- return instance;
- } else {
- throw new Error('create(' + format + '): format not registered');
- }
-};
-
-archiver.registerFormat = function(format, module) {
- if (formats[format]) {
- throw new Error('register(' + format + '): format already registered');
- }
-
- if (typeof module !== 'function') {
- throw new Error('register(' + format + '): format module invalid');
- }
-
- if (typeof module.prototype.append !== 'function' || typeof module.prototype.finalize !== 'function') {
- throw new Error('register(' + format + '): format module missing methods');
- }
-
- formats[format] = module;
-
- // backwards compat - to be removed in 0.14
- var compatName = 'create' + format.charAt(0).toUpperCase() + format.slice(1);
- archiver[compatName] = function(options) {
- return archiver.create(format, options);
- };
-};
-
-archiver.registerFormat('zip', require('./plugins/zip'));
-archiver.registerFormat('tar', require('./plugins/tar'));
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
+ */
+var ArchiverCore = require('./core');
+var formats = {};
+
+var archiver = module.exports = function(format, options) {
+ return archiver.create(format, options);
+};
+
+archiver.create = function(format, options) {
+ if (formats[format]) {
+ var instance = new ArchiverCore(options);
+ instance.setFormat(format);
+ instance.setModule(new formats[format](options));
+
+ return instance;
+ } else {
+ throw new Error('create(' + format + '): format not registered');
+ }
+};
+
+archiver.registerFormat = function(format, module) {
+ if (formats[format]) {
+ throw new Error('register(' + format + '): format already registered');
+ }
+
+ if (typeof module !== 'function') {
+ throw new Error('register(' + format + '): format module invalid');
+ }
+
+ if (typeof module.prototype.append !== 'function' || typeof module.prototype.finalize !== 'function') {
+ throw new Error('register(' + format + '): format module missing methods');
+ }
+
+ formats[format] = module;
+
+ // backwards compat - to be removed in 0.14
+ var compatName = 'create' + format.charAt(0).toUpperCase() + format.slice(1);
+ archiver[compatName] = function(options) {
+ return archiver.create(format, options);
+ };
+};
+
+archiver.registerFormat('zip', require('./plugins/zip'));
+archiver.registerFormat('tar', require('./plugins/tar'));
archiver.registerFormat('json', require('./plugins/json'));
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/lib/core.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/lib/core.js b/node_modules/archiver/lib/core.js
index d5103f3..eba4534 100644
--- a/node_modules/archiver/lib/core.js
+++ b/node_modules/archiver/lib/core.js
@@ -1,488 +1,488 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
- */
-var fs = require('fs');
-var inherits = require('util').inherits;
-var Transform = require('readable-stream').Transform;
-
-var async = require('async');
-
-var util = require('./util');
-
-var Archiver = module.exports = function(options) {
- if (!(this instanceof Archiver)) {
- return new Archiver(options);
- }
-
- options = this.options = util.defaults(options, {
- highWaterMark: 1024 * 1024,
- statConcurrency: 4
- });
-
- Transform.call(this, options);
-
- this._entries = [];
- this._format = false;
- this._module = false;
- this._pending = 0;
- this._pointer = 0;
-
- this._queue = async.queue(this._onQueueTask.bind(this), 1);
- this._queue.drain = this._onQueueDrain.bind(this);
-
- this._statQueue = async.queue(this._onStatQueueTask.bind(this), options.statConcurrency);
-
- this._state = {
- aborted: false,
- finalize: false,
- finalizing: false,
- finalized: false,
- modulePiped: false
- };
-};
-
-inherits(Archiver, Transform);
-
-Archiver.prototype._abort = function() {
- this._state.aborted = true;
- this._queue.kill();
- this._statQueue.kill();
-
- if (this._queue.idle()) {
- this._shutdown();
- }
-};
-
-Archiver.prototype._append = function(filepath, data) {
- data = data || {};
-
- var task = {
- source: null,
- filepath: filepath
- };
-
- if (!data.name) {
- data.name = filepath;
- }
-
- data.sourcePath = filepath;
- task.data = data;
-
- if (data.stats && data.stats instanceof fs.Stats) {
- task = this._updateQueueTaskWithStats(task, data.stats);
- this._queue.push(task);
- } else {
- this._statQueue.push(task);
- }
-};
-
-Archiver.prototype._finalize = function() {
- if (this._state.finalizing || this._state.finalized || this._state.aborted) {
- return;
- }
-
- this._state.finalizing = true;
-
- this._moduleFinalize();
-
- this._state.finalizing = false;
- this._state.finalized = true;
-};
-
-Archiver.prototype._maybeFinalize = function() {
- if (this._state.finalizing || this._state.finalized || this._state.aborted) {
- return false;
- }
-
- if (this._state.finalize && this._pending === 0 && this._queue.idle() && this._statQueue.idle()) {
- this._finalize();
- return true;
- }
-
- return false;
-};
-
-Archiver.prototype._moduleAppend = function(source, data, callback) {
- if (this._state.aborted) {
- callback();
- return;
- }
-
- this._module.append(source, data, function(err) {
- this._task = null;
-
- if (this._state.aborted) {
- this._shutdown();
- return;
- }
-
- if (err) {
- this.emit('error', err);
- setImmediate(callback);
- return;
- }
-
- this.emit('entry', data);
- this._entries.push(data);
-
- setImmediate(callback);
- }.bind(this));
-};
-
-Archiver.prototype._moduleFinalize = function() {
- if (typeof this._module.finalize === 'function') {
- this._module.finalize();
- } else if (typeof this._module.end === 'function') {
- this._module.end();
- } else {
- this.emit('error', new Error('module: no suitable finalize/end method found'));
- return;
- }
-};
-
-Archiver.prototype._modulePipe = function() {
- this._module.on('error', this._onModuleError.bind(this));
- this._module.pipe(this);
- this._state.modulePiped = true;
-};
-
-Archiver.prototype._moduleSupports = function(key) {
- if (!this._module.supports || !this._module.supports[key]) {
- return false;
- }
-
- return this._module.supports[key];
-};
-
-Archiver.prototype._moduleUnpipe = function() {
- this._module.unpipe(this);
- this._state.modulePiped = false;
-};
-
-Archiver.prototype._normalizeEntryData = function(data, stats) {
- data = util.defaults(data, {
- type: 'file',
- name: null,
- date: null,
- mode: null,
- sourcePath: null,
- stats: false
- });
-
- if (stats && data.stats === false) {
- data.stats = stats;
- }
-
- var isDir = data.type === 'directory';
-
- if (data.name) {
- data.name = util.sanitizePath(data.name);
-
- if (data.name.slice(-1) === '/') {
- isDir = true;
- data.type = 'directory';
- } else if (isDir) {
- data.name += '/';
- }
- }
-
- if (typeof data.mode === 'number') {
- data.mode &= 0777;
- } else if (data.stats && data.mode === null) {
- data.mode = data.stats.mode & 0777;
- } else if (data.mode === null) {
- data.mode = isDir ? 0755 : 0644;
- }
-
- if (data.stats && data.date === null) {
- data.date = data.stats.mtime;
- } else {
- data.date = util.dateify(data.date);
- }
-
- return data;
-};
-
-Archiver.prototype._onModuleError = function(err) {
- this.emit('error', err);
-};
-
-Archiver.prototype._onQueueDrain = function() {
- if (this._state.finalizing || this._state.finalized || this._state.aborted) {
- return;
- }
-
- if (this._state.finalize && this._pending === 0 && this._queue.idle() && this._statQueue.idle()) {
- this._finalize();
- return;
- }
-};
-
-Archiver.prototype._onQueueTask = function(task, callback) {
- if (this._state.finalizing || this._state.finalized || this._state.aborted) {
- callback();
- return;
- }
-
- this._task = task;
- this._moduleAppend(task.source, task.data, callback);
-};
-
-Archiver.prototype._onStatQueueTask = function(task, callback) {
- if (this._state.finalizing || this._state.finalized || this._state.aborted) {
- callback();
- return;
- }
-
- fs.stat(task.filepath, function(err, stats) {
- if (this._state.aborted) {
- setImmediate(callback);
- return;
- }
-
- if (err) {
- this.emit('error', err);
- setImmediate(callback);
- return;
- }
-
- task = this._updateQueueTaskWithStats(task, stats);
-
- if (task.source !== null) {
- this._queue.push(task);
- setImmediate(callback);
- } else {
- this.emit('error', new Error('unsupported entry: ' + task.filepath));
- setImmediate(callback);
- return;
- }
- }.bind(this));
-};
-
-Archiver.prototype._shutdown = function() {
- this._moduleUnpipe();
- this.end();
-};
-
-Archiver.prototype._transform = function(chunk, encoding, callback) {
- if (chunk) {
- this._pointer += chunk.length;
- }
-
- callback(null, chunk);
-};
-
-Archiver.prototype._updateQueueTaskWithStats = function(task, stats) {
- if (stats.isFile()) {
- task.data.type = 'file';
- task.data.sourceType = 'stream';
- task.source = util.lazyReadStream(task.filepath);
- } else if (stats.isDirectory() && this._moduleSupports('directory')) {
- task.data.name = util.trailingSlashIt(task.data.name);
- task.data.type = 'directory';
- task.data.sourcePath = util.trailingSlashIt(task.filepath);
- task.data.sourceType = 'buffer';
- task.source = new Buffer(0);
- } else {
- return task;
- }
-
- task.data = this._normalizeEntryData(task.data, stats);
- return task;
-};
-
-Archiver.prototype.abort = function() {
- if (this._state.aborted || this._state.finalized) {
- return this;
- }
-
- this._abort();
-
- return this;
-};
-
-Archiver.prototype.append = function(source, data) {
- if (this._state.finalize || this._state.aborted) {
- this.emit('error', new Error('append: queue closed'));
- return this;
- }
-
- data = this._normalizeEntryData(data);
-
- if (typeof data.name !== 'string' || data.name.length === 0) {
- this.emit('error', new Error('append: entry name must be a non-empty string value'));
- return this;
- }
-
- if (data.type === 'directory' && !this._moduleSupports('directory')) {
- this.emit('error', new Error('append: entries of "directory" type not currently supported by this module'));
- return this;
- }
-
- source = util.normalizeInputSource(source);
-
- if (Buffer.isBuffer(source)) {
- data.sourceType = 'buffer';
- } else if (util.isStream(source)) {
- data.sourceType = 'stream';
- } else {
- this.emit('error', new Error('append: input source must be valid Stream or Buffer instance'));
- return this;
- }
-
- this._queue.push({
- data: data,
- source: source
- });
-
- return this;
-};
-
-Archiver.prototype.bulk = function(mappings) {
- if (this._state.finalize || this._state.aborted) {
- this.emit('error', new Error('bulk: queue closed'));
- return this;
- }
-
- if (!Array.isArray(mappings)) {
- mappings = [mappings];
- }
-
- var self = this;
- var files = util.file.normalizeFilesArray(mappings);
-
- files.forEach(function(file){
- var isExpandedPair = file.orig.expand || false;
- var fileData = file.data || {};
-
- file.src.forEach(function(filepath) {
- var data = util._.extend({}, fileData);
- data.name = isExpandedPair ? util.unixifyPath(file.dest) : util.unixifyPath(file.dest || '', filepath);
-
- if (data.name === '.') {
- return;
- }
-
- self._append(filepath, data);
- });
- });
-
- return this;
-};
-
-Archiver.prototype.directory = function(dirpath, destpath, data) {
- if (this._state.finalize || this._state.aborted) {
- this.emit('error', new Error('directory: queue closed'));
- return this;
- }
-
- if (typeof dirpath !== 'string' || dirpath.length === 0) {
- this.emit('error', new Error('directory: dirpath must be a non-empty string value'));
- return this;
- }
-
- this._pending++;
-
- if (destpath === false) {
- destpath = '';
- } else if (typeof destpath !== 'string'){
- destpath = dirpath;
- }
-
- if (typeof data !== 'object') {
- data = {};
- }
-
- var self = this;
-
- util.walkdir(dirpath, function(err, results) {
- if (err) {
- self.emit('error', err);
- } else {
- results.forEach(function(file) {
- var entryData = util._.extend({}, data);
- entryData.name = util.sanitizePath(destpath, file.relative);
- entryData.stats = file.stats;
-
- self._append(file.path, entryData);
- });
- }
-
- self._pending--;
- self._maybeFinalize();
- });
-
- return this;
-};
-
-Archiver.prototype.file = function(filepath, data) {
- if (this._state.finalize || this._state.aborted) {
- this.emit('error', new Error('file: queue closed'));
- return this;
- }
-
- if (typeof filepath !== 'string' || filepath.length === 0) {
- this.emit('error', new Error('file: filepath must be a non-empty string value'));
- return this;
- }
-
- this._append(filepath, data);
-
- return this;
-};
-
-Archiver.prototype.finalize = function() {
- if (this._state.aborted) {
- this.emit('error', new Error('finalize: archive was aborted'));
- return this;
- }
-
- if (this._state.finalize) {
- this.emit('error', new Error('finalize: archive already finalizing'));
- return this;
- }
-
- this._state.finalize = true;
-
- if (this._pending === 0 && this._queue.idle() && this._statQueue.idle()) {
- this._finalize();
- }
-
- return this;
-};
-
-Archiver.prototype.setFormat = function(format) {
- if (this._format) {
- this.emit('error', new Error('format: archive format already set'));
- return this;
- }
-
- this._format = format;
-
- return this;
-};
-
-Archiver.prototype.setModule = function(module) {
- if (this._state.aborted) {
- this.emit('error', new Error('module: archive was aborted'));
- return this;
- }
-
- if (this._state.module) {
- this.emit('error', new Error('module: module already set'));
- return this;
- }
-
- this._module = module;
- this._modulePipe();
-
- return this;
-};
-
-Archiver.prototype.pointer = function() {
- return this._pointer;
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
+ */
+var fs = require('fs');
+var inherits = require('util').inherits;
+var Transform = require('readable-stream').Transform;
+
+var async = require('async');
+
+var util = require('./util');
+
+var Archiver = module.exports = function(options) {
+ if (!(this instanceof Archiver)) {
+ return new Archiver(options);
+ }
+
+ options = this.options = util.defaults(options, {
+ highWaterMark: 1024 * 1024,
+ statConcurrency: 4
+ });
+
+ Transform.call(this, options);
+
+ this._entries = [];
+ this._format = false;
+ this._module = false;
+ this._pending = 0;
+ this._pointer = 0;
+
+ this._queue = async.queue(this._onQueueTask.bind(this), 1);
+ this._queue.drain = this._onQueueDrain.bind(this);
+
+ this._statQueue = async.queue(this._onStatQueueTask.bind(this), options.statConcurrency);
+
+ this._state = {
+ aborted: false,
+ finalize: false,
+ finalizing: false,
+ finalized: false,
+ modulePiped: false
+ };
+};
+
+inherits(Archiver, Transform);
+
+Archiver.prototype._abort = function() {
+ this._state.aborted = true;
+ this._queue.kill();
+ this._statQueue.kill();
+
+ if (this._queue.idle()) {
+ this._shutdown();
+ }
+};
+
+Archiver.prototype._append = function(filepath, data) {
+ data = data || {};
+
+ var task = {
+ source: null,
+ filepath: filepath
+ };
+
+ if (!data.name) {
+ data.name = filepath;
+ }
+
+ data.sourcePath = filepath;
+ task.data = data;
+
+ if (data.stats && data.stats instanceof fs.Stats) {
+ task = this._updateQueueTaskWithStats(task, data.stats);
+ this._queue.push(task);
+ } else {
+ this._statQueue.push(task);
+ }
+};
+
+Archiver.prototype._finalize = function() {
+ if (this._state.finalizing || this._state.finalized || this._state.aborted) {
+ return;
+ }
+
+ this._state.finalizing = true;
+
+ this._moduleFinalize();
+
+ this._state.finalizing = false;
+ this._state.finalized = true;
+};
+
+Archiver.prototype._maybeFinalize = function() {
+ if (this._state.finalizing || this._state.finalized || this._state.aborted) {
+ return false;
+ }
+
+ if (this._state.finalize && this._pending === 0 && this._queue.idle() && this._statQueue.idle()) {
+ this._finalize();
+ return true;
+ }
+
+ return false;
+};
+
+Archiver.prototype._moduleAppend = function(source, data, callback) {
+ if (this._state.aborted) {
+ callback();
+ return;
+ }
+
+ this._module.append(source, data, function(err) {
+ this._task = null;
+
+ if (this._state.aborted) {
+ this._shutdown();
+ return;
+ }
+
+ if (err) {
+ this.emit('error', err);
+ setImmediate(callback);
+ return;
+ }
+
+ this.emit('entry', data);
+ this._entries.push(data);
+
+ setImmediate(callback);
+ }.bind(this));
+};
+
+Archiver.prototype._moduleFinalize = function() {
+ if (typeof this._module.finalize === 'function') {
+ this._module.finalize();
+ } else if (typeof this._module.end === 'function') {
+ this._module.end();
+ } else {
+ this.emit('error', new Error('module: no suitable finalize/end method found'));
+ return;
+ }
+};
+
+Archiver.prototype._modulePipe = function() {
+ this._module.on('error', this._onModuleError.bind(this));
+ this._module.pipe(this);
+ this._state.modulePiped = true;
+};
+
+Archiver.prototype._moduleSupports = function(key) {
+ if (!this._module.supports || !this._module.supports[key]) {
+ return false;
+ }
+
+ return this._module.supports[key];
+};
+
+Archiver.prototype._moduleUnpipe = function() {
+ this._module.unpipe(this);
+ this._state.modulePiped = false;
+};
+
+Archiver.prototype._normalizeEntryData = function(data, stats) {
+ data = util.defaults(data, {
+ type: 'file',
+ name: null,
+ date: null,
+ mode: null,
+ sourcePath: null,
+ stats: false
+ });
+
+ if (stats && data.stats === false) {
+ data.stats = stats;
+ }
+
+ var isDir = data.type === 'directory';
+
+ if (data.name) {
+ data.name = util.sanitizePath(data.name);
+
+ if (data.name.slice(-1) === '/') {
+ isDir = true;
+ data.type = 'directory';
+ } else if (isDir) {
+ data.name += '/';
+ }
+ }
+
+ if (typeof data.mode === 'number') {
+ data.mode &= 0777;
+ } else if (data.stats && data.mode === null) {
+ data.mode = data.stats.mode & 0777;
+ } else if (data.mode === null) {
+ data.mode = isDir ? 0755 : 0644;
+ }
+
+ if (data.stats && data.date === null) {
+ data.date = data.stats.mtime;
+ } else {
+ data.date = util.dateify(data.date);
+ }
+
+ return data;
+};
+
+Archiver.prototype._onModuleError = function(err) {
+ this.emit('error', err);
+};
+
+Archiver.prototype._onQueueDrain = function() {
+ if (this._state.finalizing || this._state.finalized || this._state.aborted) {
+ return;
+ }
+
+ if (this._state.finalize && this._pending === 0 && this._queue.idle() && this._statQueue.idle()) {
+ this._finalize();
+ return;
+ }
+};
+
+Archiver.prototype._onQueueTask = function(task, callback) {
+ if (this._state.finalizing || this._state.finalized || this._state.aborted) {
+ callback();
+ return;
+ }
+
+ this._task = task;
+ this._moduleAppend(task.source, task.data, callback);
+};
+
+Archiver.prototype._onStatQueueTask = function(task, callback) {
+ if (this._state.finalizing || this._state.finalized || this._state.aborted) {
+ callback();
+ return;
+ }
+
+ fs.stat(task.filepath, function(err, stats) {
+ if (this._state.aborted) {
+ setImmediate(callback);
+ return;
+ }
+
+ if (err) {
+ this.emit('error', err);
+ setImmediate(callback);
+ return;
+ }
+
+ task = this._updateQueueTaskWithStats(task, stats);
+
+ if (task.source !== null) {
+ this._queue.push(task);
+ setImmediate(callback);
+ } else {
+ this.emit('error', new Error('unsupported entry: ' + task.filepath));
+ setImmediate(callback);
+ return;
+ }
+ }.bind(this));
+};
+
+Archiver.prototype._shutdown = function() {
+ this._moduleUnpipe();
+ this.end();
+};
+
+Archiver.prototype._transform = function(chunk, encoding, callback) {
+ if (chunk) {
+ this._pointer += chunk.length;
+ }
+
+ callback(null, chunk);
+};
+
+Archiver.prototype._updateQueueTaskWithStats = function(task, stats) {
+ if (stats.isFile()) {
+ task.data.type = 'file';
+ task.data.sourceType = 'stream';
+ task.source = util.lazyReadStream(task.filepath);
+ } else if (stats.isDirectory() && this._moduleSupports('directory')) {
+ task.data.name = util.trailingSlashIt(task.data.name);
+ task.data.type = 'directory';
+ task.data.sourcePath = util.trailingSlashIt(task.filepath);
+ task.data.sourceType = 'buffer';
+ task.source = new Buffer(0);
+ } else {
+ return task;
+ }
+
+ task.data = this._normalizeEntryData(task.data, stats);
+ return task;
+};
+
+Archiver.prototype.abort = function() {
+ if (this._state.aborted || this._state.finalized) {
+ return this;
+ }
+
+ this._abort();
+
+ return this;
+};
+
+Archiver.prototype.append = function(source, data) {
+ if (this._state.finalize || this._state.aborted) {
+ this.emit('error', new Error('append: queue closed'));
+ return this;
+ }
+
+ data = this._normalizeEntryData(data);
+
+ if (typeof data.name !== 'string' || data.name.length === 0) {
+ this.emit('error', new Error('append: entry name must be a non-empty string value'));
+ return this;
+ }
+
+ if (data.type === 'directory' && !this._moduleSupports('directory')) {
+ this.emit('error', new Error('append: entries of "directory" type not currently supported by this module'));
+ return this;
+ }
+
+ source = util.normalizeInputSource(source);
+
+ if (Buffer.isBuffer(source)) {
+ data.sourceType = 'buffer';
+ } else if (util.isStream(source)) {
+ data.sourceType = 'stream';
+ } else {
+ this.emit('error', new Error('append: input source must be valid Stream or Buffer instance'));
+ return this;
+ }
+
+ this._queue.push({
+ data: data,
+ source: source
+ });
+
+ return this;
+};
+
+Archiver.prototype.bulk = function(mappings) {
+ if (this._state.finalize || this._state.aborted) {
+ this.emit('error', new Error('bulk: queue closed'));
+ return this;
+ }
+
+ if (!Array.isArray(mappings)) {
+ mappings = [mappings];
+ }
+
+ var self = this;
+ var files = util.file.normalizeFilesArray(mappings);
+
+ files.forEach(function(file){
+ var isExpandedPair = file.orig.expand || false;
+ var fileData = file.data || {};
+
+ file.src.forEach(function(filepath) {
+ var data = util._.extend({}, fileData);
+ data.name = isExpandedPair ? util.unixifyPath(file.dest) : util.unixifyPath(file.dest || '', filepath);
+
+ if (data.name === '.') {
+ return;
+ }
+
+ self._append(filepath, data);
+ });
+ });
+
+ return this;
+};
+
+Archiver.prototype.directory = function(dirpath, destpath, data) {
+ if (this._state.finalize || this._state.aborted) {
+ this.emit('error', new Error('directory: queue closed'));
+ return this;
+ }
+
+ if (typeof dirpath !== 'string' || dirpath.length === 0) {
+ this.emit('error', new Error('directory: dirpath must be a non-empty string value'));
+ return this;
+ }
+
+ this._pending++;
+
+ if (destpath === false) {
+ destpath = '';
+ } else if (typeof destpath !== 'string'){
+ destpath = dirpath;
+ }
+
+ if (typeof data !== 'object') {
+ data = {};
+ }
+
+ var self = this;
+
+ util.walkdir(dirpath, function(err, results) {
+ if (err) {
+ self.emit('error', err);
+ } else {
+ results.forEach(function(file) {
+ var entryData = util._.extend({}, data);
+ entryData.name = util.sanitizePath(destpath, file.relative);
+ entryData.stats = file.stats;
+
+ self._append(file.path, entryData);
+ });
+ }
+
+ self._pending--;
+ self._maybeFinalize();
+ });
+
+ return this;
+};
+
+Archiver.prototype.file = function(filepath, data) {
+ if (this._state.finalize || this._state.aborted) {
+ this.emit('error', new Error('file: queue closed'));
+ return this;
+ }
+
+ if (typeof filepath !== 'string' || filepath.length === 0) {
+ this.emit('error', new Error('file: filepath must be a non-empty string value'));
+ return this;
+ }
+
+ this._append(filepath, data);
+
+ return this;
+};
+
+Archiver.prototype.finalize = function() {
+ if (this._state.aborted) {
+ this.emit('error', new Error('finalize: archive was aborted'));
+ return this;
+ }
+
+ if (this._state.finalize) {
+ this.emit('error', new Error('finalize: archive already finalizing'));
+ return this;
+ }
+
+ this._state.finalize = true;
+
+ if (this._pending === 0 && this._queue.idle() && this._statQueue.idle()) {
+ this._finalize();
+ }
+
+ return this;
+};
+
+Archiver.prototype.setFormat = function(format) {
+ if (this._format) {
+ this.emit('error', new Error('format: archive format already set'));
+ return this;
+ }
+
+ this._format = format;
+
+ return this;
+};
+
+Archiver.prototype.setModule = function(module) {
+ if (this._state.aborted) {
+ this.emit('error', new Error('module: archive was aborted'));
+ return this;
+ }
+
+ if (this._state.module) {
+ this.emit('error', new Error('module: module already set'));
+ return this;
+ }
+
+ this._module = module;
+ this._modulePipe();
+
+ return this;
+};
+
+Archiver.prototype.pointer = function() {
+ return this._pointer;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/lib/plugins/json.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/lib/plugins/json.js b/node_modules/archiver/lib/plugins/json.js
index 4659dc3..b6acc12 100644
--- a/node_modules/archiver/lib/plugins/json.js
+++ b/node_modules/archiver/lib/plugins/json.js
@@ -1,70 +1,70 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
- */
-var inherits = require('util').inherits;
-var Transform = require('readable-stream').Transform;
-
-var crc32 = require('buffer-crc32');
-var util = require('../util');
-
-var Json = module.exports = function(options) {
- if (!(this instanceof Json)) {
- return new Json(options);
- }
-
- options = this.options = util.defaults(options, {});
-
- Transform.call(this, options);
-
- this.supports = {
- directory: true
- };
-
- this.files = [];
-};
-
-inherits(Json, Transform);
-
-Json.prototype._transform = function(chunk, encoding, callback) {
- callback(null, chunk);
-};
-
-Json.prototype._writeStringified = function() {
- var fileString = JSON.stringify(this.files);
- this.write(fileString);
-};
-
-Json.prototype.append = function(source, data, callback) {
- var self = this;
-
- data.crc32 = 0;
-
- function onend(err, sourceBuffer) {
- if (err) {
- callback(err);
- return;
- }
-
- data.size = sourceBuffer.length || 0;
- data.crc32 = crc32.unsigned(sourceBuffer);
-
- self.files.push(data);
-
- callback(null, data);
- }
-
- if (data.sourceType === 'buffer') {
- onend(null, source);
- } else if (data.sourceType === 'stream') {
- util.collectStream(source, onend);
- }
-};
-
-Json.prototype.finalize = function() {
- this._writeStringified();
- this.end();
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
+ */
+var inherits = require('util').inherits;
+var Transform = require('readable-stream').Transform;
+
+var crc32 = require('buffer-crc32');
+var util = require('../util');
+
+var Json = module.exports = function(options) {
+ if (!(this instanceof Json)) {
+ return new Json(options);
+ }
+
+ options = this.options = util.defaults(options, {});
+
+ Transform.call(this, options);
+
+ this.supports = {
+ directory: true
+ };
+
+ this.files = [];
+};
+
+inherits(Json, Transform);
+
+Json.prototype._transform = function(chunk, encoding, callback) {
+ callback(null, chunk);
+};
+
+Json.prototype._writeStringified = function() {
+ var fileString = JSON.stringify(this.files);
+ this.write(fileString);
+};
+
+Json.prototype.append = function(source, data, callback) {
+ var self = this;
+
+ data.crc32 = 0;
+
+ function onend(err, sourceBuffer) {
+ if (err) {
+ callback(err);
+ return;
+ }
+
+ data.size = sourceBuffer.length || 0;
+ data.crc32 = crc32.unsigned(sourceBuffer);
+
+ self.files.push(data);
+
+ callback(null, data);
+ }
+
+ if (data.sourceType === 'buffer') {
+ onend(null, source);
+ } else if (data.sourceType === 'stream') {
+ util.collectStream(source, onend);
+ }
+};
+
+Json.prototype.finalize = function() {
+ this._writeStringified();
+ this.end();
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/lib/plugins/tar.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/lib/plugins/tar.js b/node_modules/archiver/lib/plugins/tar.js
index c0816e7..a672bd4 100644
--- a/node_modules/archiver/lib/plugins/tar.js
+++ b/node_modules/archiver/lib/plugins/tar.js
@@ -1,96 +1,96 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
- */
-var zlib = require('zlib');
-
-var engine = require('tar-stream');
-var util = require('../util');
-
-var Tar = module.exports = function(options) {
- if (!(this instanceof Tar)) {
- return new Tar(options);
- }
-
- options = this.options = util.defaults(options, {
- gzip: false
- });
-
- if (typeof options.gzipOptions !== 'object') {
- options.gzipOptions = {};
- }
-
- this.supports = {
- directory: true
- };
-
- this.engine = engine.pack(options);
- this.compressor = false;
-
- if (options.gzip) {
- this.compressor = zlib.createGzip(options.gzipOptions);
- this.compressor.on('error', this._onCompressorError.bind(this));
- }
-};
-
-Tar.prototype._onCompressorError = function(err) {
- this.engine.emit('error', err);
-};
-
-Tar.prototype.append = function(source, data, callback) {
- var self = this;
-
- data.mtime = data.date;
-
- function append(err, sourceBuffer) {
- if (err) {
- callback(err);
- return;
- }
-
- self.engine.entry(data, sourceBuffer, function(err) {
- callback(err, data);
- });
- }
-
- if (data.sourceType === 'buffer') {
- append(null, source);
- } else if (data.sourceType === 'stream' && data._stats) {
- data.size = data._stats.size;
-
- var entry = self.engine.entry(data, function(err) {
- callback(err, data);
- });
-
- source.pipe(entry);
- } else if (data.sourceType === 'stream') {
- util.collectStream(source, append);
- }
-};
-
-Tar.prototype.finalize = function() {
- this.engine.finalize();
-};
-
-Tar.prototype.on = function() {
- return this.engine.on.apply(this.engine, arguments);
-};
-
-Tar.prototype.pipe = function(destination, options) {
- if (this.compressor) {
- return this.engine.pipe.apply(this.engine, [this.compressor]).pipe(destination, options);
- } else {
- return this.engine.pipe.apply(this.engine, arguments);
- }
-};
-
-Tar.prototype.unpipe = function() {
- if (this.compressor) {
- return this.compressor.unpipe.apply(this.compressor, arguments);
- } else {
- return this.engine.unpipe.apply(this.engine, arguments);
- }
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
+ */
+var zlib = require('zlib');
+
+var engine = require('tar-stream');
+var util = require('../util');
+
+var Tar = module.exports = function(options) {
+ if (!(this instanceof Tar)) {
+ return new Tar(options);
+ }
+
+ options = this.options = util.defaults(options, {
+ gzip: false
+ });
+
+ if (typeof options.gzipOptions !== 'object') {
+ options.gzipOptions = {};
+ }
+
+ this.supports = {
+ directory: true
+ };
+
+ this.engine = engine.pack(options);
+ this.compressor = false;
+
+ if (options.gzip) {
+ this.compressor = zlib.createGzip(options.gzipOptions);
+ this.compressor.on('error', this._onCompressorError.bind(this));
+ }
+};
+
+Tar.prototype._onCompressorError = function(err) {
+ this.engine.emit('error', err);
+};
+
+Tar.prototype.append = function(source, data, callback) {
+ var self = this;
+
+ data.mtime = data.date;
+
+ function append(err, sourceBuffer) {
+ if (err) {
+ callback(err);
+ return;
+ }
+
+ self.engine.entry(data, sourceBuffer, function(err) {
+ callback(err, data);
+ });
+ }
+
+ if (data.sourceType === 'buffer') {
+ append(null, source);
+ } else if (data.sourceType === 'stream' && data._stats) {
+ data.size = data._stats.size;
+
+ var entry = self.engine.entry(data, function(err) {
+ callback(err, data);
+ });
+
+ source.pipe(entry);
+ } else if (data.sourceType === 'stream') {
+ util.collectStream(source, append);
+ }
+};
+
+Tar.prototype.finalize = function() {
+ this.engine.finalize();
+};
+
+Tar.prototype.on = function() {
+ return this.engine.on.apply(this.engine, arguments);
+};
+
+Tar.prototype.pipe = function(destination, options) {
+ if (this.compressor) {
+ return this.engine.pipe.apply(this.engine, [this.compressor]).pipe(destination, options);
+ } else {
+ return this.engine.pipe.apply(this.engine, arguments);
+ }
+};
+
+Tar.prototype.unpipe = function() {
+ if (this.compressor) {
+ return this.compressor.unpipe.apply(this.compressor, arguments);
+ } else {
+ return this.engine.unpipe.apply(this.engine, arguments);
+ }
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/lib/plugins/zip.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/lib/plugins/zip.js b/node_modules/archiver/lib/plugins/zip.js
index c46ffc4..b55d910 100644
--- a/node_modules/archiver/lib/plugins/zip.js
+++ b/node_modules/archiver/lib/plugins/zip.js
@@ -1,47 +1,47 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
- */
-var engine = require('zip-stream');
-var util = require('../util');
-
-var Zip = module.exports = function(options) {
- if (!(this instanceof Zip)) {
- return new Zip(options);
- }
-
- options = this.options = util.defaults(options, {
- comment: '',
- forceUTC: false,
- store: false
- });
-
- this.supports = {
- directory: true
- };
-
- this.engine = new engine(options);
-};
-
-Zip.prototype.append = function(source, data, callback) {
- this.engine.entry(source, data, callback);
-};
-
-Zip.prototype.finalize = function() {
- this.engine.finalize();
-};
-
-Zip.prototype.on = function() {
- return this.engine.on.apply(this.engine, arguments);
-};
-
-Zip.prototype.pipe = function() {
- return this.engine.pipe.apply(this.engine, arguments);
-};
-
-Zip.prototype.unpipe = function() {
- return this.engine.unpipe.apply(this.engine, arguments);
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
+ */
+var engine = require('zip-stream');
+var util = require('../util');
+
+var Zip = module.exports = function(options) {
+ if (!(this instanceof Zip)) {
+ return new Zip(options);
+ }
+
+ options = this.options = util.defaults(options, {
+ comment: '',
+ forceUTC: false,
+ store: false
+ });
+
+ this.supports = {
+ directory: true
+ };
+
+ this.engine = new engine(options);
+};
+
+Zip.prototype.append = function(source, data, callback) {
+ this.engine.entry(source, data, callback);
+};
+
+Zip.prototype.finalize = function() {
+ this.engine.finalize();
+};
+
+Zip.prototype.on = function() {
+ return this.engine.on.apply(this.engine, arguments);
+};
+
+Zip.prototype.pipe = function() {
+ return this.engine.pipe.apply(this.engine, arguments);
+};
+
+Zip.prototype.unpipe = function() {
+ return this.engine.unpipe.apply(this.engine, arguments);
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/lib/util/file.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/lib/util/file.js b/node_modules/archiver/lib/util/file.js
index 4d671de..425895f 100644
--- a/node_modules/archiver/lib/util/file.js
+++ b/node_modules/archiver/lib/util/file.js
@@ -1,206 +1,206 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
- */
-var fs = require('fs');
-var path = require('path');
-
-var _ = require('lodash');
-var glob = require('glob');
-
-var file = module.exports = {};
-
-var pathSeparatorRe = /[\/\\]/g;
-
-// Process specified wildcard glob patterns or filenames against a
-// callback, excluding and uniquing files in the result set.
-var processPatterns = function(patterns, fn) {
- // Filepaths to return.
- var result = [];
- // Iterate over flattened patterns array.
- _.flatten(patterns).forEach(function(pattern) {
- // If the first character is ! it should be omitted
- var exclusion = pattern.indexOf('!') === 0;
- // If the pattern is an exclusion, remove the !
- if (exclusion) { pattern = pattern.slice(1); }
- // Find all matching files for this pattern.
- var matches = fn(pattern);
- if (exclusion) {
- // If an exclusion, remove matching files.
- result = _.difference(result, matches);
- } else {
- // Otherwise add matching files.
- result = _.union(result, matches);
- }
- });
- return result;
-};
-
-// True if the file path exists.
-file.exists = function() {
- var filepath = path.join.apply(path, arguments);
- return fs.existsSync(filepath);
-};
-
-// Return an array of all file paths that match the given wildcard patterns.
-file.expand = function() {
- var args = _.toArray(arguments);
- // If the first argument is an options object, save those options to pass
- // into the File.prototype.glob.sync method.
- var options = _.isPlainObject(args[0]) ? args.shift() : {};
- // Use the first argument if it's an Array, otherwise convert the arguments
- // object to an array and use that.
- var patterns = Array.isArray(args[0]) ? args[0] : args;
- // Return empty set if there are no patterns or filepaths.
- if (patterns.length === 0) { return []; }
- // Return all matching filepaths.
- var matches = processPatterns(patterns, function(pattern) {
- // Find all matching files for this pattern.
- return glob.sync(pattern, options);
- });
- // Filter result set?
- if (options.filter) {
- matches = matches.filter(function(filepath) {
- filepath = path.join(options.cwd || '', filepath);
- try {
- if (typeof options.filter === 'function') {
- return options.filter(filepath);
- } else {
- // If the file is of the right type and exists, this should work.
- return fs.statSync(filepath)[options.filter]();
- }
- } catch(e) {
- // Otherwise, it's probably not the right type.
- return false;
- }
- });
- }
- return matches;
-};
-
-// Build a multi task "files" object dynamically.
-file.expandMapping = function(patterns, destBase, options) {
- options = _.defaults({}, options, {
- rename: function(destBase, destPath) {
- return path.join(destBase || '', destPath);
- }
- });
- var files = [];
- var fileByDest = {};
- // Find all files matching pattern, using passed-in options.
- file.expand(options, patterns).forEach(function(src) {
- var destPath = src;
- // Flatten?
- if (options.flatten) {
- destPath = path.basename(destPath);
- }
- // Change the extension?
- if (options.ext) {
- destPath = destPath.replace(/(\.[^\/]*)?$/, options.ext);
- }
- // Generate destination filename.
- var dest = options.rename(destBase, destPath, options);
- // Prepend cwd to src path if necessary.
- if (options.cwd) { src = path.join(options.cwd, src); }
- // Normalize filepaths to be unix-style.
- dest = dest.replace(pathSeparatorRe, '/');
- src = src.replace(pathSeparatorRe, '/');
- // Map correct src path to dest path.
- if (fileByDest[dest]) {
- // If dest already exists, push this src onto that dest's src array.
- fileByDest[dest].src.push(src);
- } else {
- // Otherwise create a new src-dest file mapping object.
- files.push({
- src: [src],
- dest: dest,
- });
- // And store a reference for later use.
- fileByDest[dest] = files[files.length - 1];
- }
- });
- return files;
-};
-
-// reusing bits of grunt's multi-task source normalization
-file.normalizeFilesArray = function(data) {
- var files = [];
-
- data.forEach(function(obj) {
- var prop;
- if ('src' in obj || 'dest' in obj) {
- files.push(obj);
- }
- });
-
- if (files.length === 0) {
- return [];
- }
-
- files = _(files).chain().forEach(function(obj) {
- if (!('src' in obj) || !obj.src) { return; }
- // Normalize .src properties to flattened array.
- if (Array.isArray(obj.src)) {
- obj.src = _.flatten(obj.src);
- } else {
- obj.src = [obj.src];
- }
- }).map(function(obj) {
- // Build options object, removing unwanted properties.
- var expandOptions = _.extend({}, obj);
- delete expandOptions.src;
- delete expandOptions.dest;
-
- // Expand file mappings.
- if (obj.expand) {
- return file.expandMapping(obj.src, obj.dest, expandOptions).map(function(mapObj) {
- // Copy obj properties to result.
- var result = _.extend({}, obj);
- // Make a clone of the orig obj available.
- result.orig = _.extend({}, obj);
- // Set .src and .dest, processing both as templates.
- result.src = mapObj.src;
- result.dest = mapObj.dest;
- // Remove unwanted properties.
- ['expand', 'cwd', 'flatten', 'rename', 'ext'].forEach(function(prop) {
- delete result[prop];
- });
- return result;
- });
- }
-
- // Copy obj properties to result, adding an .orig property.
- var result = _.extend({}, obj);
- // Make a clone of the orig obj available.
- result.orig = _.extend({}, obj);
-
- if ('src' in result) {
- // Expose an expand-on-demand getter method as .src.
- Object.defineProperty(result, 'src', {
- enumerable: true,
- get: function fn() {
- var src;
- if (!('result' in fn)) {
- src = obj.src;
- // If src is an array, flatten it. Otherwise, make it into an array.
- src = Array.isArray(src) ? _.flatten(src) : [src];
- // Expand src files, memoizing result.
- fn.result = file.expand(expandOptions, src);
- }
- return fn.result;
- }
- });
- }
-
- if ('dest' in result) {
- result.dest = obj.dest;
- }
-
- return result;
- }).flatten().value();
-
- return files;
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
+ */
+var fs = require('fs');
+var path = require('path');
+
+var _ = require('lodash');
+var glob = require('glob');
+
+var file = module.exports = {};
+
+var pathSeparatorRe = /[\/\\]/g;
+
+// Process specified wildcard glob patterns or filenames against a
+// callback, excluding and uniquing files in the result set.
+var processPatterns = function(patterns, fn) {
+ // Filepaths to return.
+ var result = [];
+ // Iterate over flattened patterns array.
+ _.flatten(patterns).forEach(function(pattern) {
+ // If the first character is ! it should be omitted
+ var exclusion = pattern.indexOf('!') === 0;
+ // If the pattern is an exclusion, remove the !
+ if (exclusion) { pattern = pattern.slice(1); }
+ // Find all matching files for this pattern.
+ var matches = fn(pattern);
+ if (exclusion) {
+ // If an exclusion, remove matching files.
+ result = _.difference(result, matches);
+ } else {
+ // Otherwise add matching files.
+ result = _.union(result, matches);
+ }
+ });
+ return result;
+};
+
+// True if the file path exists.
+file.exists = function() {
+ var filepath = path.join.apply(path, arguments);
+ return fs.existsSync(filepath);
+};
+
+// Return an array of all file paths that match the given wildcard patterns.
+file.expand = function() {
+ var args = _.toArray(arguments);
+ // If the first argument is an options object, save those options to pass
+ // into the File.prototype.glob.sync method.
+ var options = _.isPlainObject(args[0]) ? args.shift() : {};
+ // Use the first argument if it's an Array, otherwise convert the arguments
+ // object to an array and use that.
+ var patterns = Array.isArray(args[0]) ? args[0] : args;
+ // Return empty set if there are no patterns or filepaths.
+ if (patterns.length === 0) { return []; }
+ // Return all matching filepaths.
+ var matches = processPatterns(patterns, function(pattern) {
+ // Find all matching files for this pattern.
+ return glob.sync(pattern, options);
+ });
+ // Filter result set?
+ if (options.filter) {
+ matches = matches.filter(function(filepath) {
+ filepath = path.join(options.cwd || '', filepath);
+ try {
+ if (typeof options.filter === 'function') {
+ return options.filter(filepath);
+ } else {
+ // If the file is of the right type and exists, this should work.
+ return fs.statSync(filepath)[options.filter]();
+ }
+ } catch(e) {
+ // Otherwise, it's probably not the right type.
+ return false;
+ }
+ });
+ }
+ return matches;
+};
+
+// Build a multi task "files" object dynamically.
+file.expandMapping = function(patterns, destBase, options) {
+ options = _.defaults({}, options, {
+ rename: function(destBase, destPath) {
+ return path.join(destBase || '', destPath);
+ }
+ });
+ var files = [];
+ var fileByDest = {};
+ // Find all files matching pattern, using passed-in options.
+ file.expand(options, patterns).forEach(function(src) {
+ var destPath = src;
+ // Flatten?
+ if (options.flatten) {
+ destPath = path.basename(destPath);
+ }
+ // Change the extension?
+ if (options.ext) {
+ destPath = destPath.replace(/(\.[^\/]*)?$/, options.ext);
+ }
+ // Generate destination filename.
+ var dest = options.rename(destBase, destPath, options);
+ // Prepend cwd to src path if necessary.
+ if (options.cwd) { src = path.join(options.cwd, src); }
+ // Normalize filepaths to be unix-style.
+ dest = dest.replace(pathSeparatorRe, '/');
+ src = src.replace(pathSeparatorRe, '/');
+ // Map correct src path to dest path.
+ if (fileByDest[dest]) {
+ // If dest already exists, push this src onto that dest's src array.
+ fileByDest[dest].src.push(src);
+ } else {
+ // Otherwise create a new src-dest file mapping object.
+ files.push({
+ src: [src],
+ dest: dest,
+ });
+ // And store a reference for later use.
+ fileByDest[dest] = files[files.length - 1];
+ }
+ });
+ return files;
+};
+
+// reusing bits of grunt's multi-task source normalization
+file.normalizeFilesArray = function(data) {
+ var files = [];
+
+ data.forEach(function(obj) {
+ var prop;
+ if ('src' in obj || 'dest' in obj) {
+ files.push(obj);
+ }
+ });
+
+ if (files.length === 0) {
+ return [];
+ }
+
+ files = _(files).chain().forEach(function(obj) {
+ if (!('src' in obj) || !obj.src) { return; }
+ // Normalize .src properties to flattened array.
+ if (Array.isArray(obj.src)) {
+ obj.src = _.flatten(obj.src);
+ } else {
+ obj.src = [obj.src];
+ }
+ }).map(function(obj) {
+ // Build options object, removing unwanted properties.
+ var expandOptions = _.extend({}, obj);
+ delete expandOptions.src;
+ delete expandOptions.dest;
+
+ // Expand file mappings.
+ if (obj.expand) {
+ return file.expandMapping(obj.src, obj.dest, expandOptions).map(function(mapObj) {
+ // Copy obj properties to result.
+ var result = _.extend({}, obj);
+ // Make a clone of the orig obj available.
+ result.orig = _.extend({}, obj);
+ // Set .src and .dest, processing both as templates.
+ result.src = mapObj.src;
+ result.dest = mapObj.dest;
+ // Remove unwanted properties.
+ ['expand', 'cwd', 'flatten', 'rename', 'ext'].forEach(function(prop) {
+ delete result[prop];
+ });
+ return result;
+ });
+ }
+
+ // Copy obj properties to result, adding an .orig property.
+ var result = _.extend({}, obj);
+ // Make a clone of the orig obj available.
+ result.orig = _.extend({}, obj);
+
+ if ('src' in result) {
+ // Expose an expand-on-demand getter method as .src.
+ Object.defineProperty(result, 'src', {
+ enumerable: true,
+ get: function fn() {
+ var src;
+ if (!('result' in fn)) {
+ src = obj.src;
+ // If src is an array, flatten it. Otherwise, make it into an array.
+ src = Array.isArray(src) ? _.flatten(src) : [src];
+ // Expand src files, memoizing result.
+ fn.result = file.expand(expandOptions, src);
+ }
+ return fn.result;
+ }
+ });
+ }
+
+ if ('dest' in result) {
+ result.dest = obj.dest;
+ }
+
+ return result;
+ }).flatten().value();
+
+ return files;
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/lib/util/index.js
----------------------------------------------------------------------
diff --git a/node_modules/archiver/lib/util/index.js b/node_modules/archiver/lib/util/index.js
index 132b406..0e5251e 100644
--- a/node_modules/archiver/lib/util/index.js
+++ b/node_modules/archiver/lib/util/index.js
@@ -1,149 +1,149 @@
-/**
- * node-archiver
- *
- * Copyright (c) 2012-2014 Chris Talkington, contributors.
- * Licensed under the MIT license.
- * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
- */
-var fs = require('fs');
-var path = require('path');
-
-var Stream = require('stream').Stream;
-var PassThrough = require('readable-stream').PassThrough;
-
-var util = module.exports = {};
-
-util._ = require('lodash');
-util.lazystream = require('lazystream');
-util.file = require('./file');
-
-util.collectStream = function(source, callback) {
- var collection = [];
- var size = 0;
-
- source.on('error', callback);
-
- source.on('data', function(chunk) {
- collection.push(chunk);
- size += chunk.length;
- });
-
- source.on('end', function() {
- var buf = new Buffer(size, 'utf8');
- var offset = 0;
-
- collection.forEach(function(data) {
- data.copy(buf, offset);
- offset += data.length;
- });
-
- callback(null, buf);
- });
-};
-
-util.dateify = function(dateish) {
- dateish = dateish || new Date();
-
- if (dateish instanceof Date) {
- dateish = dateish;
- } else if (typeof dateish === 'string') {
- dateish = new Date(dateish);
- } else {
- dateish = new Date();
- }
-
- return dateish;
-};
-
-// this is slightly different from lodash version
-util.defaults = function(object, source, guard) {
- var args = arguments;
- args[0] = args[0] || {};
-
- return util._.defaults.apply(util._, args);
-};
-
-util.isStream = function(source) {
- return source instanceof Stream;
-};
-
-util.lazyReadStream = function(filepath) {
- return new util.lazystream.Readable(function() {
- return fs.createReadStream(filepath);
- });
-};
-
-util.normalizeInputSource = function(source) {
- if (source === null) {
- return new Buffer(0);
- } else if (typeof source === 'string') {
- return new Buffer(source);
- } else if (util.isStream(source) && !source._readableState) {
- var normalized = new PassThrough();
- source.pipe(normalized);
-
- return normalized;
- }
-
- return source;
-};
-
-util.sanitizePath = function() {
- var filepath = path.join.apply(path, arguments);
- return filepath.replace(/\\/g, '/').replace(/:/g, '').replace(/^(\.\.\/|\.\/|\/)+/, '');
-};
-
-util.trailingSlashIt = function(str) {
- return str.slice(-1) !== '/' ? str + '/' : str;
-};
-
-util.unixifyPath = function() {
- var filepath = path.join.apply(path, arguments);
- return filepath.replace(/\\/g, '/');
-};
-
-util.walkdir = function(dirpath, base, callback) {
- var results = [];
-
- if (typeof base === 'function') {
- callback = base;
- base = dirpath;
- }
-
- fs.readdir(dirpath, function(err, list) {
- var i = 0;
- var file;
- var filepath;
-
- if (err) {
- return callback(err);
- }
-
- (function next() {
- file = list[i++];
-
- if (!file) {
- return callback(null, results);
- }
-
- filepath = path.join(dirpath, file);
-
- fs.stat(filepath, function(err, stats) {
- results.push({
- path: filepath,
- relative: path.relative(base, filepath).replace(/\\/g, '/'),
- stats: stats
- });
-
- if (stats && stats.isDirectory()) {
- util.walkdir(filepath, base, function(err, res) {
- results = results.concat(res);
- next();
- });
- } else {
- next();
- }
- });
- })();
- });
+/**
+ * node-archiver
+ *
+ * Copyright (c) 2012-2014 Chris Talkington, contributors.
+ * Licensed under the MIT license.
+ * https://github.com/archiverjs/node-archiver/blob/master/LICENSE-MIT
+ */
+var fs = require('fs');
+var path = require('path');
+
+var Stream = require('stream').Stream;
+var PassThrough = require('readable-stream').PassThrough;
+
+var util = module.exports = {};
+
+util._ = require('lodash');
+util.lazystream = require('lazystream');
+util.file = require('./file');
+
+util.collectStream = function(source, callback) {
+ var collection = [];
+ var size = 0;
+
+ source.on('error', callback);
+
+ source.on('data', function(chunk) {
+ collection.push(chunk);
+ size += chunk.length;
+ });
+
+ source.on('end', function() {
+ var buf = new Buffer(size, 'utf8');
+ var offset = 0;
+
+ collection.forEach(function(data) {
+ data.copy(buf, offset);
+ offset += data.length;
+ });
+
+ callback(null, buf);
+ });
+};
+
+util.dateify = function(dateish) {
+ dateish = dateish || new Date();
+
+ if (dateish instanceof Date) {
+ dateish = dateish;
+ } else if (typeof dateish === 'string') {
+ dateish = new Date(dateish);
+ } else {
+ dateish = new Date();
+ }
+
+ return dateish;
+};
+
+// this is slightly different from lodash version
+util.defaults = function(object, source, guard) {
+ var args = arguments;
+ args[0] = args[0] || {};
+
+ return util._.defaults.apply(util._, args);
+};
+
+util.isStream = function(source) {
+ return source instanceof Stream;
+};
+
+util.lazyReadStream = function(filepath) {
+ return new util.lazystream.Readable(function() {
+ return fs.createReadStream(filepath);
+ });
+};
+
+util.normalizeInputSource = function(source) {
+ if (source === null) {
+ return new Buffer(0);
+ } else if (typeof source === 'string') {
+ return new Buffer(source);
+ } else if (util.isStream(source) && !source._readableState) {
+ var normalized = new PassThrough();
+ source.pipe(normalized);
+
+ return normalized;
+ }
+
+ return source;
+};
+
+util.sanitizePath = function() {
+ var filepath = path.join.apply(path, arguments);
+ return filepath.replace(/\\/g, '/').replace(/:/g, '').replace(/^(\.\.\/|\.\/|\/)+/, '');
+};
+
+util.trailingSlashIt = function(str) {
+ return str.slice(-1) !== '/' ? str + '/' : str;
+};
+
+util.unixifyPath = function() {
+ var filepath = path.join.apply(path, arguments);
+ return filepath.replace(/\\/g, '/');
+};
+
+util.walkdir = function(dirpath, base, callback) {
+ var results = [];
+
+ if (typeof base === 'function') {
+ callback = base;
+ base = dirpath;
+ }
+
+ fs.readdir(dirpath, function(err, list) {
+ var i = 0;
+ var file;
+ var filepath;
+
+ if (err) {
+ return callback(err);
+ }
+
+ (function next() {
+ file = list[i++];
+
+ if (!file) {
+ return callback(null, results);
+ }
+
+ filepath = path.join(dirpath, file);
+
+ fs.stat(filepath, function(err, stats) {
+ results.push({
+ path: filepath,
+ relative: path.relative(base, filepath).replace(/\\/g, '/'),
+ stats: stats
+ });
+
+ if (stats && stats.isDirectory()) {
+ util.walkdir(filepath, base, function(err, res) {
+ results = results.concat(res);
+ next();
+ });
+ } else {
+ next();
+ }
+ });
+ })();
+ });
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/archiver/node_modules/zip-stream/LICENSE-MIT
----------------------------------------------------------------------
diff --git a/node_modules/archiver/node_modules/zip-stream/LICENSE-MIT b/node_modules/archiver/node_modules/zip-stream/LICENSE-MIT
index 819b403..56420a6 100644
--- a/node_modules/archiver/node_modules/zip-stream/LICENSE-MIT
+++ b/node_modules/archiver/node_modules/zip-stream/LICENSE-MIT
@@ -1,22 +1,22 @@
-Copyright (c) 2014 Chris Talkington, contributors.
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+Copyright (c) 2014 Chris Talkington, contributors.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[02/13] cordova-firefoxos git commit: CB-9836 Add .gitattributes to
prevent CRLF line endings in repos
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/325bb661/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js b/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
index 43920d9..0d58db0 100644
--- a/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
+++ b/node_modules/node-firefox-start-simulator/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
@@ -1,1302 +1,1302 @@
-//
-// showdown.js -- A javascript port of Markdown.
-//
-// Copyright (c) 2007 John Fraser.
-//
-// Original Markdown Copyright (c) 2004-2005 John Gruber
-// <http://daringfireball.net/projects/markdown/>
-//
-// Redistributable under a BSD-style open source license.
-// See license.txt for more information.
-//
-// The full source distribution is at:
-//
-// A A L
-// T C A
-// T K B
-//
-// <http://www.attacklab.net/>
-//
-
-//
-// Wherever possible, Showdown is a straight, line-by-line port
-// of the Perl version of Markdown.
-//
-// This is not a normal parser design; it's basically just a
-// series of string substitutions. It's hard to read and
-// maintain this way, but keeping Showdown close to the original
-// design makes it easier to port new features.
-//
-// More importantly, Showdown behaves like markdown.pl in most
-// edge cases. So web applications can do client-side preview
-// in Javascript, and then build identical HTML on the server.
-//
-// This port needs the new RegExp functionality of ECMA 262,
-// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers
-// should do fine. Even with the new regular expression features,
-// We do a lot of work to emulate Perl's regex functionality.
-// The tricky changes in this file mostly have the "attacklab:"
-// label. Major or self-explanatory changes don't.
-//
-// Smart diff tools like Araxis Merge will be able to match up
-// this file with markdown.pl in a useful way. A little tweaking
-// helps: in a copy of markdown.pl, replace "#" with "//" and
-// replace "$text" with "text". Be sure to ignore whitespace
-// and line endings.
-//
-
-
-//
-// Showdown usage:
-//
-// var text = "Markdown *rocks*.";
-//
-// var converter = new Showdown.converter();
-// var html = converter.makeHtml(text);
-//
-// alert(html);
-//
-// Note: move the sample code to the bottom of this
-// file before uncommenting it.
-//
-
-
-//
-// Showdown namespace
-//
-var Showdown = {};
-
-//
-// converter
-//
-// Wraps all "globals" so that the only thing
-// exposed is makeHtml().
-//
-Showdown.converter = function() {
-
-//
-// Globals:
-//
-
-// Global hashes, used by various utility routines
-var g_urls;
-var g_titles;
-var g_html_blocks;
-
-// Used to track when we're inside an ordered or unordered list
-// (see _ProcessListItems() for details):
-var g_list_level = 0;
-
-
-this.makeHtml = function(text) {
-//
-// Main function. The order in which other subs are called here is
-// essential. Link and image substitutions need to happen before
-// _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the <a>
-// and <img> tags get encoded.
-//
-
- // Clear the global hashes. If we don't clear these, you get conflicts
- // from other articles when generating a page which contains more than
- // one article (e.g. an index page that shows the N most recent
- // articles):
- g_urls = new Array();
- g_titles = new Array();
- g_html_blocks = new Array();
-
- // attacklab: Replace ~ with ~T
- // This lets us use tilde as an escape char to avoid md5 hashes
- // The choice of character is arbitray; anything that isn't
- // magic in Markdown will work.
- text = text.replace(/~/g,"~T");
-
- // attacklab: Replace $ with ~D
- // RegExp interprets $ as a special character
- // when it's in a replacement string
- text = text.replace(/\$/g,"~D");
-
- // Standardize line endings
- text = text.replace(/\r\n/g,"\n"); // DOS to Unix
- text = text.replace(/\r/g,"\n"); // Mac to Unix
-
- // Make sure text begins and ends with a couple of newlines:
- text = "\n\n" + text + "\n\n";
-
- // Convert all tabs to spaces.
- text = _Detab(text);
-
- // Strip any lines consisting only of spaces and tabs.
- // This makes subsequent regexen easier to write, because we can
- // match consecutive blank lines with /\n+/ instead of something
- // contorted like /[ \t]*\n+/ .
- text = text.replace(/^[ \t]+$/mg,"");
-
- // Turn block-level HTML blocks into hash entries
- text = _HashHTMLBlocks(text);
-
- // Strip link definitions, store in hashes.
- text = _StripLinkDefinitions(text);
-
- text = _RunBlockGamut(text);
-
- text = _UnescapeSpecialChars(text);
-
- // attacklab: Restore dollar signs
- text = text.replace(/~D/g,"$$");
-
- // attacklab: Restore tildes
- text = text.replace(/~T/g,"~");
-
- return text;
-}
-
-
-var _StripLinkDefinitions = function(text) {
-//
-// Strips link definitions from text, stores the URLs and titles in
-// hash references.
-//
-
- // Link defs are in the form: ^[id]: url "optional title"
-
- /*
- var text = text.replace(/
- ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1
- [ \t]*
- \n? // maybe *one* newline
- [ \t]*
- <?(\S+?)>? // url = $2
- [ \t]*
- \n? // maybe one newline
- [ \t]*
- (?:
- (\n*) // any lines skipped = $3 attacklab: lookbehind removed
- ["(]
- (.+?) // title = $4
- [")]
- [ \t]*
- )? // title is optional
- (?:\n+|$)
- /gm,
- function(){...});
- */
- var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,
- function (wholeMatch,m1,m2,m3,m4) {
- m1 = m1.toLowerCase();
- g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive
- if (m3) {
- // Oops, found blank lines, so it's not a title.
- // Put back the parenthetical statement we stole.
- return m3+m4;
- } else if (m4) {
- g_titles[m1] = m4.replace(/"/g,""");
- }
-
- // Completely remove the definition from the text
- return "";
- }
- );
-
- return text;
-}
-
-
-var _HashHTMLBlocks = function(text) {
- // attacklab: Double up blank lines to reduce lookaround
- text = text.replace(/\n/g,"\n\n");
-
- // Hashify HTML blocks:
- // We only want to do this for block-level HTML tags, such as headers,
- // lists, and tables. That's because we still want to wrap <p>s around
- // "paragraphs" that are wrapped in non-block-level tags, such as anchors,
- // phrase emphasis, and spans. The list of tags we're looking for is
- // hard-coded:
- var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del"
- var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math"
-
- // First, look for nested blocks, e.g.:
- // <div>
- // <div>
- // tags for inner block must be indented.
- // </div>
- // </div>
- //
- // The outermost tags must start at the left margin for this to match, and
- // the inner nested divs must be indented.
- // We need to do this before the next, more liberal match, because the next
- // match will start at the first `<div>` and stop at the first `</div>`.
-
- // attacklab: This regex can be expensive when it fails.
- /*
- var text = text.replace(/
- ( // save in $1
- ^ // start of line (with /m)
- <($block_tags_a) // start tag = $2
- \b // word break
- // attacklab: hack around khtml/pcre bug...
- [^\r]*?\n // any number of lines, minimally matching
- </\2> // the matching end tag
- [ \t]* // trailing spaces/tabs
- (?=\n+) // followed by a newline
- ) // attacklab: there are sentinel newlines at end of document
- /gm,function(){...}};
- */
- text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement);
-
- //
- // Now match more liberally, simply from `\n<tag>` to `</tag>\n`
- //
-
- /*
- var text = text.replace(/
- ( // save in $1
- ^ // start of line (with /m)
- <($block_tags_b) // start tag = $2
- \b // word break
- // attacklab: hack around khtml/pcre bug...
- [^\r]*? // any number of lines, minimally matching
- .*</\2> // the matching end tag
- [ \t]* // trailing spaces/tabs
- (?=\n+) // followed by a newline
- ) // attacklab: there are sentinel newlines at end of document
- /gm,function(){...}};
- */
- text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);
-
- // Special case just for <hr />. It was easier to make a special case than
- // to make the other regex more complicated.
-
- /*
- text = text.replace(/
- ( // save in $1
- \n\n // Starting after a blank line
- [ ]{0,3}
- (<(hr) // start tag = $2
- \b // word break
- ([^<>])*? //
- \/?>) // the matching end tag
- [ \t]*
- (?=\n{2,}) // followed by a blank line
- )
- /g,hashElement);
- */
- text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement);
-
- // Special case for standalone HTML comments:
-
- /*
- text = text.replace(/
- ( // save in $1
- \n\n // Starting after a blank line
- [ ]{0,3} // attacklab: g_tab_width - 1
- <!
- (--[^\r]*?--\s*)+
- >
- [ \t]*
- (?=\n{2,}) // followed by a blank line
- )
- /g,hashElement);
- */
- text = text.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,hashElement);
-
- // PHP and ASP-style processor instructions (<?...?> and <%...%>)
-
- /*
- text = text.replace(/
- (?:
- \n\n // Starting after a blank line
- )
- ( // save in $1
- [ ]{0,3} // attacklab: g_tab_width - 1
- (?:
- <([?%]) // $2
- [^\r]*?
- \2>
- )
- [ \t]*
- (?=\n{2,}) // followed by a blank line
- )
- /g,hashElement);
- */
- text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement);
-
- // attacklab: Undo double lines (see comment at top of this function)
- text = text.replace(/\n\n/g,"\n");
- return text;
-}
-
-var hashElement = function(wholeMatch,m1) {
- var blockText = m1;
-
- // Undo double lines
- blockText = blockText.replace(/\n\n/g,"\n");
- blockText = blockText.replace(/^\n/,"");
-
- // strip trailing blank lines
- blockText = blockText.replace(/\n+$/g,"");
-
- // Replace the element text with a marker ("~KxK" where x is its key)
- blockText = "\n\n~K" + (g_html_blocks.push(blockText)-1) + "K\n\n";
-
- return blockText;
-};
-
-var _RunBlockGamut = function(text) {
-//
-// These are all the transformations that form block-level
-// tags like paragraphs, headers, and list items.
-//
- text = _DoHeaders(text);
-
- // Do Horizontal Rules:
- var key = hashBlock("<hr />");
- text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key);
- text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key);
- text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
-
- text = _DoLists(text);
- text = _DoCodeBlocks(text);
- text = _DoBlockQuotes(text);
-
- // We already ran _HashHTMLBlocks() before, in Markdown(), but that
- // was to escape raw HTML in the original Markdown source. This time,
- // we're escaping the markup we've just created, so that we don't wrap
- // <p> tags around block-level tags.
- text = _HashHTMLBlocks(text);
- text = _FormParagraphs(text);
-
- return text;
-}
-
-
-var _RunSpanGamut = function(text) {
-//
-// These are all the transformations that occur *within* block-level
-// tags like paragraphs, headers, and list items.
-//
-
- text = _DoCodeSpans(text);
- text = _EscapeSpecialCharsWithinTagAttributes(text);
- text = _EncodeBackslashEscapes(text);
-
- // Process anchor and image tags. Images must come first,
- // because ![foo][f] looks like an anchor.
- text = _DoImages(text);
- text = _DoAnchors(text);
-
- // Make links out of things like `<http://example.com/>`
- // Must come after _DoAnchors(), because you can use < and >
- // delimiters in inline links like [this](<url>).
- text = _DoAutoLinks(text);
- text = _EncodeAmpsAndAngles(text);
- text = _DoItalicsAndBold(text);
-
- // Do hard breaks:
- text = text.replace(/ +\n/g," <br />\n");
-
- return text;
-}
-
-var _EscapeSpecialCharsWithinTagAttributes = function(text) {
-//
-// Within tags -- meaning between < and > -- encode [\ ` * _] so they
-// don't conflict with their use in Markdown for code, italics and strong.
-//
-
- // Build a regex to find HTML tags and comments. See Friedl's
- // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
- var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;
-
- text = text.replace(regex, function(wholeMatch) {
- var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`");
- tag = escapeCharacters(tag,"\\`*_");
- return tag;
- });
-
- return text;
-}
-
-var _DoAnchors = function(text) {
-//
-// Turn Markdown link shortcuts into XHTML <a> tags.
-//
- //
- // First, handle reference-style links: [link text] [id]
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- (
- (?:
- \[[^\]]*\] // allow brackets nested one level
- |
- [^\[] // or anything else
- )*
- )
- \]
-
- [ ]? // one optional space
- (?:\n[ ]*)? // one optional newline followed by spaces
-
- \[
- (.*?) // id = $3
- \]
- )()()()() // pad remaining backreferences
- /g,_DoAnchors_callback);
- */
- text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag);
-
- //
- // Next, inline-style links: [link text](url "optional title")
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- (
- (?:
- \[[^\]]*\] // allow brackets nested one level
- |
- [^\[\]] // or anything else
- )
- )
- \]
- \( // literal paren
- [ \t]*
- () // no id, so leave $3 empty
- <?(.*?)>? // href = $4
- [ \t]*
- ( // $5
- (['"]) // quote char = $6
- (.*?) // Title = $7
- \6 // matching quote
- [ \t]* // ignore any spaces/tabs between closing quote and )
- )? // title is optional
- \)
- )
- /g,writeAnchorTag);
- */
- text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag);
-
- //
- // Last, handle reference-style shortcuts: [link text]
- // These must come last in case you've also got [link test][1]
- // or [link test](/foo)
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- ([^\[\]]+) // link text = $2; can't contain '[' or ']'
- \]
- )()()()()() // pad rest of backreferences
- /g, writeAnchorTag);
- */
- text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
-
- return text;
-}
-
-var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
- if (m7 == undefined) m7 = "";
- var whole_match = m1;
- var link_text = m2;
- var link_id = m3.toLowerCase();
- var url = m4;
- var title = m7;
-
- if (url == "") {
- if (link_id == "") {
- // lower-case and turn embedded newlines into spaces
- link_id = link_text.toLowerCase().replace(/ ?\n/g," ");
- }
- url = "#"+link_id;
-
- if (g_urls[link_id] != undefined) {
- url = g_urls[link_id];
- if (g_titles[link_id] != undefined) {
- title = g_titles[link_id];
- }
- }
- else {
- if (whole_match.search(/\(\s*\)$/m)>-1) {
- // Special case for explicit empty url
- url = "";
- } else {
- return whole_match;
- }
- }
- }
-
- url = escapeCharacters(url,"*_");
- var result = "<a href=\"" + url + "\"";
-
- if (title != "") {
- title = title.replace(/"/g,""");
- title = escapeCharacters(title,"*_");
- result += " title=\"" + title + "\"";
- }
-
- result += ">" + link_text + "</a>";
-
- return result;
-}
-
-
-var _DoImages = function(text) {
-//
-// Turn Markdown image shortcuts into <img> tags.
-//
-
- //
- // First, handle reference-style labeled images: ![alt text][id]
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- !\[
- (.*?) // alt text = $2
- \]
-
- [ ]? // one optional space
- (?:\n[ ]*)? // one optional newline followed by spaces
-
- \[
- (.*?) // id = $3
- \]
- )()()()() // pad rest of backreferences
- /g,writeImageTag);
- */
- text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag);
-
- //
- // Next, handle inline images: 
- // Don't forget: encode * and _
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- !\[
- (.*?) // alt text = $2
- \]
- \s? // One optional whitespace character
- \( // literal paren
- [ \t]*
- () // no id, so leave $3 empty
- <?(\S+?)>? // src url = $4
- [ \t]*
- ( // $5
- (['"]) // quote char = $6
- (.*?) // title = $7
- \6 // matching quote
- [ \t]*
- )? // title is optional
- \)
- )
- /g,writeImageTag);
- */
- text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag);
-
- return text;
-}
-
-var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
- var whole_match = m1;
- var alt_text = m2;
- var link_id = m3.toLowerCase();
- var url = m4;
- var title = m7;
-
- if (!title) title = "";
-
- if (url == "") {
- if (link_id == "") {
- // lower-case and turn embedded newlines into spaces
- link_id = alt_text.toLowerCase().replace(/ ?\n/g," ");
- }
- url = "#"+link_id;
-
- if (g_urls[link_id] != undefined) {
- url = g_urls[link_id];
- if (g_titles[link_id] != undefined) {
- title = g_titles[link_id];
- }
- }
- else {
- return whole_match;
- }
- }
-
- alt_text = alt_text.replace(/"/g,""");
- url = escapeCharacters(url,"*_");
- var result = "<img src=\"" + url + "\" alt=\"" + alt_text + "\"";
-
- // attacklab: Markdown.pl adds empty title attributes to images.
- // Replicate this bug.
-
- //if (title != "") {
- title = title.replace(/"/g,""");
- title = escapeCharacters(title,"*_");
- result += " title=\"" + title + "\"";
- //}
-
- result += " />";
-
- return result;
-}
-
-
-var _DoHeaders = function(text) {
-
- // Setext-style headers:
- // Header 1
- // ========
- //
- // Header 2
- // --------
- //
- text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,
- function(wholeMatch,m1){return hashBlock('<h1 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h1>");});
-
- text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,
- function(matchFound,m1){return hashBlock('<h2 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h2>");});
-
- // atx-style headers:
- // # Header 1
- // ## Header 2
- // ## Header 2 with closing hashes ##
- // ...
- // ###### Header 6
- //
-
- /*
- text = text.replace(/
- ^(\#{1,6}) // $1 = string of #'s
- [ \t]*
- (.+?) // $2 = Header text
- [ \t]*
- \#* // optional closing #'s (not counted)
- \n+
- /gm, function() {...});
- */
-
- text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
- function(wholeMatch,m1,m2) {
- var h_level = m1.length;
- return hashBlock("<h" + h_level + ' id="' + headerId(m2) + '">' + _RunSpanGamut(m2) + "</h" + h_level + ">");
- });
-
- function headerId(m) {
- return m.replace(/[^\w]/g, '').toLowerCase();
- }
- return text;
-}
-
-// This declaration keeps Dojo compressor from outputting garbage:
-var _ProcessListItems;
-
-var _DoLists = function(text) {
-//
-// Form HTML ordered (numbered) and unordered (bulleted) lists.
-//
-
- // attacklab: add sentinel to hack around khtml/safari bug:
- // http://bugs.webkit.org/show_bug.cgi?id=11231
- text += "~0";
-
- // Re-usable pattern to match any entirel ul or ol list:
-
- /*
- var whole_list = /
- ( // $1 = whole list
- ( // $2
- [ ]{0,3} // attacklab: g_tab_width - 1
- ([*+-]|\d+[.]) // $3 = first list item marker
- [ \t]+
- )
- [^\r]+?
- ( // $4
- ~0 // sentinel for workaround; should be $
- |
- \n{2,}
- (?=\S)
- (?! // Negative lookahead for another list item marker
- [ \t]*
- (?:[*+-]|\d+[.])[ \t]+
- )
- )
- )/g
- */
- var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
-
- if (g_list_level) {
- text = text.replace(whole_list,function(wholeMatch,m1,m2) {
- var list = m1;
- var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol";
-
- // Turn double returns into triple returns, so that we can make a
- // paragraph for the last item in a list, if necessary:
- list = list.replace(/\n{2,}/g,"\n\n\n");;
- var result = _ProcessListItems(list);
-
- // Trim any trailing whitespace, to put the closing `</$list_type>`
- // up on the preceding line, to get it past the current stupid
- // HTML block parser. This is a hack to work around the terrible
- // hack that is the HTML block parser.
- result = result.replace(/\s+$/,"");
- result = "<"+list_type+">" + result + "</"+list_type+">\n";
- return result;
- });
- } else {
- whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
- text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) {
- var runup = m1;
- var list = m2;
-
- var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol";
- // Turn double returns into triple returns, so that we can make a
- // paragraph for the last item in a list, if necessary:
- var list = list.replace(/\n{2,}/g,"\n\n\n");;
- var result = _ProcessListItems(list);
- result = runup + "<"+list_type+">\n" + result + "</"+list_type+">\n";
- return result;
- });
- }
-
- // attacklab: strip sentinel
- text = text.replace(/~0/,"");
-
- return text;
-}
-
-_ProcessListItems = function(list_str) {
-//
-// Process the contents of a single ordered or unordered list, splitting it
-// into individual list items.
-//
- // The $g_list_level global keeps track of when we're inside a list.
- // Each time we enter a list, we increment it; when we leave a list,
- // we decrement. If it's zero, we're not in a list anymore.
- //
- // We do this because when we're not inside a list, we want to treat
- // something like this:
- //
- // I recommend upgrading to version
- // 8. Oops, now this line is treated
- // as a sub-list.
- //
- // As a single paragraph, despite the fact that the second line starts
- // with a digit-period-space sequence.
- //
- // Whereas when we're inside a list (or sub-list), that line will be
- // treated as the start of a sub-list. What a kludge, huh? This is
- // an aspect of Markdown's syntax that's hard to parse perfectly
- // without resorting to mind-reading. Perhaps the solution is to
- // change the syntax rules such that sub-lists must start with a
- // starting cardinal number; e.g. "1." or "a.".
-
- g_list_level++;
-
- // trim trailing blank lines:
- list_str = list_str.replace(/\n{2,}$/,"\n");
-
- // attacklab: add sentinel to emulate \z
- list_str += "~0";
-
- /*
- list_str = list_str.replace(/
- (\n)? // leading line = $1
- (^[ \t]*) // leading whitespace = $2
- ([*+-]|\d+[.]) [ \t]+ // list marker = $3
- ([^\r]+? // list item text = $4
- (\n{1,2}))
- (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+))
- /gm, function(){...});
- */
- list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
- function(wholeMatch,m1,m2,m3,m4){
- var item = m4;
- var leading_line = m1;
- var leading_space = m2;
-
- if (leading_line || (item.search(/\n{2,}/)>-1)) {
- item = _RunBlockGamut(_Outdent(item));
- }
- else {
- // Recursion for sub-lists:
- item = _DoLists(_Outdent(item));
- item = item.replace(/\n$/,""); // chomp(item)
- item = _RunSpanGamut(item);
- }
-
- return "<li>" + item + "</li>\n";
- }
- );
-
- // attacklab: strip sentinel
- list_str = list_str.replace(/~0/g,"");
-
- g_list_level--;
- return list_str;
-}
-
-
-var _DoCodeBlocks = function(text) {
-//
-// Process Markdown `<pre><code>` blocks.
-//
-
- /*
- text = text.replace(text,
- /(?:\n\n|^)
- ( // $1 = the code block -- one or more lines, starting with a space/tab
- (?:
- (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
- .*\n+
- )+
- )
- (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
- /g,function(){...});
- */
-
- // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
- text += "~0";
-
- text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
- function(wholeMatch,m1,m2) {
- var codeblock = m1;
- var nextChar = m2;
-
- codeblock = _EncodeCode( _Outdent(codeblock));
- codeblock = _Detab(codeblock);
- codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
- codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
-
- codeblock = "<pre><code>" + codeblock + "\n</code></pre>";
-
- return hashBlock(codeblock) + nextChar;
- }
- );
-
- // attacklab: strip sentinel
- text = text.replace(/~0/,"");
-
- return text;
-}
-
-var hashBlock = function(text) {
- text = text.replace(/(^\n+|\n+$)/g,"");
- return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n";
-}
-
-
-var _DoCodeSpans = function(text) {
-//
-// * Backtick quotes are used for <code></code> spans.
-//
-// * You can use multiple backticks as the delimiters if you want to
-// include literal backticks in the code span. So, this input:
-//
-// Just type ``foo `bar` baz`` at the prompt.
-//
-// Will translate to:
-//
-// <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
-//
-// There's no arbitrary limit to the number of backticks you
-// can use as delimters. If you need three consecutive backticks
-// in your code, use four for delimiters, etc.
-//
-// * You can use spaces to get literal backticks at the edges:
-//
-// ... type `` `bar` `` ...
-//
-// Turns to:
-//
-// ... type <code>`bar`</code> ...
-//
-
- /*
- text = text.replace(/
- (^|[^\\]) // Character before opening ` can't be a backslash
- (`+) // $2 = Opening run of `
- ( // $3 = The code block
- [^\r]*?
- [^`] // attacklab: work around lack of lookbehind
- )
- \2 // Matching closer
- (?!`)
- /gm, function(){...});
- */
-
- text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
- function(wholeMatch,m1,m2,m3,m4) {
- var c = m3;
- c = c.replace(/^([ \t]*)/g,""); // leading whitespace
- c = c.replace(/[ \t]*$/g,""); // trailing whitespace
- c = _EncodeCode(c);
- return m1+"<code>"+c+"</code>";
- });
-
- return text;
-}
-
-
-var _EncodeCode = function(text) {
-//
-// Encode/escape certain characters inside Markdown code runs.
-// The point is that in code, these characters are literals,
-// and lose their special Markdown meanings.
-//
- // Encode all ampersands; HTML entities are not
- // entities within a Markdown code span.
- text = text.replace(/&/g,"&");
-
- // Do the angle bracket song and dance:
- text = text.replace(/</g,"<");
- text = text.replace(/>/g,">");
-
- // Now, escape characters that are magic in Markdown:
- text = escapeCharacters(text,"\*_{}[]\\",false);
-
-// jj the line above breaks this:
-//---
-
-//* Item
-
-// 1. Subitem
-
-// special char: *
-//---
-
- return text;
-}
-
-
-var _DoItalicsAndBold = function(text) {
-
- // <strong> must go first:
- text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
- "<strong>$2</strong>");
-
- text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,
- "<em>$2</em>");
-
- return text;
-}
-
-
-var _DoBlockQuotes = function(text) {
-
- /*
- text = text.replace(/
- ( // Wrap whole match in $1
- (
- ^[ \t]*>[ \t]? // '>' at the start of a line
- .+\n // rest of the first line
- (.+\n)* // subsequent consecutive lines
- \n* // blanks
- )+
- )
- /gm, function(){...});
- */
-
- text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
- function(wholeMatch,m1) {
- var bq = m1;
-
- // attacklab: hack around Konqueror 3.5.4 bug:
- // "----------bug".replace(/^-/g,"") == "bug"
-
- bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting
-
- // attacklab: clean up hack
- bq = bq.replace(/~0/g,"");
-
- bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines
- bq = _RunBlockGamut(bq); // recurse
-
- bq = bq.replace(/(^|\n)/g,"$1 ");
- // These leading spaces screw with <pre> content, so we need to fix that:
- bq = bq.replace(
- /(\s*<pre>[^\r]+?<\/pre>)/gm,
- function(wholeMatch,m1) {
- var pre = m1;
- // attacklab: hack around Konqueror 3.5.4 bug:
- pre = pre.replace(/^ /mg,"~0");
- pre = pre.replace(/~0/g,"");
- return pre;
- });
-
- return hashBlock("<blockquote>\n" + bq + "\n</blockquote>");
- });
- return text;
-}
-
-
-var _FormParagraphs = function(text) {
-//
-// Params:
-// $text - string to process with html <p> tags
-//
-
- // Strip leading and trailing lines:
- text = text.replace(/^\n+/g,"");
- text = text.replace(/\n+$/g,"");
-
- var grafs = text.split(/\n{2,}/g);
- var grafsOut = new Array();
-
- //
- // Wrap <p> tags.
- //
- var end = grafs.length;
- for (var i=0; i<end; i++) {
- var str = grafs[i];
-
- // if this is an HTML marker, copy it
- if (str.search(/~K(\d+)K/g) >= 0) {
- grafsOut.push(str);
- }
- else if (str.search(/\S/) >= 0) {
- str = _RunSpanGamut(str);
- str = str.replace(/^([ \t]*)/g,"<p>");
- str += "</p>"
- grafsOut.push(str);
- }
-
- }
-
- //
- // Unhashify HTML blocks
- //
- end = grafsOut.length;
- for (var i=0; i<end; i++) {
- // if this is a marker for an html block...
- while (grafsOut[i].search(/~K(\d+)K/) >= 0) {
- var blockText = g_html_blocks[RegExp.$1];
- blockText = blockText.replace(/\$/g,"$$$$"); // Escape any dollar signs
- grafsOut[i] = grafsOut[i].replace(/~K\d+K/,blockText);
- }
- }
-
- return grafsOut.join("\n\n");
-}
-
-
-var _EncodeAmpsAndAngles = function(text) {
-// Smart processing for ampersands and angle brackets that need to be encoded.
-
- // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
- // http://bumppo.net/projects/amputator/
- text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&");
-
- // Encode naked <'s
- text = text.replace(/<(?![a-z\/?\$!])/gi,"<");
-
- return text;
-}
-
-
-var _EncodeBackslashEscapes = function(text) {
-//
-// Parameter: String.
-// Returns: The string, with after processing the following backslash
-// escape sequences.
-//
-
- // attacklab: The polite way to do this is with the new
- // escapeCharacters() function:
- //
- // text = escapeCharacters(text,"\\",true);
- // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
- //
- // ...but we're sidestepping its use of the (slow) RegExp constructor
- // as an optimization for Firefox. This function gets called a LOT.
-
- text = text.replace(/\\(\\)/g,escapeCharacters_callback);
- text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback);
- return text;
-}
-
-
-var _DoAutoLinks = function(text) {
-
- text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"<a href=\"$1\">$1</a>");
-
- // Email addresses: <ad...@domain.foo>
-
- /*
- text = text.replace(/
- <
- (?:mailto:)?
- (
- [-.\w]+
- \@
- [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
- )
- >
- /gi, _DoAutoLinks_callback());
- */
- text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
- function(wholeMatch,m1) {
- return _EncodeEmailAddress( _UnescapeSpecialChars(m1) );
- }
- );
-
- return text;
-}
-
-
-var _EncodeEmailAddress = function(addr) {
-//
-// Input: an email address, e.g. "foo@example.com"
-//
-// Output: the email address as a mailto link, with each character
-// of the address encoded as either a decimal or hex entity, in
-// the hopes of foiling most address harvesting spam bots. E.g.:
-//
-// <a href="mailto:foo@e
-// xample.com">foo
-// @example.com</a>
-//
-// Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
-// mailing list: <http://tinyurl.com/yu7ue>
-//
-
- // attacklab: why can't javascript speak hex?
- function char2hex(ch) {
- var hexDigits = '0123456789ABCDEF';
- var dec = ch.charCodeAt(0);
- return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15));
- }
-
- var encode = [
- function(ch){return "&#"+ch.charCodeAt(0)+";";},
- function(ch){return "&#x"+char2hex(ch)+";";},
- function(ch){return ch;}
- ];
-
- addr = "mailto:" + addr;
-
- addr = addr.replace(/./g, function(ch) {
- if (ch == "@") {
- // this *must* be encoded. I insist.
- ch = encode[Math.floor(Math.random()*2)](ch);
- } else if (ch !=":") {
- // leave ':' alone (to spot mailto: later)
- var r = Math.random();
- // roughly 10% raw, 45% hex, 45% dec
- ch = (
- r > .9 ? encode[2](ch) :
- r > .45 ? encode[1](ch) :
- encode[0](ch)
- );
- }
- return ch;
- });
-
- addr = "<a href=\"" + addr + "\">" + addr + "</a>";
- addr = addr.replace(/">.+:/g,"\">"); // strip the mailto: from the visible part
-
- return addr;
-}
-
-
-var _UnescapeSpecialChars = function(text) {
-//
-// Swap back in all the special characters we've hidden.
-//
- text = text.replace(/~E(\d+)E/g,
- function(wholeMatch,m1) {
- var charCodeToReplace = parseInt(m1);
- return String.fromCharCode(charCodeToReplace);
- }
- );
- return text;
-}
-
-
-var _Outdent = function(text) {
-//
-// Remove one level of line-leading tabs or spaces
-//
-
- // attacklab: hack around Konqueror 3.5.4 bug:
- // "----------bug".replace(/^-/g,"") == "bug"
-
- text = text.replace(/^(\t|[ ]{1,4})/gm,"~0"); // attacklab: g_tab_width
-
- // attacklab: clean up hack
- text = text.replace(/~0/g,"")
-
- return text;
-}
-
-var _Detab = function(text) {
-// attacklab: Detab's completely rewritten for speed.
-// In perl we could fix it by anchoring the regexp with \G.
-// In javascript we're less fortunate.
-
- // expand first n-1 tabs
- text = text.replace(/\t(?=\t)/g," "); // attacklab: g_tab_width
-
- // replace the nth with two sentinels
- text = text.replace(/\t/g,"~A~B");
-
- // use the sentinel to anchor our regex so it doesn't explode
- text = text.replace(/~B(.+?)~A/g,
- function(wholeMatch,m1,m2) {
- var leadingText = m1;
- var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width
-
- // there *must* be a better way to do this:
- for (var i=0; i<numSpaces; i++) leadingText+=" ";
-
- return leadingText;
- }
- );
-
- // clean up sentinels
- text = text.replace(/~A/g," "); // attacklab: g_tab_width
- text = text.replace(/~B/g,"");
-
- return text;
-}
-
-
-//
-// attacklab: Utility functions
-//
-
-
-var escapeCharacters = function(text, charsToEscape, afterBackslash) {
- // First we have to escape the escape characters so that
- // we can build a character class out of them
- var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g,"\\$1") + "])";
-
- if (afterBackslash) {
- regexString = "\\\\" + regexString;
- }
-
- var regex = new RegExp(regexString,"g");
- text = text.replace(regex,escapeCharacters_callback);
-
- return text;
-}
-
-
-var escapeCharacters_callback = function(wholeMatch,m1) {
- var charCodeToEscape = m1.charCodeAt(0);
- return "~E"+charCodeToEscape+"E";
-}
-
-} // end of Showdown.converter
-
-// export
+//
+// showdown.js -- A javascript port of Markdown.
+//
+// Copyright (c) 2007 John Fraser.
+//
+// Original Markdown Copyright (c) 2004-2005 John Gruber
+// <http://daringfireball.net/projects/markdown/>
+//
+// Redistributable under a BSD-style open source license.
+// See license.txt for more information.
+//
+// The full source distribution is at:
+//
+// A A L
+// T C A
+// T K B
+//
+// <http://www.attacklab.net/>
+//
+
+//
+// Wherever possible, Showdown is a straight, line-by-line port
+// of the Perl version of Markdown.
+//
+// This is not a normal parser design; it's basically just a
+// series of string substitutions. It's hard to read and
+// maintain this way, but keeping Showdown close to the original
+// design makes it easier to port new features.
+//
+// More importantly, Showdown behaves like markdown.pl in most
+// edge cases. So web applications can do client-side preview
+// in Javascript, and then build identical HTML on the server.
+//
+// This port needs the new RegExp functionality of ECMA 262,
+// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers
+// should do fine. Even with the new regular expression features,
+// We do a lot of work to emulate Perl's regex functionality.
+// The tricky changes in this file mostly have the "attacklab:"
+// label. Major or self-explanatory changes don't.
+//
+// Smart diff tools like Araxis Merge will be able to match up
+// this file with markdown.pl in a useful way. A little tweaking
+// helps: in a copy of markdown.pl, replace "#" with "//" and
+// replace "$text" with "text". Be sure to ignore whitespace
+// and line endings.
+//
+
+
+//
+// Showdown usage:
+//
+// var text = "Markdown *rocks*.";
+//
+// var converter = new Showdown.converter();
+// var html = converter.makeHtml(text);
+//
+// alert(html);
+//
+// Note: move the sample code to the bottom of this
+// file before uncommenting it.
+//
+
+
+//
+// Showdown namespace
+//
+var Showdown = {};
+
+//
+// converter
+//
+// Wraps all "globals" so that the only thing
+// exposed is makeHtml().
+//
+Showdown.converter = function() {
+
+//
+// Globals:
+//
+
+// Global hashes, used by various utility routines
+var g_urls;
+var g_titles;
+var g_html_blocks;
+
+// Used to track when we're inside an ordered or unordered list
+// (see _ProcessListItems() for details):
+var g_list_level = 0;
+
+
+this.makeHtml = function(text) {
+//
+// Main function. The order in which other subs are called here is
+// essential. Link and image substitutions need to happen before
+// _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the <a>
+// and <img> tags get encoded.
+//
+
+ // Clear the global hashes. If we don't clear these, you get conflicts
+ // from other articles when generating a page which contains more than
+ // one article (e.g. an index page that shows the N most recent
+ // articles):
+ g_urls = new Array();
+ g_titles = new Array();
+ g_html_blocks = new Array();
+
+ // attacklab: Replace ~ with ~T
+ // This lets us use tilde as an escape char to avoid md5 hashes
+ // The choice of character is arbitray; anything that isn't
+ // magic in Markdown will work.
+ text = text.replace(/~/g,"~T");
+
+ // attacklab: Replace $ with ~D
+ // RegExp interprets $ as a special character
+ // when it's in a replacement string
+ text = text.replace(/\$/g,"~D");
+
+ // Standardize line endings
+ text = text.replace(/\r\n/g,"\n"); // DOS to Unix
+ text = text.replace(/\r/g,"\n"); // Mac to Unix
+
+ // Make sure text begins and ends with a couple of newlines:
+ text = "\n\n" + text + "\n\n";
+
+ // Convert all tabs to spaces.
+ text = _Detab(text);
+
+ // Strip any lines consisting only of spaces and tabs.
+ // This makes subsequent regexen easier to write, because we can
+ // match consecutive blank lines with /\n+/ instead of something
+ // contorted like /[ \t]*\n+/ .
+ text = text.replace(/^[ \t]+$/mg,"");
+
+ // Turn block-level HTML blocks into hash entries
+ text = _HashHTMLBlocks(text);
+
+ // Strip link definitions, store in hashes.
+ text = _StripLinkDefinitions(text);
+
+ text = _RunBlockGamut(text);
+
+ text = _UnescapeSpecialChars(text);
+
+ // attacklab: Restore dollar signs
+ text = text.replace(/~D/g,"$$");
+
+ // attacklab: Restore tildes
+ text = text.replace(/~T/g,"~");
+
+ return text;
+}
+
+
+var _StripLinkDefinitions = function(text) {
+//
+// Strips link definitions from text, stores the URLs and titles in
+// hash references.
+//
+
+ // Link defs are in the form: ^[id]: url "optional title"
+
+ /*
+ var text = text.replace(/
+ ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1
+ [ \t]*
+ \n? // maybe *one* newline
+ [ \t]*
+ <?(\S+?)>? // url = $2
+ [ \t]*
+ \n? // maybe one newline
+ [ \t]*
+ (?:
+ (\n*) // any lines skipped = $3 attacklab: lookbehind removed
+ ["(]
+ (.+?) // title = $4
+ [")]
+ [ \t]*
+ )? // title is optional
+ (?:\n+|$)
+ /gm,
+ function(){...});
+ */
+ var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,
+ function (wholeMatch,m1,m2,m3,m4) {
+ m1 = m1.toLowerCase();
+ g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive
+ if (m3) {
+ // Oops, found blank lines, so it's not a title.
+ // Put back the parenthetical statement we stole.
+ return m3+m4;
+ } else if (m4) {
+ g_titles[m1] = m4.replace(/"/g,""");
+ }
+
+ // Completely remove the definition from the text
+ return "";
+ }
+ );
+
+ return text;
+}
+
+
+var _HashHTMLBlocks = function(text) {
+ // attacklab: Double up blank lines to reduce lookaround
+ text = text.replace(/\n/g,"\n\n");
+
+ // Hashify HTML blocks:
+ // We only want to do this for block-level HTML tags, such as headers,
+ // lists, and tables. That's because we still want to wrap <p>s around
+ // "paragraphs" that are wrapped in non-block-level tags, such as anchors,
+ // phrase emphasis, and spans. The list of tags we're looking for is
+ // hard-coded:
+ var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del"
+ var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math"
+
+ // First, look for nested blocks, e.g.:
+ // <div>
+ // <div>
+ // tags for inner block must be indented.
+ // </div>
+ // </div>
+ //
+ // The outermost tags must start at the left margin for this to match, and
+ // the inner nested divs must be indented.
+ // We need to do this before the next, more liberal match, because the next
+ // match will start at the first `<div>` and stop at the first `</div>`.
+
+ // attacklab: This regex can be expensive when it fails.
+ /*
+ var text = text.replace(/
+ ( // save in $1
+ ^ // start of line (with /m)
+ <($block_tags_a) // start tag = $2
+ \b // word break
+ // attacklab: hack around khtml/pcre bug...
+ [^\r]*?\n // any number of lines, minimally matching
+ </\2> // the matching end tag
+ [ \t]* // trailing spaces/tabs
+ (?=\n+) // followed by a newline
+ ) // attacklab: there are sentinel newlines at end of document
+ /gm,function(){...}};
+ */
+ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement);
+
+ //
+ // Now match more liberally, simply from `\n<tag>` to `</tag>\n`
+ //
+
+ /*
+ var text = text.replace(/
+ ( // save in $1
+ ^ // start of line (with /m)
+ <($block_tags_b) // start tag = $2
+ \b // word break
+ // attacklab: hack around khtml/pcre bug...
+ [^\r]*? // any number of lines, minimally matching
+ .*</\2> // the matching end tag
+ [ \t]* // trailing spaces/tabs
+ (?=\n+) // followed by a newline
+ ) // attacklab: there are sentinel newlines at end of document
+ /gm,function(){...}};
+ */
+ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);
+
+ // Special case just for <hr />. It was easier to make a special case than
+ // to make the other regex more complicated.
+
+ /*
+ text = text.replace(/
+ ( // save in $1
+ \n\n // Starting after a blank line
+ [ ]{0,3}
+ (<(hr) // start tag = $2
+ \b // word break
+ ([^<>])*? //
+ \/?>) // the matching end tag
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // Special case for standalone HTML comments:
+
+ /*
+ text = text.replace(/
+ ( // save in $1
+ \n\n // Starting after a blank line
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ <!
+ (--[^\r]*?--\s*)+
+ >
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // PHP and ASP-style processor instructions (<?...?> and <%...%>)
+
+ /*
+ text = text.replace(/
+ (?:
+ \n\n // Starting after a blank line
+ )
+ ( // save in $1
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ (?:
+ <([?%]) // $2
+ [^\r]*?
+ \2>
+ )
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // attacklab: Undo double lines (see comment at top of this function)
+ text = text.replace(/\n\n/g,"\n");
+ return text;
+}
+
+var hashElement = function(wholeMatch,m1) {
+ var blockText = m1;
+
+ // Undo double lines
+ blockText = blockText.replace(/\n\n/g,"\n");
+ blockText = blockText.replace(/^\n/,"");
+
+ // strip trailing blank lines
+ blockText = blockText.replace(/\n+$/g,"");
+
+ // Replace the element text with a marker ("~KxK" where x is its key)
+ blockText = "\n\n~K" + (g_html_blocks.push(blockText)-1) + "K\n\n";
+
+ return blockText;
+};
+
+var _RunBlockGamut = function(text) {
+//
+// These are all the transformations that form block-level
+// tags like paragraphs, headers, and list items.
+//
+ text = _DoHeaders(text);
+
+ // Do Horizontal Rules:
+ var key = hashBlock("<hr />");
+ text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key);
+ text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key);
+ text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
+
+ text = _DoLists(text);
+ text = _DoCodeBlocks(text);
+ text = _DoBlockQuotes(text);
+
+ // We already ran _HashHTMLBlocks() before, in Markdown(), but that
+ // was to escape raw HTML in the original Markdown source. This time,
+ // we're escaping the markup we've just created, so that we don't wrap
+ // <p> tags around block-level tags.
+ text = _HashHTMLBlocks(text);
+ text = _FormParagraphs(text);
+
+ return text;
+}
+
+
+var _RunSpanGamut = function(text) {
+//
+// These are all the transformations that occur *within* block-level
+// tags like paragraphs, headers, and list items.
+//
+
+ text = _DoCodeSpans(text);
+ text = _EscapeSpecialCharsWithinTagAttributes(text);
+ text = _EncodeBackslashEscapes(text);
+
+ // Process anchor and image tags. Images must come first,
+ // because ![foo][f] looks like an anchor.
+ text = _DoImages(text);
+ text = _DoAnchors(text);
+
+ // Make links out of things like `<http://example.com/>`
+ // Must come after _DoAnchors(), because you can use < and >
+ // delimiters in inline links like [this](<url>).
+ text = _DoAutoLinks(text);
+ text = _EncodeAmpsAndAngles(text);
+ text = _DoItalicsAndBold(text);
+
+ // Do hard breaks:
+ text = text.replace(/ +\n/g," <br />\n");
+
+ return text;
+}
+
+var _EscapeSpecialCharsWithinTagAttributes = function(text) {
+//
+// Within tags -- meaning between < and > -- encode [\ ` * _] so they
+// don't conflict with their use in Markdown for code, italics and strong.
+//
+
+ // Build a regex to find HTML tags and comments. See Friedl's
+ // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
+ var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;
+
+ text = text.replace(regex, function(wholeMatch) {
+ var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`");
+ tag = escapeCharacters(tag,"\\`*_");
+ return tag;
+ });
+
+ return text;
+}
+
+var _DoAnchors = function(text) {
+//
+// Turn Markdown link shortcuts into XHTML <a> tags.
+//
+ //
+ // First, handle reference-style links: [link text] [id]
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ (
+ (?:
+ \[[^\]]*\] // allow brackets nested one level
+ |
+ [^\[] // or anything else
+ )*
+ )
+ \]
+
+ [ ]? // one optional space
+ (?:\n[ ]*)? // one optional newline followed by spaces
+
+ \[
+ (.*?) // id = $3
+ \]
+ )()()()() // pad remaining backreferences
+ /g,_DoAnchors_callback);
+ */
+ text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag);
+
+ //
+ // Next, inline-style links: [link text](url "optional title")
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ (
+ (?:
+ \[[^\]]*\] // allow brackets nested one level
+ |
+ [^\[\]] // or anything else
+ )
+ )
+ \]
+ \( // literal paren
+ [ \t]*
+ () // no id, so leave $3 empty
+ <?(.*?)>? // href = $4
+ [ \t]*
+ ( // $5
+ (['"]) // quote char = $6
+ (.*?) // Title = $7
+ \6 // matching quote
+ [ \t]* // ignore any spaces/tabs between closing quote and )
+ )? // title is optional
+ \)
+ )
+ /g,writeAnchorTag);
+ */
+ text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag);
+
+ //
+ // Last, handle reference-style shortcuts: [link text]
+ // These must come last in case you've also got [link test][1]
+ // or [link test](/foo)
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ ([^\[\]]+) // link text = $2; can't contain '[' or ']'
+ \]
+ )()()()()() // pad rest of backreferences
+ /g, writeAnchorTag);
+ */
+ text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
+
+ return text;
+}
+
+var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
+ if (m7 == undefined) m7 = "";
+ var whole_match = m1;
+ var link_text = m2;
+ var link_id = m3.toLowerCase();
+ var url = m4;
+ var title = m7;
+
+ if (url == "") {
+ if (link_id == "") {
+ // lower-case and turn embedded newlines into spaces
+ link_id = link_text.toLowerCase().replace(/ ?\n/g," ");
+ }
+ url = "#"+link_id;
+
+ if (g_urls[link_id] != undefined) {
+ url = g_urls[link_id];
+ if (g_titles[link_id] != undefined) {
+ title = g_titles[link_id];
+ }
+ }
+ else {
+ if (whole_match.search(/\(\s*\)$/m)>-1) {
+ // Special case for explicit empty url
+ url = "";
+ } else {
+ return whole_match;
+ }
+ }
+ }
+
+ url = escapeCharacters(url,"*_");
+ var result = "<a href=\"" + url + "\"";
+
+ if (title != "") {
+ title = title.replace(/"/g,""");
+ title = escapeCharacters(title,"*_");
+ result += " title=\"" + title + "\"";
+ }
+
+ result += ">" + link_text + "</a>";
+
+ return result;
+}
+
+
+var _DoImages = function(text) {
+//
+// Turn Markdown image shortcuts into <img> tags.
+//
+
+ //
+ // First, handle reference-style labeled images: ![alt text][id]
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ !\[
+ (.*?) // alt text = $2
+ \]
+
+ [ ]? // one optional space
+ (?:\n[ ]*)? // one optional newline followed by spaces
+
+ \[
+ (.*?) // id = $3
+ \]
+ )()()()() // pad rest of backreferences
+ /g,writeImageTag);
+ */
+ text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag);
+
+ //
+ // Next, handle inline images: 
+ // Don't forget: encode * and _
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ !\[
+ (.*?) // alt text = $2
+ \]
+ \s? // One optional whitespace character
+ \( // literal paren
+ [ \t]*
+ () // no id, so leave $3 empty
+ <?(\S+?)>? // src url = $4
+ [ \t]*
+ ( // $5
+ (['"]) // quote char = $6
+ (.*?) // title = $7
+ \6 // matching quote
+ [ \t]*
+ )? // title is optional
+ \)
+ )
+ /g,writeImageTag);
+ */
+ text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag);
+
+ return text;
+}
+
+var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
+ var whole_match = m1;
+ var alt_text = m2;
+ var link_id = m3.toLowerCase();
+ var url = m4;
+ var title = m7;
+
+ if (!title) title = "";
+
+ if (url == "") {
+ if (link_id == "") {
+ // lower-case and turn embedded newlines into spaces
+ link_id = alt_text.toLowerCase().replace(/ ?\n/g," ");
+ }
+ url = "#"+link_id;
+
+ if (g_urls[link_id] != undefined) {
+ url = g_urls[link_id];
+ if (g_titles[link_id] != undefined) {
+ title = g_titles[link_id];
+ }
+ }
+ else {
+ return whole_match;
+ }
+ }
+
+ alt_text = alt_text.replace(/"/g,""");
+ url = escapeCharacters(url,"*_");
+ var result = "<img src=\"" + url + "\" alt=\"" + alt_text + "\"";
+
+ // attacklab: Markdown.pl adds empty title attributes to images.
+ // Replicate this bug.
+
+ //if (title != "") {
+ title = title.replace(/"/g,""");
+ title = escapeCharacters(title,"*_");
+ result += " title=\"" + title + "\"";
+ //}
+
+ result += " />";
+
+ return result;
+}
+
+
+var _DoHeaders = function(text) {
+
+ // Setext-style headers:
+ // Header 1
+ // ========
+ //
+ // Header 2
+ // --------
+ //
+ text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,
+ function(wholeMatch,m1){return hashBlock('<h1 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h1>");});
+
+ text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,
+ function(matchFound,m1){return hashBlock('<h2 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h2>");});
+
+ // atx-style headers:
+ // # Header 1
+ // ## Header 2
+ // ## Header 2 with closing hashes ##
+ // ...
+ // ###### Header 6
+ //
+
+ /*
+ text = text.replace(/
+ ^(\#{1,6}) // $1 = string of #'s
+ [ \t]*
+ (.+?) // $2 = Header text
+ [ \t]*
+ \#* // optional closing #'s (not counted)
+ \n+
+ /gm, function() {...});
+ */
+
+ text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
+ function(wholeMatch,m1,m2) {
+ var h_level = m1.length;
+ return hashBlock("<h" + h_level + ' id="' + headerId(m2) + '">' + _RunSpanGamut(m2) + "</h" + h_level + ">");
+ });
+
+ function headerId(m) {
+ return m.replace(/[^\w]/g, '').toLowerCase();
+ }
+ return text;
+}
+
+// This declaration keeps Dojo compressor from outputting garbage:
+var _ProcessListItems;
+
+var _DoLists = function(text) {
+//
+// Form HTML ordered (numbered) and unordered (bulleted) lists.
+//
+
+ // attacklab: add sentinel to hack around khtml/safari bug:
+ // http://bugs.webkit.org/show_bug.cgi?id=11231
+ text += "~0";
+
+ // Re-usable pattern to match any entirel ul or ol list:
+
+ /*
+ var whole_list = /
+ ( // $1 = whole list
+ ( // $2
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ ([*+-]|\d+[.]) // $3 = first list item marker
+ [ \t]+
+ )
+ [^\r]+?
+ ( // $4
+ ~0 // sentinel for workaround; should be $
+ |
+ \n{2,}
+ (?=\S)
+ (?! // Negative lookahead for another list item marker
+ [ \t]*
+ (?:[*+-]|\d+[.])[ \t]+
+ )
+ )
+ )/g
+ */
+ var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
+
+ if (g_list_level) {
+ text = text.replace(whole_list,function(wholeMatch,m1,m2) {
+ var list = m1;
+ var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol";
+
+ // Turn double returns into triple returns, so that we can make a
+ // paragraph for the last item in a list, if necessary:
+ list = list.replace(/\n{2,}/g,"\n\n\n");;
+ var result = _ProcessListItems(list);
+
+ // Trim any trailing whitespace, to put the closing `</$list_type>`
+ // up on the preceding line, to get it past the current stupid
+ // HTML block parser. This is a hack to work around the terrible
+ // hack that is the HTML block parser.
+ result = result.replace(/\s+$/,"");
+ result = "<"+list_type+">" + result + "</"+list_type+">\n";
+ return result;
+ });
+ } else {
+ whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
+ text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) {
+ var runup = m1;
+ var list = m2;
+
+ var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol";
+ // Turn double returns into triple returns, so that we can make a
+ // paragraph for the last item in a list, if necessary:
+ var list = list.replace(/\n{2,}/g,"\n\n\n");;
+ var result = _ProcessListItems(list);
+ result = runup + "<"+list_type+">\n" + result + "</"+list_type+">\n";
+ return result;
+ });
+ }
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/,"");
+
+ return text;
+}
+
+_ProcessListItems = function(list_str) {
+//
+// Process the contents of a single ordered or unordered list, splitting it
+// into individual list items.
+//
+ // The $g_list_level global keeps track of when we're inside a list.
+ // Each time we enter a list, we increment it; when we leave a list,
+ // we decrement. If it's zero, we're not in a list anymore.
+ //
+ // We do this because when we're not inside a list, we want to treat
+ // something like this:
+ //
+ // I recommend upgrading to version
+ // 8. Oops, now this line is treated
+ // as a sub-list.
+ //
+ // As a single paragraph, despite the fact that the second line starts
+ // with a digit-period-space sequence.
+ //
+ // Whereas when we're inside a list (or sub-list), that line will be
+ // treated as the start of a sub-list. What a kludge, huh? This is
+ // an aspect of Markdown's syntax that's hard to parse perfectly
+ // without resorting to mind-reading. Perhaps the solution is to
+ // change the syntax rules such that sub-lists must start with a
+ // starting cardinal number; e.g. "1." or "a.".
+
+ g_list_level++;
+
+ // trim trailing blank lines:
+ list_str = list_str.replace(/\n{2,}$/,"\n");
+
+ // attacklab: add sentinel to emulate \z
+ list_str += "~0";
+
+ /*
+ list_str = list_str.replace(/
+ (\n)? // leading line = $1
+ (^[ \t]*) // leading whitespace = $2
+ ([*+-]|\d+[.]) [ \t]+ // list marker = $3
+ ([^\r]+? // list item text = $4
+ (\n{1,2}))
+ (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+))
+ /gm, function(){...});
+ */
+ list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
+ function(wholeMatch,m1,m2,m3,m4){
+ var item = m4;
+ var leading_line = m1;
+ var leading_space = m2;
+
+ if (leading_line || (item.search(/\n{2,}/)>-1)) {
+ item = _RunBlockGamut(_Outdent(item));
+ }
+ else {
+ // Recursion for sub-lists:
+ item = _DoLists(_Outdent(item));
+ item = item.replace(/\n$/,""); // chomp(item)
+ item = _RunSpanGamut(item);
+ }
+
+ return "<li>" + item + "</li>\n";
+ }
+ );
+
+ // attacklab: strip sentinel
+ list_str = list_str.replace(/~0/g,"");
+
+ g_list_level--;
+ return list_str;
+}
+
+
+var _DoCodeBlocks = function(text) {
+//
+// Process Markdown `<pre><code>` blocks.
+//
+
+ /*
+ text = text.replace(text,
+ /(?:\n\n|^)
+ ( // $1 = the code block -- one or more lines, starting with a space/tab
+ (?:
+ (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
+ .*\n+
+ )+
+ )
+ (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
+ /g,function(){...});
+ */
+
+ // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
+ text += "~0";
+
+ text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
+ function(wholeMatch,m1,m2) {
+ var codeblock = m1;
+ var nextChar = m2;
+
+ codeblock = _EncodeCode( _Outdent(codeblock));
+ codeblock = _Detab(codeblock);
+ codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
+ codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
+
+ codeblock = "<pre><code>" + codeblock + "\n</code></pre>";
+
+ return hashBlock(codeblock) + nextChar;
+ }
+ );
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/,"");
+
+ return text;
+}
+
+var hashBlock = function(text) {
+ text = text.replace(/(^\n+|\n+$)/g,"");
+ return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n";
+}
+
+
+var _DoCodeSpans = function(text) {
+//
+// * Backtick quotes are used for <code></code> spans.
+//
+// * You can use multiple backticks as the delimiters if you want to
+// include literal backticks in the code span. So, this input:
+//
+// Just type ``foo `bar` baz`` at the prompt.
+//
+// Will translate to:
+//
+// <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
+//
+// There's no arbitrary limit to the number of backticks you
+// can use as delimters. If you need three consecutive backticks
+// in your code, use four for delimiters, etc.
+//
+// * You can use spaces to get literal backticks at the edges:
+//
+// ... type `` `bar` `` ...
+//
+// Turns to:
+//
+// ... type <code>`bar`</code> ...
+//
+
+ /*
+ text = text.replace(/
+ (^|[^\\]) // Character before opening ` can't be a backslash
+ (`+) // $2 = Opening run of `
+ ( // $3 = The code block
+ [^\r]*?
+ [^`] // attacklab: work around lack of lookbehind
+ )
+ \2 // Matching closer
+ (?!`)
+ /gm, function(){...});
+ */
+
+ text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
+ function(wholeMatch,m1,m2,m3,m4) {
+ var c = m3;
+ c = c.replace(/^([ \t]*)/g,""); // leading whitespace
+ c = c.replace(/[ \t]*$/g,""); // trailing whitespace
+ c = _EncodeCode(c);
+ return m1+"<code>"+c+"</code>";
+ });
+
+ return text;
+}
+
+
+var _EncodeCode = function(text) {
+//
+// Encode/escape certain characters inside Markdown code runs.
+// The point is that in code, these characters are literals,
+// and lose their special Markdown meanings.
+//
+ // Encode all ampersands; HTML entities are not
+ // entities within a Markdown code span.
+ text = text.replace(/&/g,"&");
+
+ // Do the angle bracket song and dance:
+ text = text.replace(/</g,"<");
+ text = text.replace(/>/g,">");
+
+ // Now, escape characters that are magic in Markdown:
+ text = escapeCharacters(text,"\*_{}[]\\",false);
+
+// jj the line above breaks this:
+//---
+
+//* Item
+
+// 1. Subitem
+
+// special char: *
+//---
+
+ return text;
+}
+
+
+var _DoItalicsAndBold = function(text) {
+
+ // <strong> must go first:
+ text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
+ "<strong>$2</strong>");
+
+ text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,
+ "<em>$2</em>");
+
+ return text;
+}
+
+
+var _DoBlockQuotes = function(text) {
+
+ /*
+ text = text.replace(/
+ ( // Wrap whole match in $1
+ (
+ ^[ \t]*>[ \t]? // '>' at the start of a line
+ .+\n // rest of the first line
+ (.+\n)* // subsequent consecutive lines
+ \n* // blanks
+ )+
+ )
+ /gm, function(){...});
+ */
+
+ text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
+ function(wholeMatch,m1) {
+ var bq = m1;
+
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ // "----------bug".replace(/^-/g,"") == "bug"
+
+ bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting
+
+ // attacklab: clean up hack
+ bq = bq.replace(/~0/g,"");
+
+ bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines
+ bq = _RunBlockGamut(bq); // recurse
+
+ bq = bq.replace(/(^|\n)/g,"$1 ");
+ // These leading spaces screw with <pre> content, so we need to fix that:
+ bq = bq.replace(
+ /(\s*<pre>[^\r]+?<\/pre>)/gm,
+ function(wholeMatch,m1) {
+ var pre = m1;
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ pre = pre.replace(/^ /mg,"~0");
+ pre = pre.replace(/~0/g,"");
+ return pre;
+ });
+
+ return hashBlock("<blockquote>\n" + bq + "\n</blockquote>");
+ });
+ return text;
+}
+
+
+var _FormParagraphs = function(text) {
+//
+// Params:
+// $text - string to process with html <p> tags
+//
+
+ // Strip leading and trailing lines:
+ text = text.replace(/^\n+/g,"");
+ text = text.replace(/\n+$/g,"");
+
+ var grafs = text.split(/\n{2,}/g);
+ var grafsOut = new Array();
+
+ //
+ // Wrap <p> tags.
+ //
+ var end = grafs.length;
+ for (var i=0; i<end; i++) {
+ var str = grafs[i];
+
+ // if this is an HTML marker, copy it
+ if (str.search(/~K(\d+)K/g) >= 0) {
+ grafsOut.push(str);
+ }
+ else if (str.search(/\S/) >= 0) {
+ str = _RunSpanGamut(str);
+ str = str.replace(/^([ \t]*)/g,"<p>");
+ str += "</p>"
+ grafsOut.push(str);
+ }
+
+ }
+
+ //
+ // Unhashify HTML blocks
+ //
+ end = grafsOut.length;
+ for (var i=0; i<end; i++) {
+ // if this is a marker for an html block...
+ while (grafsOut[i].search(/~K(\d+)K/) >= 0) {
+ var blockText = g_html_blocks[RegExp.$1];
+ blockText = blockText.replace(/\$/g,"$$$$"); // Escape any dollar signs
+ grafsOut[i] = grafsOut[i].replace(/~K\d+K/,blockText);
+ }
+ }
+
+ return grafsOut.join("\n\n");
+}
+
+
+var _EncodeAmpsAndAngles = function(text) {
+// Smart processing for ampersands and angle brackets that need to be encoded.
+
+ // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
+ // http://bumppo.net/projects/amputator/
+ text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&");
+
+ // Encode naked <'s
+ text = text.replace(/<(?![a-z\/?\$!])/gi,"<");
+
+ return text;
+}
+
+
+var _EncodeBackslashEscapes = function(text) {
+//
+// Parameter: String.
+// Returns: The string, with after processing the following backslash
+// escape sequences.
+//
+
+ // attacklab: The polite way to do this is with the new
+ // escapeCharacters() function:
+ //
+ // text = escapeCharacters(text,"\\",true);
+ // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
+ //
+ // ...but we're sidestepping its use of the (slow) RegExp constructor
+ // as an optimization for Firefox. This function gets called a LOT.
+
+ text = text.replace(/\\(\\)/g,escapeCharacters_callback);
+ text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback);
+ return text;
+}
+
+
+var _DoAutoLinks = function(text) {
+
+ text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"<a href=\"$1\">$1</a>");
+
+ // Email addresses: <ad...@domain.foo>
+
+ /*
+ text = text.replace(/
+ <
+ (?:mailto:)?
+ (
+ [-.\w]+
+ \@
+ [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
+ )
+ >
+ /gi, _DoAutoLinks_callback());
+ */
+ text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
+ function(wholeMatch,m1) {
+ return _EncodeEmailAddress( _UnescapeSpecialChars(m1) );
+ }
+ );
+
+ return text;
+}
+
+
+var _EncodeEmailAddress = function(addr) {
+//
+// Input: an email address, e.g. "foo@example.com"
+//
+// Output: the email address as a mailto link, with each character
+// of the address encoded as either a decimal or hex entity, in
+// the hopes of foiling most address harvesting spam bots. E.g.:
+//
+// <a href="mailto:foo@e
+// xample.com">foo
+// @example.com</a>
+//
+// Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
+// mailing list: <http://tinyurl.com/yu7ue>
+//
+
+ // attacklab: why can't javascript speak hex?
+ function char2hex(ch) {
+ var hexDigits = '0123456789ABCDEF';
+ var dec = ch.charCodeAt(0);
+ return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15));
+ }
+
+ var encode = [
+ function(ch){return "&#"+ch.charCodeAt(0)+";";},
+ function(ch){return "&#x"+char2hex(ch)+";";},
+ function(ch){return ch;}
+ ];
+
+ addr = "mailto:" + addr;
+
+ addr = addr.replace(/./g, function(ch) {
+ if (ch == "@") {
+ // this *must* be encoded. I insist.
+ ch = encode[Math.floor(Math.random()*2)](ch);
+ } else if (ch !=":") {
+ // leave ':' alone (to spot mailto: later)
+ var r = Math.random();
+ // roughly 10% raw, 45% hex, 45% dec
+ ch = (
+ r > .9 ? encode[2](ch) :
+ r > .45 ? encode[1](ch) :
+ encode[0](ch)
+ );
+ }
+ return ch;
+ });
+
+ addr = "<a href=\"" + addr + "\">" + addr + "</a>";
+ addr = addr.replace(/">.+:/g,"\">"); // strip the mailto: from the visible part
+
+ return addr;
+}
+
+
+var _UnescapeSpecialChars = function(text) {
+//
+// Swap back in all the special characters we've hidden.
+//
+ text = text.replace(/~E(\d+)E/g,
+ function(wholeMatch,m1) {
+ var charCodeToReplace = parseInt(m1);
+ return String.fromCharCode(charCodeToReplace);
+ }
+ );
+ return text;
+}
+
+
+var _Outdent = function(text) {
+//
+// Remove one level of line-leading tabs or spaces
+//
+
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ // "----------bug".replace(/^-/g,"") == "bug"
+
+ text = text.replace(/^(\t|[ ]{1,4})/gm,"~0"); // attacklab: g_tab_width
+
+ // attacklab: clean up hack
+ text = text.replace(/~0/g,"")
+
+ return text;
+}
+
+var _Detab = function(text) {
+// attacklab: Detab's completely rewritten for speed.
+// In perl we could fix it by anchoring the regexp with \G.
+// In javascript we're less fortunate.
+
+ // expand first n-1 tabs
+ text = text.replace(/\t(?=\t)/g," "); // attacklab: g_tab_width
+
+ // replace the nth with two sentinels
+ text = text.replace(/\t/g,"~A~B");
+
+ // use the sentinel to anchor our regex so it doesn't explode
+ text = text.replace(/~B(.+?)~A/g,
+ function(wholeMatch,m1,m2) {
+ var leadingText = m1;
+ var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width
+
+ // there *must* be a better way to do this:
+ for (var i=0; i<numSpaces; i++) leadingText+=" ";
+
+ return leadingText;
+ }
+ );
+
+ // clean up sentinels
+ text = text.replace(/~A/g," "); // attacklab: g_tab_width
+ text = text.replace(/~B/g,"");
+
+ return text;
+}
+
+
+//
+// attacklab: Utility functions
+//
+
+
+var escapeCharacters = function(text, charsToEscape, afterBackslash) {
+ // First we have to escape the escape characters so that
+ // we can build a character class out of them
+ var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g,"\\$1") + "])";
+
+ if (afterBackslash) {
+ regexString = "\\\\" + regexString;
+ }
+
+ var regex = new RegExp(regexString,"g");
+ text = text.replace(regex,escapeCharacters_callback);
+
+ return text;
+}
+
+
+var escapeCharacters_callback = function(wholeMatch,m1) {
+ var charCodeToEscape = m1.charCodeAt(0);
+ return "~E"+charCodeToEscape+"E";
+}
+
+} // end of Showdown.converter
+
+// export
if (typeof exports != 'undefined') exports.Showdown = Showdown;
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org