diff --git a/SOURCES/rubygem-pg-1.6.0-Use-a-connection-encoding-compatible-to-M-hre.patch b/SOURCES/rubygem-pg-1.6.0-Use-a-connection-encoding-compatible-to-M-hre.patch new file mode 100644 index 0000000..6c602d3 --- /dev/null +++ b/SOURCES/rubygem-pg-1.6.0-Use-a-connection-encoding-compatible-to-M-hre.patch @@ -0,0 +1,31 @@ +From dd138ecf313274cc6a5481071bf301dc8c5139d8 Mon Sep 17 00:00:00 2001 +From: Lars Kanis +Date: Fri, 28 Feb 2025 10:39:07 +0100 +Subject: [PATCH] =?UTF-8?q?Use=20a=20connection=20encoding=20compatible=20?= + =?UTF-8?q?to=20"M=C3=B6hre"?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The function PQescapeString was changed in PostgreSQL 17.4, 16.8, 15.12, 14.17, and 13.20. +It now returns a predefined invalid character as a replacement in the connection encoding, if the input text is not valid according to the current connection encoding. +Using a compatible connection encoding avoids this, so that we get the original text out of the singleton escape function. + +Fixes #628 +--- + spec/pg/connection_spec.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/spec/pg/connection_spec.rb b/spec/pg/connection_spec.rb +index 63d3585..b646044 100644 +--- a/spec/pg/connection_spec.rb ++++ b/spec/pg/connection_spec.rb +@@ -2183,7 +2183,7 @@ describe PG::Connection do + + it "uses the previous string encoding for escaped string" do + original = "Möhre to 'scape".encode( "iso-8859-1" ) +- @conn.set_client_encoding( "euc_jp" ) ++ @conn.set_client_encoding( "iso-8859-2" ) + escaped = described_class.escape( original ) + expect( escaped.encoding ).to eq( Encoding::ISO8859_1 ) + expect( escaped ).to eq( "Möhre to ''scape".encode(Encoding::ISO8859_1) ) diff --git a/SPECS/rubygem-pg.spec b/SPECS/rubygem-pg.spec index 0e4e1c9..1b84dd9 100644 --- a/SPECS/rubygem-pg.spec +++ b/SPECS/rubygem-pg.spec @@ -3,7 +3,7 @@ Name: rubygem-%{gem_name} Version: 1.5.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A Ruby interface to the PostgreSQL RDBMS License: (BSD-2-Clause OR Ruby) AND PostgreSQL URL: https://github.com/ged/ruby-pg @@ -27,6 +27,10 @@ Patch1: rubygem-pg-1.5.4-Explicitly-retype-timespec-fields-to-int64_t.patch # https://github.com/ged/ruby-pg/issues/545 # https://github.com/ged/ruby-pg/pull/548 Patch2: rubygem-pg-1.5.4-Fix-possible-buffer-overflows-on-32-bit-systems.patch +# Use a compatible connection encoding in spec. +# https://github.com/ged/ruby-pg/issues/628 +# https://github.com/ged/ruby-pg/commit/dd138ecf313274cc6a5481071bf301dc8c5139d8 +Patch3: rubygem-pg-1.6.0-Use-a-connection-encoding-compatible-to-M-hre.patch # ext/pg_text_decoder.c Requires: rubygem(bigdecimal) # lib/pg/text_{de,en}coder.rb @@ -62,6 +66,10 @@ Documentation for %{name}. %patch -P 1 -p1 %patch -P 2 -p1 +pushd %{_builddir} +%patch 3 -p1 +popd + %build # Create the gem as gem install only works on a gem file gem build ../%{gem_name}-%{version}.gemspec @@ -133,6 +141,10 @@ popd %exclude %{gem_instdir}/translation %changelog +* Tue Mar 24 2026 Jarek Prokop -1.5.4-2 +- Fix encoding issue in spec suite. + Resolves: RHEL-159200 + * Fri Jan 19 2024 Jarek Prokop - 1.5.4-1 - Upgrade to pg 1.5.4. Related: RHEL-17089