Re: [Trac] patch to run IncludeMacro with Trac 1.6

Ales Horak <[email protected]> Sat, 27 Sep 2025 02:05:30 -0700 (PDT)
Newsgroups gmane.comp.version-control.subversion.trac.general
Message-ID <[email protected]>
------=_Part_138614_1560144938.1758963930558
Content-Type: multipart/alternative; 
	boundary="----=_Part_138615_1286256950.1758963930558"

------=_Part_138615_1286256950.1758963930558
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Thank you.

Another small patch attached that I needed for including an HTML page with=
=20
UTF-8 encoding as `Include(http://www.example.com/page.html)` .
Without decoding, the page is included as bytes with all special characters=
=20
escaped.
It might be better to enter the encoding as a parameter.
--
ales horak


Dne st=C5=99eda 17. z=C3=A1=C5=99=C3=AD 2025 v 4:13:15 UTC+2 u=C5=BEivatel =
Jun Omae napsal:

Thanks for the feedback.
I've committed the patch in [18706] <https://trac-hacks.org/changeset/18706=
>
.

On 2025/09/14 16:27, Ale=C5=A1 Hor=C3=A1k wrote:

Hi,=20

thank you. my patch was the minimum to get it to work, just fixing the=20
errors that appeared :-)

yours is more complete and functional =F0=9F=91=8D

--=20
ales horak


--=20
Ale=C5=A1 Hor=C3=A1k


ne 14. 9. 2025 v 5:53 odes=C3=ADlatel Jun Omae <[email protected]> napsal:

Hi,

On Sat, Sep 13, 2025 at 04:13:16AM -0700, Ales Horak wrote:
> current https://trac-hacks.org/wiki/IncludeMacro does not run under Trac=
=20
1.6
> due to genshi imports
>=20
> see the attached patch to make it functional
>=20
> --=20
> ales horak

Thanks for the patch! However, it seems to be incomplete.

$ pyflakes includemacro/macros.py
includemacro/macros.py:214:59: undefined name 'TracHTMLSanitizer'
includemacro/macros.py:244:23: undefined name 'ParseError'
includemacro/macros.py:255:27: undefined name 'ParseError'
includemacro/macros.py:288:20: undefined name 'ParseError'

Could you please try the attached patch?

--=20
You received this message because you are subscribed to a topic in the=20
Google Groups "Trac Users" group.
To unsubscribe from this topic, visit=20
https://groups.google.com/d/topic/trac-users/oIX9bq6TkVc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to=20
trac-users+...-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To view this discussion visit=20
https://groups.google.com/d/msgid/trac-users/aMY8Eia7Pi0d/sOV%40localhost.

--=20

You received this message because you are subscribed to the Google Groups=
=20
"Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an=
=20
email to trac-users+...-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To view this discussion visit=20
https://groups.google.com/d/msgid/trac-users/CAHm62qP8EwaOVoCpjNiTBThhNNLAs=
6%2BGGrU6nznXEoX6AOPw7A%40mail.gmail.com=20
<https://groups.google.com/d/msgid/trac-users/CAHm62qP8EwaOVoCpjNiTBThhNNLA=
s6%2BGGrU6nznXEoX6AOPw7A%40mail.gmail.com?utm_medium=3Demail&utm_source=3Df=
ooter>
.


-- Jun Omae <[email protected]> (=E5=A4=A7=E5=89=8D =E6=BD=A4)=20

--=20
You received this message because you are subscribed to the Google Groups "=
Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to trac-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To view this discussion visit https://groups.google.com/d/msgid/trac-users/=
99108147-9d89-4159-b467-43257e803ec4n%40googlegroups.com.

------=_Part_138615_1286256950.1758963930558
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Thank you.<div><br /><div>Another small patch attached that I needed for in=
cluding an HTML page with UTF-8 encoding as `Include(http://www.example.com=
/page.html)` .</div><div>Without decoding, the page is included as bytes wi=
th all special characters escaped.</div><div>It might be better to enter th=
e encoding as a parameter.</div><div>--</div><div>ales horak</div><div><br =
/><br /></div><div><div dir=3D"auto">Dne st=C5=99eda 17. z=C3=A1=C5=99=C3=
=AD 2025=C2=A0v=C2=A04:13:15 UTC+2 u=C5=BEivatel Jun Omae napsal:<br /></di=
v><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rg=
b(204, 204, 204); padding-left: 1ex;"><u></u>

 =20
   =20
 =20
  <div>
    <div>Thanks for the feedback.</div>
    <div>I've committed the patch in=C2=A0<a href=3D"https://trac-hacks.org=
/changeset/18706" target=3D"_blank" rel=3D"nofollow">[18706]</a>.</div></di=
v><div>
    <div><br />
    </div>
    <div>On 2025/09/14 16:27, Ale=C5=A1 Hor=C3=A1k wrote:<br />
    </div>
    </div><div><blockquote type=3D"cite">
     =20
      <div dir=3D"ltr">Hi,
        <div><br />
        </div>
        <div>thank you. my patch was the minimum to get it to work, just
          fixing the errors that appeared :-)</div>
        <div><br />
        </div>
        <div>yours is more complete and functional=C2=A0=F0=9F=91=8D</div>
        <div><br />
        </div>
        <div>-- <br />
          ales horak<br />
        </div>
        <div><br />
        </div>
      </div>
      <div><br clear=3D"all" />
      </div>
      <div>
        <div dir=3D"ltr">
          <div dir=3D"ltr">-- <br />
            Ale=C5=A1 Hor=C3=A1k</div>
        </div>
      </div>
      <br />
      <br />
      <div>
        <div dir=3D"ltr">ne 14. 9. 2025 v=C2=A05:53
          odes=C3=ADlatel Jun Omae &lt;<a href=3D"" rel=3D"nofollow">jun...=
