Skip to content
Snippets Groups Projects
Commit 448db89e authored by Prasad's avatar Prasad
Browse files

Fixed captcha script support in webform

parent de70289c
No related branches found
No related tags found
No related merge requests found
......@@ -118,7 +118,8 @@
{/foreach}
</table>
{if $IS_CAPTCHA_ENABLED}
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
{# vscript - custom script tag to avoid loading when form popup is displayed #}
<vscript src="https://www.google.com/recaptcha/api.js" async defer></vscript>
<div class="g-recaptcha" data-sitekey="{$CAPTCHA_CONFIG['VTIGER_RECAPTCHA_PUBLIC_KEY']}" data-callback="enableSubmitBtn"></div>
{/if}
<input type="submit" value="Submit" ></input>
......
......@@ -48,6 +48,10 @@ Settings_Vtiger_Detail_Js('Settings_Webforms_Detail_Js', {
//show html without rendering
var allowedAllFilesSize = container.find('.allowedAllFilesSize').val();
var showFormContents = container.find('pre').html();
// Replace custom (vscript) tags to (script) before adding to textarea
showFormContents = showFormContents.replace(/vscript/g, "script");
showFormContents = showFormContents + '<script type="text/javascript">'+
'window.onload = function() { '+
'var N=navigator.appName, ua=navigator.userAgent, tem;'+
......@@ -175,4 +179,4 @@ Settings_Vtiger_Detail_Js('Settings_Webforms_Detail_Js', {
registerEvents : function() {
this._super();
}
})
\ No newline at end of file
})
  • Prasad @prasad

    mentioned in merge request !832 (merged)

    ·

    mentioned in merge request !832 (merged)

    Toggle commit list
  • Nilay Khatri @nilay.automatesmb ·

    @prasad we need not do that, instead of deferred loading we can go for explicit loading of recaptcha. Will have to weigh in any cons of that.

  • Contributor

    @nilay.automatesmb what do you mean by "explicit loading"?

    @prasad the above feels a bit "hacky". I think we should find a way for the JS not to execute.

  • Author Maintainer

    @ruben.estrada - We remove script tag acceptance in the content here we are doing special case handling to retain. So is the workaround pattern.

  • Contributor

    couldn't we put something like 'RECAPTCHA_SCRIPT_PLACEHOLDER' and then replace the whole thing with <script src="https://www.google.com/recaptcha/api.js" async defer></script>. I find the <vscript> convention quite confusing.

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment