Removing unnecessary/wasterful ^M's from nvram strings

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Goto page Previous  1, 2
Author Message
BrainSlayer
Site Admin


Joined: 06 Jun 2006
Posts: 7349
Location: Dresden, Germany

PostPosted: Fri Aug 26, 2022 14:06    Post subject: Reply with quote
let me add something to this bullshit. dd-wrt does not add crlf it takes what it gets. please kindly ask your local browser vendor why he is doing that shit. and btw. if you save startup etc. dd-wrt removes all \r instances

edit: made a quick and dirty generic solution which corrects all nvrams once they got written

_________________
"So you tried to use the computer and it started smoking? Sounds like a Mac to me.." - Louis Rossmann https://www.youtube.com/watch?v=eL_5YDRWqGE&t=60s
Sponsor
puterboy2
DD-WRT User


Joined: 24 Feb 2019
Posts: 115

PostPosted: Fri Aug 26, 2022 18:10    Post subject: Reply with quote
BrainSlayer wrote:
let me add something to this bullshit. dd-wrt does not add crlf it takes what it gets. please kindly ask your local browser vendor why he is doing that shit. and btw. if you save startup etc. dd-wrt removes all \r instances

edit: made a quick and dirty generic solution which corrects all nvrams once they got written


Thanks. I agree it's a browser/Windows issue but it's not like Microsoft will change for me or any of us. So sometimes we need to clean up other people's mess -- and certainly don't let the sloppiness/laziness of others infect the cleanliness and consistency of our beautiful nvram Smile

Wasn't clear to me though why text boxes in the command tab removed \r while elsewhere they didn't.

Thanks again for fixing this for all of us!
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 330

PostPosted: Mon Aug 29, 2022 17:12    Post subject: Reply with quote
For those on builds after r49908 and who didn't erase nvram when upgrading, you can check if you have these extra ^M characters with:
Code:
nvram show | grep -c $'\r'
size: 56926 bytes (8610 left)
146

I had to click "Save" in the following pages to get that 146 occurrences number down to zero.

Services->Services
Administration->Management
Services->VPN
Privoxy???

In my case I have removed privoxy from my build since I'm now using entware's privoxy so I cleaned up the privoxy_conf variable manually. You can see the offending variables with the above command without the -c as below:
Code:
nvram show | grep $'\r'

The name of the variables usually give a good hint as to which page needs re-saving.
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1364
Location: Appalachian mountains, USA

PostPosted: Tue Aug 30, 2022 20:15    Post subject: Reply with quote
OK guys... I have seen these ^M chars on and off for years, especially in the OpenVPN config nvram vars, and I have never been near dd-wrt's GUI with a Windows machine. I use linux exclusively (and have for over 35 years if we include pre-linux Unix species). I maintain the important large nvram vars (additional config windows, etc.) in emacs on my laptop and have makefile scripts to scp them to dd-wrt and put them back into their nvram vars. When I strip off the ^M chars in emacs, they go back over clean. But some lesser-used dd-wrt action (GUI? post-flashing setup? just guessing here) does occasionally restore the ^M chars.

I used to care, until it was discovered that my model router has 2x the nvram space we all thought it had!

_________________
5 Linksys WRT1900ACSv2 routers on 50474: VLANs, VAPs, NAS, client mode, OpenVPN client (AirVPN), wireguard servers (via AirVPN port forwarding) and clients (AzireVPN and AirVPN), 3 DNSCrypt DNS providers via VPN clients.
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 330

PostPosted: Tue Aug 30, 2022 21:35    Post subject: Reply with quote
I also stated on page 1 that saving the additional cron jobs with linux firefox adds the ^M. The "browser thing" link I gave on page 1 says "The canonical form of any MIME "text" subtype MUST always represent a line break as a CRLF sequence." so the linux browsers are probably following the spec. Any dd-wrt after r49908 cleans up the carriage returns when a page's variables are saved to nvram. The ^Ms on multi-line nvram variables are a thing of the past.
Goto page Previous  1, 2 Display posts from previous:    Page 2 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum