Files @ bf5c2c75c976
Branch filter:

Location: kallithea/rhodecode/public/js/mode/meta_ext.js - annotation

Marcin Kuzminski
fixes issue #856 file upload >1000 bytes on windows throws exception.

The returned object is a true file object on POSIX platforms.
On other platforms, it is a file-like object whose `file` attribute is the
underlying true file object. We check if such object has a file attribute
which is missing on POSIX platform
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
35fcc232f652
MIME_TO_EXT = {
    'application/javascript': ['*.js'],
    'text/javascript': ['*.js'],
    'application/json': ['*.json'],
    'application/postscript': ['*.ps', '*.eps'],
    'application/x-actionscript': ['*.as'],
    'application/x-actionscript3': ['*.as'],
    'application/x-awk': ['*.awk'],
    'application/x-befunge': ['*.befunge'],
    'application/x-brainfuck': ['*.bf', '*.b'],
    'application/x-cheetah': ['*.tmpl', '*.spt'],
    'application/x-coldfusion': ['*.cfm', '*.cfml', '*.cfc'],
    'application/x-csh': ['*.tcsh', '*.csh'],
    'application/x-dos-batch': ['*.bat', '*.cmd'],
    'application/x-ecl': ['*.ecl'],
    'application/x-evoque': ['*.evoque'],
    'application/x-fantom': ['*.fan'],
    'application/x-genshi': ['*.kid'],
    'application/x-gettext': ['*.pot', '*.po'],
    'application/x-jsp': ['*.jsp'],
    'application/x-mako': ['*.mao'],
    'application/x-mason': ['*.m', '*.mhtml', '*.mc', '*.mi', 'autohandler', 'dhandler'],
    'application/x-myghty': ['*.myt', 'autodelegate'],
    'application/x-php': ['*.phtml'],
    'application/x-pypylog': ['*.pypylog'],
    'application/x-qml': ['*.qml'],
    'application/x-sh': ['*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass', '.bashrc', 'bashrc', '.bash_*', 'bash_*'],
    'application/x-sh-session': ['*.shell-session'],
    'application/x-shell-session': ['*.sh-session'],
    'application/x-smarty': ['*.tpl'],
    'application/x-ssp': ['*.ssp'],
    'application/x-troff': ['*.[1234567]', '*.man'],
    'application/x-urbiscript': ['*.u'],
    'application/xml+evoque': ['*.xml'],
    'application/xml-dtd': ['*.dtd'],
    'application/xsl+xml': ['*.xsl', '*.xslt', '*.xpl'],
    'text/S-plus': ['*.S', '*.R', '.Rhistory', '.Rprofile'],
    'text/coffeescript': ['*.coffee'],
    'text/css': ['*.css'],
    'text/haxe': ['*.hx'],
    'text/html': ['*.html', '*.htm', '*.xhtml', '*.xslt'],
    'text/html+evoque': ['*.html'],
    'text/html+ruby': ['*.rhtml'],
    'text/idl': ['*.pro'],
    'text/livescript': ['*.ls'],
    'text/matlab': ['*.m'],
    'text/octave': ['*.m'],
    'text/plain': ['*.txt'],
    'text/scilab': ['*.sci', '*.sce', '*.tst'],
    'text/smali': ['*.smali'],
    'text/x-abap': ['*.abap'],
    'text/x-ada': ['*.adb', '*.ads', '*.ada'],
    'text/x-apacheconf': ['.htaccess', 'apache.conf', 'apache2.conf'],
    'text/x-aspectj': ['*.aj'],
    'text/x-asymptote': ['*.asy'],
    'text/x-autohotkey': ['*.ahk', '*.ahkl'],
    'text/x-autoit': ['*.au3'],
    'text/x-bmx': ['*.bmx'],
    'text/x-boo': ['*.boo'],
    'text/x-c++hdr': ['*.cpp', '*.hpp', '*.c++', '*.h++', '*.cc', '*.hh', '*.cxx', '*.hxx', '*.C', '*.H', '*.cp','*.CPP'],
    'text/x-c-objdump': ['*.c-objdump'],
    'text/x-ceylon': ['*.ceylon'],
    'text/x-chdr': ['*.c', '*.h', '*.idc'],
    'text/x-clojure': ['*.clj'],
    'text/x-cmake': ['*.cmake', 'CMakeLists.txt'],
    'text/x-cobol': ['*.cob', '*.COB', '*.cpy', '*.CPY'],
    'text/x-common-lisp': ['*.cl', '*.lisp', '*.el'],
    'text/x-coq': ['*.v'],
    'text/x-cpp-objdump': ['*.cpp-objdump', '*.c++-objdump', '*.cxx-objdump'],
    'text/x-crocsrc': ['*.croc'],
    'text/x-csharp': ['*.cs'],
    'text/x-cuda': ['*.cu', '*.cuh'],
    'text/x-cython': ['*.pyx', '*.pxd', '*.pxi'],
    'text/x-d-objdump': ['*.d-objdump'],
    'text/x-dart': ['*.dart'],
    'text/x-dg': ['*.dg'],
    'text/x-diff': ['*.diff', '*.patch'],
    'text/x-dsrc': ['*.d', '*.di'],
    'text/x-duel': ['*.duel', '*.jbst'],
    'text/x-dylan': ['*.dylan', '*.dyl', '*.intr'],
    'text/x-dylan-console': ['*.dylan-console'],
    'text/x-dylan-lid': ['*.lid', '*.hdp'],
    'text/x-echdr': ['*.ec', '*.eh'],
    'text/x-elixir': ['*.ex', '*.exs'],
    'text/x-erl-shellsession': ['*.erl-sh'],
    'text/x-erlang': ['*.erl', '*.hrl', '*.es', '*.escript'],
    'text/x-factor': ['*.factor'],
    'text/x-fancysrc': ['*.fy', '*.fancypack'],
    'text/x-felix': ['*.flx', '*.flxh'],
    'text/x-fortran': ['*.f', '*.f90', '*.F', '*.F90'],
    'text/x-fsharp': ['*.fs', '*.fsi'],
    'text/x-gas': ['*.s', '*.S'],
    'text/x-gherkin': ['*.feature'],
    'text/x-glslsrc': ['*.vert', '*.frag', '*.geo'],
    'text/x-gnuplot': ['*.plot', '*.plt'],
    'text/x-gooddata-cl': ['*.gdc'],
    'text/x-gooddata-maql': ['*.maql'],
    'text/x-gosrc': ['*.go'],
    'text/x-gosu': ['*.gs', '*.gsx', '*.gsp', '*.vark'],
    'text/x-gosu-template': ['*.gst'],
    'text/x-groovy': ['*.groovy'],
    'text/x-haml': ['*.haml'],
    'text/x-haskell': ['*.hs'],
    'text/x-hybris': ['*.hy', '*.hyb'],
    'text/x-ini': ['*.ini', '*.cfg'],
    'text/x-iokesrc': ['*.ik'],
    'text/x-iosrc': ['*.io'],
    'text/x-irclog': ['*.weechatlog'],
    'text/x-jade': ['*.jade'],
    'text/x-java': ['*.java'],
    'text/x-java-properties': ['*.properties'],
    'text/x-julia': ['*.jl'],
    'text/x-kconfig': ['Kconfig', '*Config.in*', 'external.in*', 'standard-modules.in'],
    'text/x-koka': ['*.kk', '*.kki'],
    'text/x-kotlin': ['*.kt'],
    'text/x-lasso': ['*.lasso', '*.lasso[89]'],
    'text/x-literate-haskell': ['*.lhs'],
    'text/x-llvm': ['*.ll'],
    'text/x-logos': ['*.x', '*.xi', '*.xm', '*.xmi'],
    'text/x-logtalk': ['*.lgt'],
    'text/x-lua': ['*.lua', '*.wlua'],
    'text/x-makefile': ['*.mak', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile'],
    'text/x-minidsrc': ['*.md'],
    'text/x-markdown': ['*.md'],
    'text/x-modelica': ['*.mo'],
    'text/x-modula2': ['*.def', '*.mod'],
    'text/x-monkey': ['*.monkey'],
    'text/x-moocode': ['*.moo'],
    'text/x-moonscript': ['*.moon'],
    'text/x-nasm': ['*.asm', '*.ASM'],
    'text/x-nemerle': ['*.n'],
    'text/x-newlisp': ['*.lsp', '*.nl'],
    'text/x-newspeak': ['*.ns2'],
    'text/x-nimrod': ['*.nim', '*.nimrod'],
    'text/x-nsis': ['*.nsi', '*.nsh'],
    'text/x-objdump': ['*.objdump'],
    'text/x-objective-c': ['*.m', '*.h'],
    'text/x-objective-c++': ['*.mm', '*.hh'],
    'text/x-objective-j': ['*.j'],
    'text/x-ocaml': ['*.ml', '*.mli', '*.mll', '*.mly'],
    'text/x-ooc': ['*.ooc'],
    'text/x-opa': ['*.opa'],
    'text/x-openedge': ['*.p', '*.cls'],
    'text/x-pascal': ['*.pas'],
    'text/x-perl': ['*.pl', '*.pm'],
    'text/x-php': ['*.php', '*.php[345]', '*.inc'],
    'text/x-povray': ['*.pov', '*.inc'],
    'text/x-powershell': ['*.ps1'],
    'text/x-prolog': ['*.prolog', '*.pro', '*.pl'],
    'text/x-python': ['*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac', '*.sage'],
    'text/x-python-traceback': ['*.pytb'],
    'text/x-python3-traceback': ['*.py3tb'],
    'text/x-r-doc': ['*.Rd'],
    'text/x-racket': ['*.rkt', '*.rktl'],
    'text/x-rebol': ['*.r', '*.r3'],
    'text/x-robotframework': ['*.txt', '*.robot'],
    'text/x-rpm-spec': ['*.spec'],
    'text/x-rst': ['*.rst', '*.rest'],
    'text/x-ruby': ['*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec', '*.rbx', '*.duby'],
    'text/x-rustsrc': ['*.rs', '*.rc'],
    'text/x-sass': ['*.sass'],
    'text/x-scala': ['*.scala'],
    'text/x-scaml': ['*.scaml'],
    'text/x-scheme': ['*.scm', '*.ss'],
    'text/x-scss': ['*.scss'],
    'text/x-smalltalk': ['*.st'],
    'text/x-snobol': ['*.snobol'],
    'text/x-sourcepawn': ['*.sp'],
    'text/x-sql': ['*.sql'],
    'text/x-sqlite3-console': ['*.sqlite3-console'],
    'text/x-squidconf': ['squid.conf'],
    'text/x-standardml': ['*.sml', '*.sig', '*.fun'],
    'text/x-systemverilog': ['*.sv', '*.svh'],
    'text/x-tcl': ['*.tcl'],
    'text/x-tea': ['*.tea'],
    'text/x-tex': ['*.tex', '*.aux', '*.toc'],
    'text/x-typescript': ['*.ts'],
    'text/x-vala': ['*.vala', '*.vapi'],
    'text/x-vbnet': ['*.vb', '*.bas'],
    'text/x-verilog': ['*.v'],
    'text/x-vhdl': ['*.vhdl', '*.vhd'],
    'text/x-vim': ['*.vim', '.vimrc', '.exrc', '.gvimrc', '_vimrc', '_exrc', '_gvimrc', 'vimrc', 'gvimrc'],
    'text/x-windows-registry': ['*.reg'],
    'text/x-xtend': ['*.xtend'],
    'text/x-yaml': ['*.yaml', '*.yml'],
    'text/xml': ['*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl'],
    'text/xquery': ['*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm'],
    'text/apl': [],
    'text/x-asterisk': [],
    'text/x-csrc': [],
    'text/x-c++src': ['*.cpp'],
    'text/x-coffeescript': ['*.coffee'],
    'text/x-d': ["*.d"],
    'text/x-ecl': ['*.ecl'],
    'text/x-go': ['*.go'],
    'text/x-haxe': ['*.hx'],
    'application/x-aspx': ['*.aspx'],
    'application/x-ejs': [],
    'message/http': [],
    'application/x-json': ['*.json'],
    'application/typescript': ['*.ts'],
    'jinja2': ['.jinja2'],
    'text/x-less': ['*.less'],
    'text/x-livescript': ['*.ls'],
    'text/mirc': [],
    'text/n-triples': [],
    'application/x-httpd-php': ['*.php'],
    'text/x-pig': [],
    'text/x-properties': ['*.properties'],
    'text/x-rsrc': [],
    'text/x-sh': ['*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass', '.bashrc', 'bashrc', '.bash_*', 'bash_*'],
    'application/sieve': [],
    'text/x-stsrc': ['*.rs', '*.rc'],
    'text/x-smarty': ['*.tpl'],
    'application/x-sparql-query': [],
    'text/x-mariadb': ['*.sql'],
    'text/x-stex': [],
    'text/x-latex': ["*.ltx"],
    'text/x-tiddlywiki': [],
    'text/tiki': [],
    'text/x-vb': ['*.vb'],
    'text/vbscript': ['*.vb'],
    'text/velocity': [],
    'application/xml': ['*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl'],
    'application/xquery': ['*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm'],
    'text/x-z80': [],
}