Commit graph

1964 commits

Author SHA1 Message Date
Tim Starling b5c36bad59 Debug console module
* Added a debug console to the edit page, allowing unsaved modules to be
  tested.
* Removed the "preview" button from the edit page.
* Only show the "ignore code errors" checkbox on module edit pages, not
  all edit pages.
* Added Lua function mw.log() for sending messages to the debug log.

Change-Id: Ia51f439e573a1deb5b83f94ddd1a86792d5569c1
2012-07-14 14:35:55 +10:00
Translation updater bot 16e9eba133 Localisation updates from http://translatewiki.net.
Change-Id: I8fe56aa5b3c7825b20c4e33e2874c543f101124d
2012-07-11 20:00:33 +00:00
Tim Starling a6a3678bf3 expandTemplate() nonexistent title error
(bug 37324) Raise an error instead of returning nil when the specified
template does not exist.

Change-Id: Idd52c0cb9431cfeb7db73ca2692365aa121c49ab
2012-07-09 13:23:31 +10:00
Tim Starling 54af4fc79e (bug 37315) Run UTF-8 normalization on script results
Change-Id: I9b9fdb0391145560d85e64f6afdc5bfbd5093cf2
2012-07-09 13:12:54 +10:00
Translation updater bot fb8b86931c Localisation updates from http://translatewiki.net.
Change-Id: I7cdd8c5430ef08faa82a689d08e618f81462ef79
2012-07-08 19:23:09 +00:00
Translation updater bot 751ea278ff Localisation updates from http://translatewiki.net.
Change-Id: I1f7b8dd6267b5afddf8b31955838a4bf208a8901
2012-07-06 21:20:43 +00:00
Translation updater bot c248cccf5c Localisation updates from http://translatewiki.net.
Change-Id: I63e22a36016c7436c886c52776242a2ab935f9db
2012-07-05 19:46:15 +00:00
Translation updater bot d86dcb0b70 Localisation updates from http://translatewiki.net.
Change-Id: I103eabfb4d3e45f50573f0088208861697a4f31d
2012-07-04 20:09:43 +00:00
Translation updater bot dfa09541e5 Localisation updates from http://translatewiki.net.
Change-Id: I579f7efb14104f4d5bb37a7b6aff67b22babae9d
2012-07-03 20:57:37 +00:00
Tim Starling be8f6ca34d Allow users to ignore parse errors
Allow users to save a module with a parse error in it, by checking an
"ignore error" box. This was a requested feature in Berlin, there was a
desire to be able to save incomplete drafts of modules. I tested the
effect of #invoking a module with a parse error in it, it shows a normal
script error.

Change-Id: If2978a226ac50150ebeb7837e8dd370a669db771
2012-07-03 13:02:03 +10:00
Tim Starling c45034b250 Give a helpful error message if frame methods are called incorrectly
Change-Id: Iae1ed064eb540122c89f0e93f20e76569ec3d1fe
2012-07-03 13:02:03 +10:00
Translation updater bot c161d29775 Localisation updates from http://translatewiki.net.
Change-Id: Ia5f61acba06fa80990010972c02e7b3201fe3615
2012-07-02 22:15:05 +00:00
Translation updater bot 986f8cbaed Localisation updates from http://translatewiki.net.
Change-Id: I85b3eb670a7b3c00752e263950b62aa951f01b1b
2012-07-02 22:01:26 +00:00
Siebrand Mazeland 844cf4e73e Add file header.
Change-Id: I4dc3ee7b4533a5b86baf023a798f9fe584f13497
2012-07-02 23:41:14 +02:00
Derk-Jan Hartman 253e36fff5 Don't use php shorttags, because not everyone has them enabled.
Change-Id: Ia6c992d32af25932fd3d91c970058849f1766e9e
2012-07-02 23:15:26 +02:00
Translation updater bot 9080ece112 Localisation updates from http://translatewiki.net.
Change-Id: I5ffed16964243ae072dc609e305e2f1bf5389e70
2012-07-01 14:14:36 +00:00
Translation updater bot 82d2d88ab0 Localisation updates from http://translatewiki.net.
Change-Id: If376578dc926e6aaef83b282b2ae7b442d1c1f75
2012-06-30 11:37:45 +00:00
Tim Starling 30dee55eeb Merge "Add a Mac OS X (Lion) lua binary. Compiled for 32 and 64bit. Used automatically on Darwin systems" 2012-06-29 07:19:39 +00:00
Translation updater bot 35df9011f5 Localisation updates from http://translatewiki.net.
Change-Id: I869017bb695c52f6f16f984905372832c3200716
2012-06-28 19:49:07 +00:00
Translation updater bot 825f7937e3 Localisation updates from http://translatewiki.net.
Change-Id: I64c06ba75a61a835ee4874b69836d980800bd21f
2012-06-25 20:18:25 +00:00
Translation updater bot 47091cecdb $COMMITMSG
Change-Id: I13c67d45b89d5ef291dcf4d0203a8898e1434704
2012-06-23 20:14:39 +00:00
Translation updater bot f845c6b62e Localisation updates from http://translatewiki.net.
Change-Id: Ia66a84181cd2f033a53a130249655f6a4f47d182
2012-06-21 20:26:01 +00:00
Aaron Schulz b355b95019 Merge "Some bits of documentation" 2012-06-20 22:54:55 +00:00
Reedy 5afbf6a7c7 Some bits of documentation
Left a FIXME

