Skip to content
Branch: master
Commits on Feb 5, 2019
  1. Stop URLs from including session IDs, making cookies always required

    jonjensen committed Feb 5, 2019
    Scratch mv_no_session doesn't actually do anything, so remove it.
Commits on Jan 18, 2019
  1. Correct response status 403 description

    jonjensen committed Jan 18, 2019
Commits on Jan 9, 2019
  1. Update copyright year in key places

    jonjensen committed Jan 9, 2019
  2. Teach pragma set_httponly to apply only to certain cookies

    jonjensen committed Jan 9, 2019
    E.g. for the default session cookie only:
    Pragma set_httponly=MV_SESSION_ID
    The change is backward-compatible, so this still applies to all cookies as before:
    Pragma set_httponly
  3. Quell undef string interpolation warnings

    jonjensen committed Jan 9, 2019
    For example:
    Use of uninitialized value $CGI::remote_host in concatenation (.) or string at /path/to/interchange/lib/Vend/ line 102.
Commits on Dec 28, 2018
Commits on Dec 4, 2018
  1. Sync manifest

    jonjensen committed Dec 4, 2018
  2. Tidy up comments

    jonjensen committed Nov 27, 2018
  3. Remove deprecation comment that won't ever be followed up on

    jonjensen committed Nov 27, 2018
    and clean up some whitespace.
Commits on Nov 26, 2018
  1. Add MYSQL_ENABLE_UTF8MB4 database option

    jonjensen committed Nov 26, 2018
    This sets the DBD::mysql dbh option mysql_enable_utf8mb4.
Commits on Nov 22, 2018
Commits on Nov 13, 2018
  1. Quell error message for harmless empty JSON request body

    jonjensen committed Nov 13, 2018
Commits on Sep 19, 2018
  1. Note that Mark added Braintree payment module

    jonjensen committed Sep 19, 2018
Commits on Sep 18, 2018
  1. Raise minimum Perl version to 5.14.1

    jonjensen committed Sep 18, 2018
    and fill out WHATSNEW document with recent changes.
  2. Fix loop interpolation bug on Perl 5.28

    jonjensen committed Sep 18, 2018
    Without this fix, the Strap demo [if-item-field] ... [/if-item-field]
    loop tags are broken on the flypage and elsewhere.
    This bug shows that Perl 5.28 no longer processes string concatenation
    from left to right such that it is safe to autoincrement a variable that
    is referred to elsewhere in the concatenation as well.
    I have not seen any other reports of people running into this problem, but
    the new behavior can be inferred from the "perl5280delta" documentation
    which notes under "Performance Enhancements":
        Many string concatenation expressions are now considerably faster,
        due to the introduction internally of a "multiconcat" opcode which
        combines multiple concatenations, and optionally a "=" or ".=", into
        a single action.
    The perlop documentation for "Auto-increment and Auto-decrement" reads:
        "++" and "--" work as in C. [...]
        Note that just as in C, Perl doesn't define when the variable is
        incremented or decremented. You just know it will be done sometime
        before or after the value is returned. This also means that modifying a
        variable twice in the same statement will lead to undefined behavior.
        Avoid statements like:
            $i = $i ++;
            print ++ $i + $i ++;
        Perl will not guarantee what the result of the above statements is.
    That does not address changing the variable once and referring to it in
    other places, but now it should.
  3. Fix nonstandard SQL

    jonjensen committed Sep 18, 2018
  4. Quell new warning in Perl 5.28

    jonjensen committed Sep 18, 2018
    Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.32)
  5. Fix race conditions in timed-build output

    jonjensen committed Sep 18, 2018
    Add a writefile_atomic() routine that is only used for writing complete
    files, not appending or piping, and is atomic on a POSIX filesystem,
    and have timed-build use that.
    Reorder the locking in the classic writefile() to return the race
    condition vulnerability window back to the much smaller time it was before
    the introduction of UTF-8 support, to make it very unlikely to occur.
    Detailed explanation of the problem and fix:
    Recently I was surprised to run into a bug in Interchange's timed-build
    generation routine on a client's production system.
    First see the source of &Vend::Interpolate::timed_build and then look
    at &Vend::File::writefile, especially this:
        open(MVLOGDATA, $file) or die "open\n";
        if ($encoding) {
            local $PerlIO::encoding::fallback = $fallback;
            binmode(MVLOGDATA, ":encoding($encoding)");
        lockfile(\*MVLOGDATA, 1, 1) or die "lock\n";
        seek(MVLOGDATA, 0, 2) or die "seek\n";
        if(ref $data) {
            print(MVLOGDATA $$data) or die "write to\n";
        else {
            print(MVLOGDATA $data) or die "write to\n";
        unlockfile(\*MVLOGDATA) or die "unlock\n";
    Note that $file will contain ">/path/to/timed_build_file" so it causes
    the file to be opened in write mode and truncated.
    That alone is a race condition: When a file is truncated, there's a
    brief time before it's written to when it's empty and any other process
    reading it will get an empty file.
    The introduction of UTF-8 support has made that race window longer because
    right after truncation the binmode() call is made with :encoding(UTF-8)
    or whatever, which can induce dynamic Encode package loads, which is
    relatively slow.
    That is one bug, but the bug I encountered is different and much weirder:
    Two timed build files generated by Interchange each had their contents
    That is, if the file should have contained "HORSES\n", it instead
    contained "HORSES\nHORSES\n".
    I've never seen such a thing before, but it happened in two separate
    timed-build files that both get used right after each other in ITL,
    so if it's caused by a race condition, it's believable that both would
    happen in the same run because they're sequential, so the same thing
    that caused it one place could cause it another.
    Now let's walk through the above code as run by two concurrent
    processes to see the race as it happens.
    Process A runs this:
        open(MVLOGDATA, $file) or die "open\n";
    And then process B runs it:
        open(MVLOGDATA, $file) or die "open\n";
    Process A runs this:
        if ($encoding) {
            local $PerlIO::encoding::fallback = $fallback;
            binmode(MVLOGDATA, ":encoding($encoding)");
    Then process B runs it:
        if ($encoding) {
            local $PerlIO::encoding::fallback = $fallback;
            binmode(MVLOGDATA, ":encoding($encoding)");
    Process A runs this:
        lockfile(\*MVLOGDATA, 1, 1) or die "lock\n";
    Then process B runs it and blocks on the lock:
        lockfile(\*MVLOGDATA, 1, 1) or die "lock\n";
    Process A runs this:
        seek(MVLOGDATA, 0, 2) or die "seek\n";
        if(ref $data) {
            print(MVLOGDATA $$data) or die "write to\n";
        else {
            print(MVLOGDATA $data) or die "write to\n";
        unlockfile(\*MVLOGDATA) or die "unlock\n";
    and the timed-build file is written correctly and unlocked.
    That unblocks process B which now runs this:
        seek(MVLOGDATA, 0, 2) or die "seek\n";
    which, oddly for this situation where we are writing to a truncated file,
    seeks to the end of the file! That appears to be a recipe gotten from
    the Perl flock() documentation:
        flock($fh, LOCK_EX) or die "Cannot lock mailbox - $!\n";
        # and, in case we're running on a very old UNIX
        # variant without the modern O_APPEND semantics...
        seek($fh, 0, SEEK_END) or die "Cannot seek - $!\n";
    and would be harmless if the file is still truncated, but now that the
    file has been written to, means we seek to the end of the file and start
    writing there!
    Now process B runs this:
        if(ref $data) {
            print(MVLOGDATA $$data) or die "write to\n";
        else {
            print(MVLOGDATA $data) or die "write to\n";
        unlockfile(\*MVLOGDATA) or die "unlock\n";
    And we have two copies of the same timed-build output, one after the
    other, in the same file.
    This bug has always existed in this code, but I think it became many
    times more likely to be encountered once the binmode() with encoding
    was added because that can be so slow.
    There are a few ways to try to solve the doubling problem:
    1. Just remove the seek() call which appears to have been only to cope
    with Unix systems that were already old and rare at the time the Perl
    flock() docs were written. Then when the doubling problem hits in the
    future, it'll write the same timed-build output once, then over itself
    If the timed-build runs return output of differing length, it could
    cause the tail end of the longer one to appear after the shorter one,
    which might be an even more confusing bug than this one.  But we could
    call truncate() to empty the rest of the file and remove the risk of
    the longer pieces remaining from before.
    This isn't attractive, though, because I don't know for sure that removing
    the seek() is actually safe, and on which systems.
    2. Call the binmode() to set the encoding *after* taking the lock. This
    seems like the right thing to do anyway, but it only narrows the window
    for the race condition, and doesn't remove it entirely.
    3. Overhaul the routine to use standard practice in writing a shared
    file atomically.
    It seems only (3) really solves both of the bugs. We can achieve our
    goal with a procedure like this:
    a. Open a new randomly-named temporary file in the same directory.
    b. Write to it.
    c. Close it.
    d. Rename it over the original file.
    Renaming is an atomic operation when done within a single POSIX
    filesystem. It isn't atomic for reads over NFS, but writefile() didn't
    support fcntl() locking for NFS anyway, so we're not making that problem
    any worse.
    This doesn't stop concurrent timed-build writes from happening, but they
    would harmlessly replace each other in a way that would never leave an
    empty or partially-written file, would keep concurrent reads from ever
    getting a stale timed-build file, and doesn't need locking at all.
    Thanks to Mark Johnson for review.
Commits on May 15, 2018
  1. Convert README to Markdown for nice GitHub viewing

    jonjensen committed May 15, 2018
    As suggested in GitHub issue #99.
    Along the way, update some things that needed it.
  2. Bump Vend::Util version

    jonjensen committed May 15, 2018
Commits on May 1, 2018
  1. Remove non-header from BounceReferrals HTTP response headers

    jonjensen committed May 1, 2018
    This invalid extra quasi-header has been there from the beginning of
    this feature, but recent versions of Apache surfaced it when they started
    throwing a 500 error when seeing a non-header in the header data.
Commits on Apr 7, 2018
  1. Fix broken random password number range; consistently make random ins…

    jonjensen committed Apr 7, 2018
    …tead of using zip or phone
    It's gross to have this logic duplicated, but fixing that is a task for
    another day.
  2. Newer MySQL versions need ISO timestamp, just like Postgres does

    jonjensen committed Apr 7, 2018
    Tested with Oracle's distribution of MySQL 5.7.
Commits on Apr 6, 2018
Commits on Apr 3, 2018
  1. Fix bug in &Vend::Data::update_data

    jonjensen committed Apr 3, 2018
    I inadvertently introduced this bug in commit fa63936 while optimizing
    a loop. The arrayref passed to set_slice is, in some cases, apparently
    mutated somewhere down the line, though it worked fine in my tests.
    Found by Gert van der Spoel <>. Thanks, Gert!
Commits on Mar 22, 2018
  1. Remove debugging message from metadata help

    jonjensen committed Mar 22, 2018
  2. Merge PR #87 #87

    jonjensen committed Mar 22, 2018
Commits on Mar 1, 2018
  1. Fix table editor composite key problems, both creating new and editin…

    jonjensen committed Mar 1, 2018
    …g existing rows
    Also refactor some code along the way.
  2. Fix typo

    jonjensen committed Mar 1, 2018
Commits on Feb 22, 2018
  1. Improve some logging

    jonjensen committed Feb 22, 2018
You can’t perform that action at this time.