@gmail.com</a>&gt;
          napsal:<br />
        </div>
        <blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px so=
lid rgb(204, 204, 204); padding-left: 1ex;">Hi,<br />
          <br />
          On Sat, Sep 13, 2025 at 04:13:16AM -0700, Ales Horak wrote:<br />
          &gt; current <a href=3D"https://trac-hacks.org/wiki/IncludeMacro"=
 rel=3D"noreferrer nofollow" target=3D"_blank">https://trac-hacks.org/wiki/=
IncludeMacro</a>
          does not run under Trac 1.6<br />
          &gt; due to genshi imports<br />
          &gt; <br />
          &gt; see the attached patch to make it functional<br />
          &gt; <br />
          &gt; --=C2=A0<br />
          &gt; ales horak<br />
          <br />
          Thanks for the patch! However, it seems to be incomplete.<br />
          <br />
          $ pyflakes includemacro/macros.py<br />
          includemacro/macros.py:214:59: undefined name
          'TracHTMLSanitizer'<br />
          includemacro/macros.py:244:23: undefined name 'ParseError'<br />
          includemacro/macros.py:255:27: undefined name 'ParseError'<br />
          includemacro/macros.py:288:20: undefined name 'ParseError'<br />
          <br />
          Could you please try the attached patch?<br />
          <br />
          -- <br />
          You received this message because you are subscribed to a
          topic in the Google Groups "Trac Users" group.<br />
          To unsubscribe from this topic, visit <a href=3D"https://groups.g=
oogle.com/d/topic/trac-users/oIX9bq6TkVc/unsubscribe" rel=3D"noreferrer nof=
ollow" target=3D"_blank">https://groups.google.com/d/topic/trac-users/oIX9b=
q6TkVc/unsubscribe</a>.<br />
          To unsubscribe from this group and all its topics, send an
          email to <a href=3D"" rel=3D"nofollow">trac-users+...@googlegroup=
s.com</a>.<br />
          To view this discussion visit <a href=3D"https://groups.google.co=
m/d/msgid/trac-users/aMY8Eia7Pi0d/sOV%40localhost" rel=3D"noreferrer nofoll=
ow" target=3D"_blank">https://groups.google.com/d/msgid/trac-users/aMY8Eia7=
Pi0d/sOV%40localhost</a>.<br />
        </blockquote>
      </div>
      -- <br /></blockquote></div><div><blockquote type=3D"cite">
      You received this message because you are subscribed to the Google
      Groups "Trac Users" group.<br />
      To unsubscribe from this group and stop receiving emails from it,
      send an email to <a href=3D"" rel=3D"nofollow">trac-users+...@googleg=
roups.com</a>.<br />
      To view this discussion visit <a href=3D"https://groups.google.com/d/=
msgid/trac-users/CAHm62qP8EwaOVoCpjNiTBThhNNLAs6%2BGGrU6nznXEoX6AOPw7A%40ma=
il.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow">https://groups.google.com/d/msgid/trac-users/CAHm62qP8EwaO=
VoCpjNiTBThhNNLAs6%2BGGrU6nznXEoX6AOPw7A%40mail.gmail.com</a>.<br />
    </blockquote>
    <p><br />
    </p>
    <span cols=3D"0">--=20
Jun Omae <a href=3D"" rel=3D"nofollow">&lt;[email protected]&gt;</a> (=E5=A4=
=A7=E5=89=8D =E6=BD=A4)</span>
  </div>

</blockquote></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;Trac Users&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:trac-users+unsubscribe-/[email protected]">trac-use=
rs+unsubscribe-/[email protected]</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
trac-users/99108147-9d89-4159-b467-43257e803ec4n%40googlegroups.com?utm_med=
ium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/trac-use=
rs/99108147-9d89-4159-b467-43257e803ec4n%40googlegroups.com</a>.<br />

------=_Part_138615_1286256950.1758963930558--

------=_Part_138614_1560144938.1758963930558
Content-Type: text/x-patch; charset=US-ASCII; name=includemacro-utf8.patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=includemacro-utf8.patch
X-Attachment-Id: 488992a5-7c0a-4430-bbff-25b98b41ccc9
Content-ID: <488992a5-7c0a-4430-bbff-25b98b41ccc9>

--- macros.orig.py	2025-09-27 10:53:09.051770704 +0200
+++ macros.py	2025-09-27 10:55:29.187899320 +0200
@@ -94,7 +94,7 @@
                 return ''
             try:
                 urlf = urlopen(source)
-                out = urlf.read()
+                out = urlf.read().decode('utf-8')
             except URLError as e:
                 return system_message("Error while retrieving file", str(e))
             except TracError as e:

------=_Part_138614_1560144938.1758963930558--