Remove some unused variables

Change-Id: If733608416e68de6afe1e8f6edd4ed78a119979e
2012-06-20 23:54:21 +01:00
Translation updater bot 751d517ace Localisation updates from http://translatewiki.net.
Change-Id: If439bc218cffd8082cee790ef588ea40122a6dcd
2012-06-20 20:26:59 +00:00
Translation updater bot 10028eb8ba Localisation updates from http://translatewiki.net.
Change-Id: I3a323120699e8128a2d6903267e1589261745a33
2012-06-19 19:29:49 +00:00
Siebrand Mazeland d97b59395a Update punctuation and casing for error messages.
Change-Id: I97f7732010ebfebcf494ac9e308275b34dbb9609
2012-06-19 16:49:49 +02:00
Translation updater bot 3fd6deea93 Localisation updates from http://translatewiki.net.
Change-Id: I4bae79625c97fd7ac55e9ea7b1f6acdabc2a6494
2012-06-17 20:33:18 +00:00
Translation updater bot f66392bdde Localisation updates from http://translatewiki.net.
Change-Id: I689c625516880fe23738a046e74a930888e68503
2012-06-15 22:06:10 +00:00
Derk-Jan Hartman 32831ec56e Add a Mac OS X (Lion) lua binary. Compiled for 32 and 64bit.
Used automatically on Darwin systems

Change-Id: Ie4f4d2a2ad3b7d62ae3daea66318ce3947c7fc0e
2012-06-06 23:01:48 +02:00
Victor Vasiliev 02385f0bf7 Update credits.
Change-Id: I5321a306eb877e8445ef538d02db9c9d9539556c
2012-06-01 19:09:13 +02:00
Tim Starling 441943bd9b Do not allow access to setfenv() and getfenv() by default
Optionally remove setfenv and getfenv from the global environment in
which user code runs. This will improve the forwards-compatibility of
user code with Lua 5.2.

Porting to Lua 5.2 would still be a daunting project, of questionable
value, but at least only the internal code would need updating, and not
thousands of on-wiki modules. Compared to the environment changes, the
rest of the Lua 5.2 changes are relatively easy to simulate for
backwards compatibility.

Removed module() from the package module, since it depends on setfenv().
The native version of it is deprecated in Lua 5.2 for that reason.

Change-Id: I978903ca98943ac941833da13fe5027949f6b429
2012-05-31 15:02:04 +02:00
Tim Starling 886c6ae06d Don't open multiple error dialogs
If a Scribunto error dialog is open and the user clicks another error,
or the same error again, don't open another dialog window, instead close
the old one and reuse it.

Change-Id: I50b8d48ee551cfb8cb4e1e672a0e36e15b5ae216
2012-05-26 16:00:05 +04:00
Victor Vasiliev 8fcaa128ac Merge "New parser interface" 2012-05-26 11:42:40 +00:00
Tim Starling 6964cb1ded Don't throw an exception when you save a module page
Fix for 14e8d5d: EditFilter has a $section parameter, EditFilterMerged
doesn't. So if you try to just change the hook without changing the hook
function definition, you get "expected reference, value given" for
parameter 4, which is escalated to an exception.

Change-Id: Ibedff799472285802c43feff6f3cb078e9bfb73c
2012-05-24 04:50:35 -07:00
Tim Starling 6bc11ff615 New parser interface
* Implemented the new parser interface based on a frame object, as
  described in the design document and wikitech-l.
