Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix escaped quotes #48

Merged
merged 2 commits into from
Apr 26, 2024
Merged

Fix escaped quotes #48

merged 2 commits into from
Apr 26, 2024

Conversation

williamthome
Copy link
Contributor

This PR fixes escaped quotes.

Before:

1> rp(template_compiler:compile_binary(<<"{% print 'Hello \\'world\\'' %}">>, <<"tmp.tpl">>, [], [])).
{error,[82,101,97,99,104,101,100,32,101,110,100,32,111,102,
        32,
        [60,60,"\"tmp.tpl\"",62,62],
        32,105,110,115,105,100,101,32,97,32,99,111,100,101,32,98,
        108,111,99,107,46]}
2> io:format("~s~n", [[82,101,97,99,104,101,100,32,101,110,100,32,111,102,
           32,
           [60,60,"\"tmp.tpl\"",62,62],
           32,105,110,115,105,100,101,32,97,32,99,111,100,101,32,98,
           108,111,99,107,46]]).
Reached end of <<"tmp.tpl">> inside a code block.

Now:

1> template_compiler:compile_binary(<<"{% print 'Hello \\'world\\'' %}">>, <<"tmp.tpl">>, [], []).
{ok,tpl_423b67510ab04afcc797794b8a9d5e69319b8cc6}
ok
2> tpl_423b67510ab04afcc797794b8a9d5e69319b8cc6:render([],[],[]).
[<<>>,
 [<<"<pre>">>,
  <<"&lt;&lt;&quot;Hello &#39;world&#39;&quot;&gt;&gt;">>,
  <<"</pre>">>]]

The reason is that the compiler could not find the end of the quotes.

That's the result of running those new tests in the master branch:

$ make test
./rebar3  ct
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling template_compiler
===> Running Common Test suites...
%%% template_compiler_basic_SUITE: ........
%%% template_compiler_control_flow_SUITE: ...........
%%% template_compiler_expr_SUITE: ...........
%%% template_compiler_include_SUITE: ...
%%% template_compiler_quote_SUITE: .
%%% template_compiler_quote_SUITE ==> basic.single_quote_slash_test: FAILED
%%% template_compiler_quote_SUITE ==> {{badmatch,
     {error,
         [82,101,97,99,104,101,100,32,101,110,100,32,111,102,32,
          [60,60,
           "\"/home/williamthome/Projects/erlang/template_compiler/_build/test/lib/template_compiler/test/test-data/quote_single_slash.tpl\"",
           62,62],
          32,105,110,115,105,100,101,32,97,32,99,111,100,101,32,98,108,111,99,
          107,46]}},
 [{template_compiler_quote_SUITE,single_quote_slash_test,1,
      [{file,
           "/home/williamthome/Projects/erlang/template_compiler/test/template_compiler_quote_SUITE.erl"},
       {line,48}]},
  {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1793}]},
  {test_server,run_test_case_eval1,6,[{file,"test_server.erl"},{line,1302}]},
  {test_server,run_test_case_eval,9,[{file,"test_server.erl"},{line,1234}]}]}
.
%%% template_compiler_quote_SUITE ==> basic.double_quote_slash_test: FAILED
%%% template_compiler_quote_SUITE ==> {{badmatch,
     {error,
         [82,101,97,99,104,101,100,32,101,110,100,32,111,102,32,
          [60,60,
           "\"/home/williamthome/Projects/erlang/template_compiler/_build/test/lib/template_compiler/test/test-data/quote_double_slash.tpl\"",
           62,62],
          32,105,110,115,105,100,101,32,97,32,99,111,100,101,32,98,108,111,99,
          107,46]}},
 [{template_compiler_quote_SUITE,double_quote_slash_test,1,
      [{file,
           "/home/williamthome/Projects/erlang/template_compiler/test/template_compiler_quote_SUITE.erl"},
       {line,58}]},
  {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1793}]},
  {test_server,run_test_case_eval1,6,[{file,"test_server.erl"},{line,1302}]},
  {test_server,run_test_case_eval,9,[{file,"test_server.erl"},{line,1234}]}]}
..
%%% template_compiler_tags_SUITE: ......
%%% template_compiler_trans_SUITE: ...
%%% template_compiler_with_SUITE: ....
EXPERIMENTAL: Writing retry specification at /home/williamthome/Projects/erlang/template_compiler/_build/test/logs/retry.spec
              call rebar3 ct with '--retry' to re-run failing cases.
Failed 2 tests. Passed 50 tests.
Results written to "/home/williamthome/Projects/erlang/template_compiler/_build/test/logs/index.html".
===> Failures occurred running tests: 2
make: *** [GNUmakefile:40: test] Error 1

@mworrell mworrell self-assigned this Apr 25, 2024
@mworrell
Copy link
Member

Looks like we have a totally unrelated problem with ex_doc.

@williamthome
Copy link
Contributor Author

williamthome commented Apr 25, 2024

@mworrell could you please rerun the actions?
I've no permission to do so.

@mworrell
Copy link
Member

Great! This works again, after all your other fixes.

@mworrell mworrell merged commit ef201ef into zotonic:master Apr 26, 2024
3 checks passed
@williamthome williamthome deleted the fix/quotes branch April 26, 2024 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants