diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9b6bd96..c8c08f19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,6 @@ jobs: - { os: ubuntu-latest , ruby: truffleruby-head } exclude: - { os: windows-latest, ruby: jruby } - - { os: windows-latest, ruby: jruby-head } steps: - uses: actions/checkout@v5 diff --git a/.github/workflows/sync-ruby.yml b/.github/workflows/sync-ruby.yml new file mode 100644 index 00000000..29c43449 --- /dev/null +++ b/.github/workflows/sync-ruby.yml @@ -0,0 +1,33 @@ +name: Sync ruby +on: + push: + branches: [master] +jobs: + sync: + name: Sync ruby + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'ruby' }} + steps: + - uses: actions/checkout@v5 + + - name: Create GitHub App token + id: app-token + uses: actions/create-github-app-token@v2 + with: + app-id: 2060836 + private-key: ${{ secrets.RUBY_SYNC_DEFAULT_GEMS_PRIVATE_KEY }} + owner: ruby + repositories: ruby + + - name: Sync to ruby/ruby + uses: convictional/trigger-workflow-and-wait@v1.6.5 + with: + owner: ruby + repo: ruby + workflow_file_name: sync_default_gems.yml + github_token: ${{ steps.app-token.outputs.token }} + ref: master + client_payload: | + {"gem":"${{ github.event.repository.name }}","before":"${{ github.event.before }}","after":"${{ github.event.after }}"} + propagate_failure: true + wait_interval: 10 diff --git a/CHANGES.md b/CHANGES.md index 747b8059..1f0b7873 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,10 +2,14 @@ ### Unreleased +### 2025-10-07 (2.15.1) + +* Fix incorrect escaping in the JRuby extension when encoding shared strings. + ### 2025-09-22 (2.15.0) * `JSON::Coder` callback now receive a second argument to convey whether the object is a hash key. -* Tuned the floating point number generator to not use scientific notation as agressively. +* Tuned the floating point number generator to not use scientific notation as aggressively. ### 2025-09-18 (2.14.1) diff --git a/java/src/json/ext/SWARBasicStringEncoder.java b/java/src/json/ext/SWARBasicStringEncoder.java index 02a3bfcd..a6695d99 100644 --- a/java/src/json/ext/SWARBasicStringEncoder.java +++ b/java/src/json/ext/SWARBasicStringEncoder.java @@ -27,9 +27,10 @@ void encode(ByteList src) throws IOException { // slice a string, the underlying byte array is the same, but the // begin index and real size are different. When reading from the ptrBytes // array, we need to always add ptr to the index. - ByteBuffer bb = ByteBuffer.wrap(ptrBytes, ptr, len); + ByteBuffer bb = ByteBuffer.wrap(ptrBytes, 0, ptr + len); + while (pos + 8 <= len) { - long x = bb.getLong(pos); + long x = bb.getLong(ptr + pos); if (skipChunk(x)) { pos += 8; continue; @@ -48,7 +49,7 @@ void encode(ByteList src) throws IOException { } if (pos + 4 <= len) { - int x = bb.getInt(pos); + int x = bb.getInt(ptr + pos); if (skipChunk(x)) { pos += 4; } diff --git a/lib/json/version.rb b/lib/json/version.rb index e2db923e..be5daf4c 100644 --- a/lib/json/version.rb +++ b/lib/json/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module JSON - VERSION = '2.15.0' + VERSION = '2.15.1' end diff --git a/test/json/json_encoding_test.rb b/test/json/json_encoding_test.rb index 8dce81da..2789e94b 100644 --- a/test/json/json_encoding_test.rb +++ b/test/json/json_encoding_test.rb @@ -35,6 +35,8 @@ def test_generate_shared_string # Ref: https://github.com/ruby/json/issues/859 s = "01234567890" assert_equal '"234567890"', JSON.dump(s[2..-1]) + s = '01234567890123456789"a"b"c"d"e"f"g"h' + assert_equal '"\"a\"b\"c\"d\"e\"f\"g\""', JSON.dump(s[20, 15]) end def test_unicode