* Added parser tests for the new interface.
* Removed {{script:}} parser function
* Allow named parameters to {{#invoke:}}
* Don't trim the return value
* If a function invoked by #invoke returns multiple values, concatenate
  them into a single string.
* If there is an error during parse, show the error message as an HTML
  comment as well as via JavaScript. This makes parser test construction
  easier, and probably makes debugging easier also.
* Rename mw_internal to mw_php to clarify its role. It is now strictly a
  private Lua -> PHP interface function table.
* Protect mw.setup() against multiple invocation.
* Fixed a bug in Scribunto_LuaStandaloneInterpreter::receiveMessage():
  large packets caused fread() to return with less than the requested
  amount of data, which previously caused an exception. It's necessary
  to check for EOF and to repeat the read to get all data. The receive
  function on the Lua side does not suffer from this problem.
* In the standalone engine, fixed a bug in the interpretation of null
  return values from PHP callbacks. This should return no values to Lua.
* Updated the Lua unit tests to account for the fact that functions are
  now forced to return strings.
* Updated the getfenv and setfenv tests to account for the extra stack
  level introduced by mw.executeFunction().

Change-Id: If8fdecdfc91ebe7bd4b1dae8489ccbdeb6bbf5ce
2012-05-22 14:18:49 +10:00
Reedy 9584ae2016 Add .gitignore
Change-Id: I9e989ba6c579f2098abd99764798cf180edaf864
2012-05-21 01:44:42 +01:00
Catrope 14e8d5d714 Use EditFilterMerged instead of EditFilter
The former is guaranteed to operate on the full wikitext. There should
probably never be sections in a Lua page anyway, but I'm paranoid

Change-Id: I0e19e60029a20112f42ebd087afd6a90fe210b3d
2012-05-09 21:02:46 -07:00
Tim Starling c9c0aa6fce Peak memory usage, debug.traceback
* Use LuaSandbox::getPeakMemoryUsage() from r115086
* Fixed the debug.traceback function from da06273e, was nil

Change-Id: Iae4b195ffe25a522d4c37f9c8341e1d6ea3ae106
2012-04-30 16:37:41 +10:00
Tim Starling 35cc7c4630 Added CPU usage to limit report
Also changed scribunto-lua-in-function-at to not say "anonymous" since
it also applies to functions which are not anonymous as declared, only
anonymous as called.

Change-Id: Ib99cc6d12fbb40a295e1fda35ac48bcf097fdb66
2012-04-30 16:37:41 +10:00
Victor Vasiliev f311f8bc96 Minor code cleanup.
* Remove an unused message.
* Remove an unused skin reference which caused notices.

Change-Id: I5d051f3a04da089e1789fd785a80c91b5be9a340
2012-04-29 18:26:04 +04:00
Tim Starling fa6dd44957 LuaSandbox backtraces
* Updates for the LuaSandbox backtrace feature introduced in r115020.
* Fixed a notice in the case where the backtrace is not available
* Implemented error message parsing for file/line as in LuaStandalone

Change-Id: Ie1e053784e174aa53ebf5a1fa782d3cf6243c3f0
2012-04-24 20:40:40 +10:00
Tim Starling 41b93dd7e1 Fixed setfenv() across a tail call
Fixed the issue noticed during testing of da06273e, and which resulted
in satest.setfenv1() being disabled. It's not possible to protect
environments by iterating through every stack level, calling getfenv()
at each one, because if any of the stack levels is a tail call, an error
is raised.

Such a tail call was introduced in da06273e, which is why the test broke.

Instead, just protect the actual specified environments, not their
callers. The callers will have to protect themselves.

Change-Id: If39104010ff2663c1bae5105cc8d37e276532100
2012-04-24 12:33:06 +10:00
Victor Vasiliev 606aaf30ac Fix Windows support:
* Improve OS detection
* Provide workaround for a proc_open bug.

Change-Id: I02b56cf2af1613406f7175a4ca053adb9d794bdd
2012-04-24 04:47:53 +04:00
Tim Starling da06273ede Nicer errors with backtraces etc.
* Added error backtrace collection to MWServer:handleCall()
* When there is an error on parse, show a short and simple inline error
  message to the user, which when clicked, expands to a full error with
  HTML-formatted backtrace.
* When an error is encountered during module validation, have the code
  editor jump directly to the line. Requires r115011.
* Expose the code location of most errors to Scribunto, by parsing the
  standard error message format.
* During module validation, abbreviate the error location if the error
  is in the same module.
* Do not execute the module during validation, just parse it. Execution
  does not really work without an active parse operation in progress.
  It already caused a fatal error if you called require() from the main
  chunk, and problems would have become more visible as more
  parser-related APIs were added.
* LuaSandbox does not yet provide backtraces, but this is planned.

Change-Id: Id9f6564a41b310792b3fe3ebb527cbf8f8771bd1
2012-04-23 21:58:30 +10:00
tstarling b68cae904a More tests and some related bug fixes
* Added tests for the engine classes.
* Added some tests that run under Lua.
* In the chunk names, fixed truncation of module names at 60 bytes
  by using an "=" prefix instead of @.
* Fixed a bug in mw.clone() which was causing the metatable to be set on
  the source table instead of the destination.
* Put restricted setfenv/getfenv in the cloned environment rather than
  the base environment, they work better that way.
* In setfenv(), check for getfenv() == nil, since that's what our own
  restricted getfenv returns.
* Fixed getfenv() handling of numeric arguments: add one where
  appropriate.

Change-Id: I2b356fd65a3fcb348c4e99a3a4267408fb995739
2012-04-19 17:48:20 +10:00
tstarling cebe775ee8 Added more Lua environment features
Package library:

* Added a simulation of the Lua 5.1 package library.
* Removed mw.import(), replaced it with a package loader. Packages can be
  retrieved from the wiki, using require('Module:Foo'), or from files
  distributed with Scribunto, using require('foo'). The "Module:" prefix allows
  for source compatibility with existing Lua code.
* Added a couple of libraries from LuaForge: luabit and stringtools.
* Made fetchModuleFromParser() return null on error instead of throwing an
  exception, to more easily support the desired behaviour of the package loader,
  which needs to return null on error.
* Renamed mw.setupEnvironment() to mw.setup() since it is setting up things
  other than the environment now.
* In MWServer:handleRegisterLibrary(), remove the feature which interprets dots
  in library names, since LuaSandbox doesn't support this.

Improved module isolation and related refactoring:

* Expose restricted versions of getfenv() and setfenv() to user Lua code.
  Requires luasandbox r114952.
* Don't cache the export list returned by module execution for later function
  calls. This breaks isolation of #invoke calls, since the local variables are
  persistent.
* Removed ScribuntoFunctionBase and its children, since it doesn't really have
  a purpose if it can't cache anything. Instead, invoke functions using a module
  method called invoke().
* Removed Module::initialize(), replaced it with a validate() function. This is
  a more elegant interface and works better with the new module caching scheme.
* Use a Status object for the return value of Engine::validate() instead of an
  array. Use the formatting facilities of the Status class.

Other:

* Removed "too many returns" error, doesn't fit in with Lua conventions.
* Use the standalone engine by default, so that the extension will work without
  configuration for more people.
* Added an accessor for $engine->interpreter
* Fix mw.clone() to correctly clone metatables
* If the standalone interpreter exits due to an error, there are some contexts
  where the initial error will be caught and ignored, and the user will see the
  error from checkValid() instead. In this case, rethrow the original error for
  a more informative message.
* Load mw.lua into the initial standalone environment, to reduce code
  duplication between mw.lua and MWServer.lua.
* Fixed a bug in Scribunto_LuaStandaloneInterpreter::handleCall() for functions
  that return no results.
* Fixed a bug in encodeLuaVar() for strings with "\r". Added test case.
* In MWServer.lua, don't call error() for internal errors, instead just print
  the error and exit. This avoids a protocol violation when an error is
  encountered from within handleCall().
* Added lots of documentation. Lua doc comments are in LuaDoc format.

Change-Id: Ie2fd572c362bedf02f45d3fa5352a5280e034740
2012-04-18 13:46:18 +10:00
tstarling 889f4e42a5 Allow PHP functions to return multiple values to Lua
Corresponding luasandbox commit is r114920.

Change-Id: I10fe726795623e2976c9ddadaa4d9b6d44b30bed
2012-04-16 15:43:34 +10:00
tstarling 16d132312f Remove old check for luasandbox extension
Change-Id: I08594015ce044d7fab129b8bbbef2a92382f6870
2012-04-16 15:06:06 +10:00
tstarling b0f00103e2 Added tests and fixed bugs
* Added unit tests for the two Lua interpreter classes
* Fixed a bug in checkType()
* Have Scribunto_LuaSandboxInterpreter throw an exception on construct
  when the extension doesn't exist, to match the standalone behaviour.
* In Scribunto_LuaSandboxInterpreter, removed debugging statements
  accidentally left in.
* Convert LuaSandboxTimeoutError to the appropriate common error
  message.
* Moved the option munging from the sandbox engine to the interpreter,
  so that the interpreter can be unit tested separately.
* Use /bin/sh instead of bash for lua_ulimit.sh, since dash is smaller
  and still supports ulimit.
* Use exec to run the lua binary, so that the vsize of the shell doesn't
  add to the memory limit.
* Added a quit function to the standalone interpreter. Unused at present.
* Don't add a comma after the last element of a table in a Lua
  expression.
* Make the SIGXCPU detection work: proc_open() runs the command via a
  shell, which reports signals in the child via the exit status, so
  proc_get_status() will never return a valid termsig element.
* In MWServer:call(), fixed a bug causing the return values to be
  wrapped in an array.
* Fixed a misunderstanding of what select() does.
* In MWServer:getStatus(), fixed indexes so that vsize will be correct.
  Removed RSS, since it wasn't used anyway and turns out to be measured
  in multiples of the page size, and I couldn't be bothered trying to
  fetch that from getconf. Return the PID and vsize as numbers rather
  than strings.
* Added a simple table dump feature to MWServer:debug().
* Fixed brackets in MWServer:tostring().
* Added missing Linux 32-bit binary.

Change-Id: Ibf5f4656b1c0a9f81287d363184c3fe9d2abdafd
2012-04-16 14:41:08 +10:00