<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: TehKonnos</title>
    <description>The latest articles on DEV Community by TehKonnos (@tehkonnos).</description>
    <link>https://dev.to/tehkonnos</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F535567%2F9381026a-6707-4db6-9155-e924de08a493.jpg</url>
      <title>DEV Community: TehKonnos</title>
      <link>https://dev.to/tehkonnos</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tehkonnos"/>
    <language>en</language>
    <item>
      <title>Why URL encoding saves lives.</title>
      <dc:creator>TehKonnos</dc:creator>
      <pubDate>Sun, 29 Jan 2023 14:32:19 +0000</pubDate>
      <link>https://dev.to/tehkonnos/why-url-encoding-saves-lives-1453</link>
      <guid>https://dev.to/tehkonnos/why-url-encoding-saves-lives-1453</guid>
      <description>&lt;p&gt;The story begins with me trying to understand why the gravity forms confirmation message is not sent to a third-party application that I use via HTML post requests.&lt;br&gt;
After many manually handled cases, I started noticing a pattern that revealed where all of my issues were coming from. That pattern was the URL encoding part I was missing.&lt;/p&gt;

&lt;p&gt;To give you some background, everything looks fine when a Notification mail is sent from Gravity Forms to the recipients (in our example, me). But when it turns to the confirmation message, the plugin it self does not encode the values submitted by the users.&lt;/p&gt;

&lt;p&gt;After I understood what was happening, I had to encode all of the values somehow. There are many ways to achieve that, and all of them are probably much better than my final workaround, though I am still writing this to share my learnings.&lt;/p&gt;

&lt;p&gt;I chose to use the 'gform_pre_submission' function from Gravity Forms webhooks and encode all the critical fields that might cause a problem before the actual submission of the form.&lt;br&gt;
As one could, though, if the value is encoded before the submission, doesn't it affect the notification mail? Short answer, yes, it is. But to fix that,  I used another function called 'gform_pre_send_email' and replaced those values by decoding them to "utf-8" strings.&lt;/p&gt;

&lt;p&gt;Why didn't I encode them in the confirmation stage? At that point, the response to the user was a custom-coded message, and I had to encode it as a whole, which was not a choice.&lt;/p&gt;

&lt;p&gt;I hope you get some value and learnings from this story. As a gift for reaching that far, with my friend chatGPT, we made you a poem.&lt;/p&gt;

&lt;p&gt;URL encoding is a must, when writing code&lt;br&gt;
Sending data with HTML requests, it's not just a mode&lt;br&gt;
For user's inputs may not always be right&lt;br&gt;
And lead to errors, with no end in sight&lt;/p&gt;

&lt;p&gt;But URL encoding helps to fix that flaw&lt;br&gt;
By converting special characters, and making it all raw&lt;br&gt;
So data can be sent, without any mix&lt;br&gt;
And servers can understand, just what we want to fix&lt;/p&gt;

&lt;p&gt;And never forget, the user input's impurity&lt;br&gt;
It may contain errors, that bring insecurity&lt;br&gt;
So before it's processed, verify with care&lt;br&gt;
To avoid any risks, and keep your code fair.&lt;/p&gt;

&lt;p&gt;In short, URL encoding is a key&lt;br&gt;
To sending data, the right way to be&lt;br&gt;
And validating user's submissions, is a must&lt;br&gt;
For security reasons, and to keep your code robust.&lt;/p&gt;

&lt;p&gt;Have a nice day :)&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
  </channel>
</rss>
