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
Bug found in http_trim_filter-module. #368
Comments
Hello, Can anyone check this bug? I think this bug can cause issue for almost all users who are using this module. As mentioned in above example, multiple continuous spaces are replaced with the word next to the multiple spaces. Thanks, |
Thank you. We are tracking this bug. It seems there is a compatible problem with echo module. |
leaving first line blank is all right, we expect that. we will track the second case, and will you please post your whole conf file? |
Thanks for some updates on this. Only the first result had first line blank. After reloading page first blank line was no more exist. There is no spacial settings in my conf file. I just have two locations
I have used this module just for /htmlTest location where I am generating response with echo module. I would be thankful to you if you could just keep updating progress here on ticket. |
we have found the reason. maybe we should add a "method=copy" parameter to "trim", so that it will not change the source. |
I really appreciate your quick updates on this today. I would like to use that new feature "method=copy" if you would develop(add) this parameter and it can solve this issue. I need one small help. This module replaces single/multiple line breaks with single ' ' (space) character. I would like to make a small change here. I want to replace ONLY "multiple line breaks" with "single line break". Would you suggest me what should be changed in the "ngx_http_trim_filter_module.c" file? Thanks |
On 2013/12/31 21:45, makailol wrote:
It could work with substitution module. Could you explain why you want Thanks |
I am not sure how does substitution module work but as it runs on final output so it could work with echo module too. So I just suggested if it is possible to make changes in trim module just like substitution module. For some URI, I use echo subrequest directive. Would you suggest me changes in the trim module for replacing "multiple line breaks" with "single line break" and to avoid replacing single line break with ' ' (space) character (as I mentioned in previous post)? I just want to trim just like pagespeed does. |
On 2014/1/1 21:23, makailol wrote:
Is there any problem when replacing all the linefeeds to be one space? Weibin Yao |
I don't have any test case where replacing all linefeeds could cause the issue right now. But I think this change should be easy to do in this trim module. I would like to change this because it can make source more readable. Would you suggest me changes in trim module c code to achieve this? |
Hello, Could anyone get time to check this yet? |
I'm sorry, trim module can't work with echo module, it is different with substitution as cfsego says. About make source more readable, you can enter args "http_trim=off" to read the original http code. |
Hi, Thanks for reply. Yes I checked "http_trim=off" argument but I want below change in module with "http_trim=on". This module replaces single/multiple line breaks with single ' ' (space) character. I would like to make a small change here. I want to replace ONLY "multiple line breaks" with "single line break". Would you suggest me where should I make change in C file to achieve this? Thanks |
try this patch. 2014/1/6 makailol notifications@github.com
|
Hello, Where is the patch file? I can not find link. |
|
The given patch seems to be working but I have noticed that this trim module breaks the nested pre tag. For example,
In above html code, this trim module removes blank line after "pre>2nd line" . Unable to paste html so I removed '<' from starting tag. |
Thank you very much. |
Thank you very much for quick updates. Please also check another issue which I have mentioned in my previous post. The extra spaces in script and style tags(probably other tags too). I think we can remove extra spaces from any tag lines. For example spaces between two attributes and spaces after < and spaces before > . Once you fix this bug, let us know I will test it. |
First of all, thank you for your support. Yet I have a doubt if 'pre' can really be nested, because it makes no use, i suppose. |
It is okay to nest the pre tag inside a div tag. It can be used for different formatting for different text. If you want to format the pre text to display in a different font or color, you can easily define CSS styles for it by using the "pre" selector in a CSS rule. And that style is used with class="" attribute of pre tag. I have also noticed that cloudflare minification preserves nested 'pre'. |
we test it, and it's okay. so we will look into these two points:
thank you |
Thank you! I will wait for updated version of module and it would be good if you can import the patch given by "taoyuanyuan" in default module. Basically google page speed and cloudflare preserve single line break. |
https://github.com/taoyuanyuan/patch/blob/master/trim_140114.patch
|
Hello, First of all Thanks for all your efforts and work on this module. I really appreciate your quick updates on this. I rebuilt my Nginx with the updated patch of trim module and tried to perform some tests. Out of two issues second one (support nest 'pre') seems to be fixed now. For first one I have used below test html code :
And result was as below :
In the result, first line break in the first script tag is not removed. And in last script tag there is extra space before '>'. I think we can remove spaced after starting < and before closing > in the tag. I'm not sure how difficult this would be. :) I have just tested these cases with script tag but I think result will be same with other tags too. Regards, |
Trim replaces more than one spaces with a space, so.
result:
About "first line break in the first script tag is not removed", this is your suggest.
|
Yes it replaces multiple spaces with single space. But have you noticed the replacement of line breaks in tag line? The test case which I have posted in my previous post, you can see only first line break in first script tag is not remove which can be removed just like other line breaks in tag line(which are being removed already). About space before > character , it is just my suggestion that we can remove it too but I am not sure if it is possible to implement in this module. |
About space before > character, I have considered before , it's rare in the case, it's diffrent from code logic of "replaces multiple spaces with single space" and there is some trouble doing it, so I don't remove this single space specially. I don't understand your test case. my result is diffrent with yours, I don't replace line break with space . |
To reproduce the case , you can add this code in your HTML. This module removes the line break in tag lines with a space. This is proper way too. But with this test case you can see the first line break in the first (script)tag line is not being removed. Current result is like https://gist.github.com/makailol/2d89d1edb962a49d621e |
I reinstalled Nginx with updated version of this module. New options are available and seems to be working. I will do more testing on inline js and css trimming and if I find any issue, I will give you updates. I have just noticed that in tag lines spaces around '=' can be removed if it is for attribute values.
Can be changed to :
In current module it is already replacing multiple spaces with single space in this test code too so it is not a major thing if we can not remove space around '=' in tag lines. |
download the code in my github again, I have update the code for you suggest. code:
result:
this is my all test cases thank you, have a nice weekend. |
Good job! I really appreciate this quick update again. Your quick updates motivates me for more testing! Thanks & Have a nice weekend |
Hello, I have built nginx with updated version of trim module and tested it. It seems like all issues which we had noticed are fixed in this update. Is there any plan to merge this changes in tengine? So that we can always get updated version of this module from tengine? It would be good if someone can add English version of the trim document. Thanks for developing this open source module and providing support for fixing all issues and changing features as needed. Regards, |
I'm changing the code for trim js and css these days, we will merge this changes in tengine this week. |
Do you mean are you still making changes to trim module? If yes then can you just tell me what are those changes? Tengine trim module will have all these changes available or will there be some differences? Also please notify me (on this ticket) when changes are merged to tengine. Thanks, |
remove space around some characters ( '{' '}' ',' ':' ';' '>' ) in css. All changes will be merged to tengine this week. |
trim module feature and bugfix (#368)
hi, all changes have been merged to tengine. |
Thanks for information. Thanks cfsego for English doc. Would it be possible to make it complete ? i.e. Chinese version contains more information about js and css trimming. So far I have done some testing on inline js and css and all cases were passed though I would like to check how we trim inline js and css. |
Oh, such a long list about trimming rules. I dont like it, though I know it is important. |
Hi, Would you check the possibility to use variable value to on|off trim module dynamically? For example, Currently it gives error on nginx restart : invalid value "$html_trim" in "trim" directive, it must be "on" or "off" . Thanks, |
Hello! |
Thank you @makailol . All of us are having Chinese New Year holiday. @taoyuanyuan will track your issue. |
Happy New Year! Generally, nginx don't set boolean value(on/off) as variable value, I don't recommend do it. is this ok? |
Happy New Year 😄 Thanks for updating doc. I tried below block to set and test the boolean value(on/off) as variable value and it works fine too.
I usually avoid using "if" in nginx (because http://wiki.nginx.org/IfIsEvil), but I am not sure if it was the case with older Nginx version. It would be good to have support of using variable value (on/off) with trim. Additionally it would be best if you can add support for 'if' context as you mentioned. :) Thanks, |
ok |
Thanks for accepting this change request. I have tested this with variable value today and it is working fine. Please let me know once after you merge this change to tengine. |
I believe that enable the trimming function in "if" context is duplicate to enable it with variable, so I think we will not do this. |
Could we add a directive like |
@taoyuanyuan, are you going to make changes suggested by yaoweibin? Please let me know when you merge the changes made to support variable value in trim directive into tengine. |
Hello, I have noticed an issue with assigning variable value to trim_js directive. While assigning value dynamically from "on" to "off", it works but it sets trim_js "off" permanently until nginx is restarted. So it can not be "on" dynamically. For example,
URL to access : www.example.com/example.html?js=on Changing js GET parameter from "on" to "off" works but it can not be "on" again. Thanks, |
hi, this bug has be fixed last week, you can update code in my github |
Hi, |
hi, these changes have merged to tengine. |
If you still have the problem, you can reopen this issue. |
Hello,
I just tried the trim module with nginx-echo module to test few cases. I am not sure how it works but when there are more number of space " " characters, it just replaces the word after the spaces on page refresh.
Test case:
Result (first time page reload):
We get first line blank and all contents in second line
1
2 hello Moki 2nd line 3rd linetest last line
Result (After reloading page 8-10 times, we get final result like below) :
1 hello Moki
2 2nd line 3rd linetest linetest linetest linetest linetest linetest linetest linetest linetest linetest linetest linetest linetest linetestinetest last line
It would be good if someone can look into this because it seems to be major bug.
Thanks,
Makailol
The text was updated successfully, but these errors were encountered: